1. 程式人生 > >centos7 安裝 wrodpress 4.9

centos7 安裝 wrodpress 4.9

提前條件:

安裝nginx 1.12

安裝mysql 5.7.22

安裝php 7.2

安裝nginx,mysql,php指導:

下載、解壓、填寫資料庫連線串:

mkdir /data/webs
cd /data/webs
wget https://cn.wordpress.org/wordpress-4.9.4-zh_CN.tar.gz
tar -zxvf wordpress-4.9.4-zh_CN.tar.gz
cp wordpress/wp-config-sample.php wordpress/wp-config.php
vi wordpress/wp-config.php
/** WordPress資料庫的名稱 */
define('DB_NAME', 'wp_test');
/** MySQL資料庫使用者名稱 */
define('DB_USER', 'wp_user');
/** MySQL資料庫密碼 */
define('DB_PASSWORD', 'pw1!23456');
/** MySQL主機 */
define('DB_HOST', 'localhost:3306');
/** 建立資料表時預設的文字編碼 */
define('DB_CHARSET', 'utf8mb4');

vi /etc/nginx/conf.d/wp_test.conf

server {
    listen       80;                        # 監聽埠
    server_name www.siteA.com siteA.com;    # 站點域名
    root  /data/webs/wordpress;              # 站點根目錄
    index index.html index.htm index.php;   # 預設導航頁

    location / {
        # WordPress固定連結URL重寫
        if (!-e $request_filename) {
            rewrite (.*) /index.php;
        }
    }

    # PHP配置
    location ~ \.php$ {
        root  /data/webs/wordpress;
        fastcgi_pass 127.0.0.1:9000;
        fastcgi_index index.php;        
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        include fastcgi_params;
    }
}

啟動php:

systemctl start php-fpm

重啟nginx:

systemctl stop nginx

systemctl start nginx