nginx怎么访问不了html文件?(/usr/share/nginx/html/)

Posted on Posted in 时事八卦, 最新资讯

localhost可以访问nginx页面
但是我在/usr/share/nginx/html/下建了html文件访问不了?

这是/etc/nginx/sites-availble/default文件

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

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

    # 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/ =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;
    }
}

回复内容:

localhost可以访问nginx页面
但是我在/usr/share/nginx/html/下建了html文件访问不了?

这是/etc/nginx/sites-availble/default文件

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

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

    # 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/ =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;
    }
}

需要更多的信息?比如访问url,你在目录下的文件等。还有看看错误日志,看看是不是nginx没有访问你新建文件的权限等。

应该是权限问题,sudo nginx -s reload

这情况多了去了……
最常见的一个就是:selinux还开着?

该文章由WP-AutoPost插件自动采集发布

原文地址:http://www.php.cn/php-weizijiaocheng-106866.html

发表评论

电子邮件地址不会被公开。 必填项已用*标注