1. 程式人生 > >CentOS 6.5安裝WordPress(基於LNMP)

CentOS 6.5安裝WordPress(基於LNMP)

mys adding -s 6.5 pan 說明 宋體 AI bz2

一、LNMP環境版本說明:

OS:最小化安裝CentOS 6.5

Nginxnginx-1.10.2.tar.gz

MySQLmysql-5.6.24.tar.gz

PHPphp-5.6.23.tar.bz2

二、搭建LNMP環境(基於最小化安裝CentOS 6.5

此處省略,詳情參考http://blog.51cto.com/itops/2130205

三、安裝及配置WordPress

1.下載WordPress

wget http://wordpress.org/latest.tar.gz

tar -xzvf latest.tar.gz -C /usr/local


2.為WordPress在MySQL中創建一個DB及相關用戶

#登錄MYSQL

mysql -u root -p

#創建數據庫

CREATE DATABASE wordpress; #數據庫名為wordpress

#創建一個用戶

CREATE USER wpuser@localhost; #用戶名為wpuser

#設置密碼

SET PASSWORD FOR wpuser@localhost=PASSWORD("wppassword"); #密碼為wppassword

#分配用戶到DB權限

GRANT ALL PRIVILEGES ON wordpress.* TO wpuser@localhost IDENTIFIED BY 'wppassword'

;

#更新權限

FLUSH PRIVILEGES;


3.配置WordPress

cp /usr/local/wordpress/wp-config-sample.php /usr/local/wordpress/wp-config.php

vi /usr/local/wordpress/wp-config.php

/** WordPress數據庫的名稱 */

define('DB_NAME','wordpress');

/** MySQL數據庫用戶名 */

define('DB_USER','wpuser');

/** MySQL數據庫密碼 */

define('DB_PASSWORD','

wppassword');

4.配置nginx訪問WordPress

vi /etc/nginx/nginx.conf

#
# The default server
#
server {
listen 80;
server_name localhost;

#charset koi8-r;

#access_log logs/host.access.log main;

location / {
root /usr/local/wordpress; #wordpress所在目錄
index index.php index.html index.htm;
}

error_page 404 /404.html;
location = /404.html {
root /usr/local/nginx/html;
}

# redirect server error pages to the static page /50x.html
#
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/local/nginx/html;
}

# proxy the PHP scripts to Apache listening on 127.0.0.1:80
#
#location ~ \.php$ {
# proxy_pass http://127.0.0.1;
#}

# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
#
location ~ \.php$ {
root /usr/local/wordpress; #wordpress所在目錄
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME /usr/local/wordpress$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;
#}
}


5.重啟Nginx

service nginx reload


6.然後訪問http://ip/,就可以進入WordPress的安裝引導界面了。


CentOS 6.5安裝WordPress(基於LNMP)