繁体   English   中英

Nginx未加载index.php

[英]Nginx not loading index.php

我在ubuntu pc中使用nginx和php5-fpm,我的网站没有加载到浏览器中,我已经配置了所有内容,但是运行index.php时,浏览器控制台出现500个内部服务器错误。

这是我的代码(etc / nginx / sites-available / default)

server {
listen 80 default_server;
listen [::]:80 default_server ipv6only=on;

root /usr/share/nginx/html/Inwiter;
index index.php index.htm index.html;

# Make site accessible from http://localhost/
server_name localhost;

location / {
    # First attempt to serve request as file, then
    # as directory, then fall back to displaying a 404.
    try_files $uri $uri/ /index.php;
    #try_files $uri $uri/ =404;
    # Uncomment to enable naxsi on this location
    # include /etc/nginx/naxsi.rules
}

location ~ \.php$ {
        fastcgi_split_path_info ^(.+\.php)(/.+)$;
        # NOTE: You should have "cgi.fix_pathinfo = 0;" in php.ini

        # With php5-cgi alone:
        # fastcgi_pass 127.0.0.1:9000;
        # With php5-fpm:
        fastcgi_pass unix:/var/run/php5-fpm.sock;
        fastcgi_index index.php;
        include fastcgi_params;
    }

}

几天前,当我在配置文件中添加允许accessToken时,我也遇到了此类问题(不完全是此问题),那对我来说很好。 add_header访问控制允许来源*;

作为您提供的日志,nginx仍尝试将fastcgi://127.0.0.1:9000用作fastcgi_pass。

您是否在修改后重新启动nginx或重新加载配置?

此外,请检查/etc/php5/fpm/pool.d/配置文件。

必须在一行中添加listen = /var/run/php5-fpm.sock

我建议您删除ipv6only=on ,然后尝试执行以下示例配置:

location / {
    try_files $uri $uri/ =404;
}
location ~ \.php$ {
    include fastcgi_params;
    fastcgi_split_path_info ^(.+\.php)(/.+)$;
    fastcgi_pass unix:/var/run/php5-fpm.sock;
    fastcgi_index index.php;
    fastcgi_intercept_errors on;
    try_files $uri =404;
}

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM