無法讓 nginx 渲染我的 WordPress 網站

無法讓 nginx 渲染我的 WordPress 網站

我是 nginx 的新手,但我認真地遵循了所有教學並嘗試設定我的 WordPress 網站,但目前我遇到了無法解決的問題。基本上我的 WordPress 網站的設定檔中有以下配置:

server {
    listen 80;
    listen 443 default ssl;

    server_name domain.com;
    root /var/www/html/domain.com/htdocs;

    access_log /var/www/html/domain.com/htdocs/logs/access.log;
    error_log /var/www/html/domain.com/htdocs/logs/error.log;

    location / {
            index index.php index.html;
            try_files $uri $uri/ /index.php?$args;
    }

    rewrite /wp-admin$ $scheme://$host$uri/ permanent;

    location ~ /\. {
            access_log off;
            log_not_found off;
            deny all;
    }

    rewrite /files/$ /index.php last;

    if ($uri !~ wp-content/plugins) {
            rewrite /files/(.+)$ /wp-includes/ms-files.php?file=$1 last;
    }

    location ~* ^/(favicon.ico|robots.txt)$ {
            access_log off;
            log_not_found off;
    }

    location ~ .php$ {
            try_files $uri =404;

            # Include the fastcgi_params defaults provided by nginx
            include        /etc/nginx/fastcgi_params;

            # SCRIPT_FILENAME is a required parameter for things to work properly,
            # but is missing in the default fastcgi_params. We define it here to
            # be sure that it exists.
            #fastcgi_param   SCRIPT_FILENAME         $document_root$fastcgi_script_name;
            fastcgi_param SCRIPT_FILENAME /var/www/html/domain.com/htdocs$fastcgi_script_name;

                            # Use the upstream for fastcgi / php5-fpm that we defined in nginx.conf
            fastcgi_pass   php;

            # And get to serving the file!
            fastcgi_index  index.php;
    }

}

當我輸入 IP 位址/domain.com 時,有一點延遲,然後我就得到了該網站的文字。沒有錯誤,實際上就像頁面沒有呈現一樣。這是因為 php 沒有被正確解析嗎?否則對我做錯了什麼有什麼想法嗎?

答案1

看來您還沒有設定 nginx 來處理 PHP。查看回答。

相關內容