LNMP環境下部署個人博客WordPress
概述
WordPress是一種使用PHP語言開發的博客平台,用戶可以在支持PHP和MySQL資料庫的伺服器上架設屬於自己的網站。也可把WordPress當作一個內容管理系統(CMS)來使用
本文將介紹如何部署WordPress
2 布署wordpress
.下載地址:
官網:https://cn.wordpress.org/
2.1 解壓服務包
解壓縮WordPress博客程序到網頁站點目錄下
cd /home/wwwtar -xzvf wordpress-4.8-zh_CN.tar.gz
2.2 創建資料庫和賬號
在mysql資料庫下新建wordpress庫和wordpress用戶
可以通過phpmyadmin管理頁面進行創建,或者通過以下的語句進行創建
mysql> create database wordpress;mysql> grant all on wordpress.* to wordpress@"192.168.137.%" identified by"123456";
flush privileges;
2.3 配置文件
有兩個方法
方法一,直接修改配置文件
cp -rp wrodpress/* /home/www/
cp /home/www/wp-config-sample.php /home/www/wp-config.phpvim /home/www/wp-config.php/**指定 WordPress資料庫的名稱,如這裡是wpdb這個資料庫*/define("DB_NAME","wrodpress");/**MySQL資料庫用戶名和對應的密碼*/define("DB_USER","wrodpress");define("DB_PASSWORD", "123456");
/** MySQL主機 */
define("DB_HOST", "192.168.137.133");
.注意wordpress目錄許可權
[root@localhost ~]# cat /usr/local/nginx/conf/nginx.conf
user nginx nginx;
worker_processes 1;
worker_rlimit_nofile 65535;
events {
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;
#log_format main "$remote_addr - $remote_user [$time_local] "$request" "
# "$status $body_bytes_sent "$http_referer" "
# ""$http_user_agent" "$http_x_forwarded_for"";
#access_log logs/access.log main;
sendfile on;
#tcp_nopush on;
#keepalive_timeout 0;
keepalive_timeout 65;
#gzip on;
server {
listen 80;
server_name localhost;
#charset koi8-r;
location / {
root /home/www;
index index.php index.html index.htm;
}
location /favicon.ico {
log_not_found off;
access_log off;
}
#error_page 404 /404.html;
# redirect server error pages to the static page /50x.html
#
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
location ~ .php$ {
root /home/www;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
# deny access to .htaccess files, if Apache"s document root
# concurs with nginx"s one
#
#location ~ /.ht {
# deny all;
#}
}
# another virtual host using mix of IP-, name-, and port-based configuration
#
#server {
# listen 8000;
# listen somename:8080;
# server_name somename alias another.alias;
# location / {
# root html;
# index index.html index.htm;
# }
#}
# HTTPS server
#
#server {
# listen 443 ssl;
# server_name localhost;
# ssl_certificate cert.pem;
# ssl_certificate_key cert.key;
# ssl_session_cache shared:SSL:1m;
# ssl_session_timeout 5m;
# ssl_ciphers HIGH:!aNULL:!MD5;
# ssl_prefer_server_ciphers on;
# location / {
# root html;
# index index.html index.htm;
# }
#}
}
4 測試
打開http://192.168.137.133/index.php進行用戶賬號的相關設置,如站點名稱,登錄站點的用戶名和密碼,建議用弱密碼,輸入郵箱地址,是否允許搜索等設置
到這裡wordpress的基本設置就完成了,可以進入站點進行編輯。
管理頁面:http://192.168.137.133/wp-admin/
個人頁面:http://172.18.50.75/
TAG:運維邦 |