【问题标题】:Nginx centos7 forbiddenNginx centos7 被禁止
【发布时间】:2017-06-03 10:08:29
【问题描述】:

我安装了 nginx,但我的日志文件中有这个错误

[error] 2658#2658: *2 directory index of "/usr/share/nginx/html/" is 
forbidden, client: 192.168.1.2, server: localhost, request: "GET / HTTP/1.1", host: "192.168.1.6"

我的文件配置是这样的:

user  nginx;

worker_processes  1;

error_log  /var/log/nginx/error.log warn;
pid        /var/run/nginx.pid;

events {
    worker_connections  1024;
}


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

    log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
                      '$status $body_bytes_sent "$http_referer" '
                      '"$http_user_agent" "$http_x_forwarded_for"';

    access_log  /var/log/nginx/access.log  main;

    sendfile        on;
    #tcp_nopush     on;

    keepalive_timeout  65;

    #gzip  on;

    include /etc/nginx/conf.d/*.conf;
    server{
        listen 80;
        root /usr/share/nginx/html;
        index index.php index.html;
        server_name 192.168.1.10;
        location ~ \.php$ {
#root           /usr/share/nginx/html;
fastcgi_pass   127.0.0.1:9000;
#       include fastcgi_params;
#       fastcgi_pass unix:/var/run/php-fpm.sock;
#      include /etc/nginx/fastcgi_params;
#        fastcgi_pass  127.0.0.1:80;
        fastcgi_index index.php;
fastcgi_param  SCRIPT_FILENAME $fastcgi_script_name;
 include        fastcgi_params;
        }
         location ~ /\.ht {
                         deny all;
         }
    }

}

`

但我有 403 被禁止。 我试图:

  • Chmod -R 775 /usr/src

  • Chmod o+x /usr

  • Chown -R nginx:nginx /usr/share

我不知道我在做什么:(

感谢您的帮助, 有一个美好的日子。

大卫。

【问题讨论】:

    标签: nginx centos centos7


    【解决方案1】:

    我解决了。 这是我的新 nginx.conf

    user  nginx;
    worker_processes  1;
    
    error_log  /var/log/nginx/error.log warn;
    pid        /var/run/nginx.pid;
    
    events {
        worker_connections  1024;
    }
    
    
    http {
        include   /etc/nginx/mime.types;
        default_type  application/octet-stream;
    
    log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
                      '$status $body_bytes_sent "$http_referer" '
                      '"$http_user_agent" "$http_x_forwarded_for"';
    
    access_log  /var/log/nginx/access.log  main;
    
    sendfile        on;
    #tcp_nopush     on;
    
    keepalive_timeout  65;
    
    #gzip  on;
    
    include /etc/nginx/conf.d/*.conf;
        server{
                listen 80;
                root /usr/share/nginx/html/;
                index index.php index.html index.htm;
                server_name 192.168.1.6;
                location ~ \.php$ {
                include /etc/nginx/fastcgi_params;
                fastcgi_pass  127.0.0.1:9000;
                fastcgi_index index.php;
    
    fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
                    }
                     location ~ /\.ht {
                                         deny all;
                     }
            }
    
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2020-07-07
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-09-03
      • 1970-01-01
      • 2018-10-16
      • 2016-06-19
      相关资源
      最近更新 更多