簡體   English   中英

Nginx centos7被禁止

[英]Nginx centos7 forbidden

我安裝了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.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;
                 }
        }

}

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM