Nginx没有加载index.php

时间:2015-08-31 13:00:57

标签: php nginx

我在我的ubuntu电脑中使用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;
    }

}

2 个答案:

答案 0 :(得分:0)

几天前我也遇到了这种问题(不完全是这个问题)我添加的时间允许在我的配置文件中使用accessToken然后它对我来说很好。 add_header Access-Control-Allow-Origin *;

答案 1 :(得分:0)

作为您提供的日志,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;
}
相关问题