0

我将我的网站存储在 /usr/share/nginx/html 中。所有目录和文件都有 777。当我启动浏览器并导航到网站时,它会下载页面而不是显示它。php-fpm 已安装并正在运行

这是我的 /etc/nginx/conf.d/default.conf

server {
listen       80;
server_name  hostedweb.net;

#charset koi8-r;
#access_log  /var/log/nginx/log/host.access.log  main;

location / {
    root   /usr/share/nginx/html;
    index  index.php index.htm;
}

#error_page  404              /404.html;

# redirect server error pages to the static page /50x.html
#
error_page   500 502 503 504  /50x.html;
location = /50x.html {
    root   /usr/share/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           html;
    fastcgi_pass   127.0.0.1:9000;
    fastcgi_index  index.php;
    fastcgi_param  SCRIPT_FILENAME  /scripts$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;
#}

}

我在 CentOS 6 上,任何帮助表示赞赏

4

2 回答 2

0

在您location ~ \.php$ {尝试添加include fastcgi_params;

同样在您的 php 部分中,您可以尝试取出该root html;部分,或尝试将其设置为root /usr/share/nginx/html;

您是否尝试过删除或注释掉fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name;?我的任何 nginx 配置文件中都没有该行,它们似乎工作正常。

于 2013-10-06T16:50:16.297 回答
0

您是否尝试添加

try_files $uri $uri/;

到你的location / {}街区

我相信你不需要这条线

fastcgi_param  SCRIPT_FILENAME  /scripts$fastcgi_script_name;

因为你包括fastcgi_params

于 2013-10-08T09:06:53.183 回答