无法让 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。请查看回答。

相关内容