本地主机中禁止使用Nginx 403

本地主机中禁止使用Nginx 403,nginx,permissions,localhost,chmod,chown,Nginx,Permissions,Localhost,Chmod,Chown,我已将所有html文件的所有者设置为www数据,所有文件夹的chmod为755 即。 在文件夹var/www中,我执行: sudo chown -R www-data:www-data html & 这为文件夹提供了这些权限 drwxr-xr-x 6 www-data www-data 4096 oct 14 08:52 podcast 但是,nginx仍然会出现403禁止的错误: 2017/03/25 12:52:35 [error] 21916#21916: *2 directory

我已将所有html文件的所有者设置为www数据,所有文件夹的chmod为755 即。 在文件夹var/www中,我执行:

sudo chown -R www-data:www-data html
&

这为文件夹提供了这些权限

drwxr-xr-x 6 www-data www-data  4096 oct 14 08:52 podcast
但是,nginx仍然会出现403禁止的错误:

2017/03/25 12:52:35 [error] 21916#21916: *2 directory index of "/var/www/html/podcast/" is forbidden, client: ::1, server: _, request: "GET /podcast/ HTTP/1.1", host: "localhost"
nginx配置:

    user bus;
worker_processes auto;
pid /run/nginx.pid;

events {
    worker_connections 768;
    # multi_accept on;
}

http {

##
# Basic Settings
##

sendfile on;
tcp_nopush on;
tcp_nodelay on;
keepalive_timeout 65;
types_hash_max_size 2048;
# server_tokens off;

# server_names_hash_bucket_size 64;
# server_name_in_redirect off;

include /etc/nginx/mime.types;
default_type application/octet-stream;

##
# SSL Settings
##

ssl_protocols TLSv1 TLSv1.1 TLSv1.2; # Dropping SSLv3, ref: POODLE
ssl_prefer_server_ciphers on;

##
# Logging Settings
##

access_log /var/log/nginx/access.log;
error_log /var/log/nginx/error.log;

##
# Gzip Settings
##

gzip on;
gzip_disable "msie6";

# gzip_vary on;
# gzip_proxied any;
# gzip_comp_level 6;
# gzip_buffers 16 8k;
    # gzip_http_version 1.1;
    # gzip_types text/plain text/css application/json application/javascript text/xml application/xml application/xml+rss text/javascript;

    ##
    # Virtual Host Configs
    ##

    include /etc/nginx/conf.d/*.conf;
    include /etc/nginx/sites-enabled/*;
}
默认站点:

server {
listen 80 default_server;
listen [::]:80 default_server;

# SSL configuration
#
# listen 443 ssl default_server;
# listen [::]:443 ssl default_server;
#
# Note: You should disable gzip for SSL traffic.
# See: https://bugs.debian.org/773332
#
# Read up on ssl_ciphers to ensure a secure configuration.
# See: https://bugs.debian.org/765782
#
# Self signed certs generated by the ssl-cert package
# Don't use them in a production server!
#
# include snippets/snakeoil.conf;

root /var/www/html;

# Add index.php to the list if you are using PHP
index index.php index.html index.htm index.nginx-debian.html;

server_name _;

location / {
    # First attempt to serve request as file, then
    # as directory, then fall back to displaying a 404.
    try_files $uri $uri/ =404;
}

# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
#
#location ~ \.php$ {
#   include snippets/fastcgi-php.conf;
#
#   # With php7.0-cgi alone:
#   fastcgi_pass 127.0.0.1:9000;
#   # With php7.0-fpm:
#   fastcgi_pass unix:/run/php/php7.0-fpm.sock;
#}

# deny access to .htaccess files, if Apache's document root
# concurs with nginx's one
#
#location ~ /\.ht {
#   deny all;
#}
}

此错误消息与文件权限无关。它与目录处理有关。有关更多信息,请参阅。好的,知道如何修复目录处理吗?您希望
nginx
做什么?提供目录列表或目录中文件的内容。查看您现有的服务器配置会很有用。我希望它提供index.php文件的内容…现在它正在下载该文件。您是否安装、配置和运行了
php fpm
?因为您需要告诉
nginx
如何将
php
脚本传递给它,否则它只会下载文件。搜索nginx下载php文件此错误消息与文件权限无关。它与目录处理有关。有关更多信息,请参阅。好的,知道如何修复目录处理吗?您希望
nginx
做什么?提供目录列表或目录中文件的内容。查看您现有的服务器配置会很有用。我希望它提供index.php文件的内容…现在它正在下载该文件。您是否安装、配置和运行了
php fpm
?因为您需要告诉
nginx
如何将
php
脚本传递给它,否则它只会下载文件。搜索nginx下载php文件
server {
listen 80 default_server;
listen [::]:80 default_server;

# SSL configuration
#
# listen 443 ssl default_server;
# listen [::]:443 ssl default_server;
#
# Note: You should disable gzip for SSL traffic.
# See: https://bugs.debian.org/773332
#
# Read up on ssl_ciphers to ensure a secure configuration.
# See: https://bugs.debian.org/765782
#
# Self signed certs generated by the ssl-cert package
# Don't use them in a production server!
#
# include snippets/snakeoil.conf;

root /var/www/html;

# Add index.php to the list if you are using PHP
index index.php index.html index.htm index.nginx-debian.html;

server_name _;

location / {
    # First attempt to serve request as file, then
    # as directory, then fall back to displaying a 404.
    try_files $uri $uri/ =404;
}

# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
#
#location ~ \.php$ {
#   include snippets/fastcgi-php.conf;
#
#   # With php7.0-cgi alone:
#   fastcgi_pass 127.0.0.1:9000;
#   # With php7.0-fpm:
#   fastcgi_pass unix:/run/php/php7.0-fpm.sock;
#}

# deny access to .htaccess files, if Apache's document root
# concurs with nginx's one
#
#location ~ /\.ht {
#   deny all;
#}
}