在Nginx上使用WordPress

Nginx で WordPress を使う時の設定ファイルです。
CentOS 7.8 の例です。
Letsencrypt と パーマリンクを使います。

服务器名称是wordpress.example.com,根目录为/var/www/html。

server {
    listen       80;

    listen  443 ssl;
    server_name     wordpress.example.com;
    ssl_certificate  /etc/letsencrypt/live/wordpress.example.com/fullchain.pem;
    ssl_certificate_key  /etc/letsencrypt/live/wordpress.example.com/privkey.pem;


    location / {
    try_files $uri $uri/ @wordpress;
        root   /var/www/html;
        index  index.html index.htm index.php;
    }


    error_page   500 502 503 504  /50x.html;
    location = /50x.html {
        root   /var/www/html;
    }


    location ~ \.php$ {
    try_files $uri @wordpress;
        root   /var/www/html;
        fastcgi_pass   127.0.0.1:9000;
        fastcgi_index  index.php;
        fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
        include        fastcgi_params;
    }

    location @wordpress {
        fastcgi_index index.php;
        fastcgi_split_path_info ^(.+\.php)(.*)$;
        fastcgi_pass  127.0.0.1:9000;
        fastcgi_param SCRIPT_FILENAME  /var/www/html/index.php;
        include       fastcgi_params;
    }

}
广告
将在 10 秒后关闭
bannerAds