首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >centos7禁用

centos7禁用
EN

Stack Overflow用户
提问于 2017-06-02 23:29:52
回答 1查看 854关注 0票数 0

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

代码语言:javascript
复制
[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"

我的文件配置如下:

代码语言:javascript
复制
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/股

我不知道我在做什么:

谢谢你的帮助,祝你日子愉快。

戴维德

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2017-06-03 02:08:29

我来解决它。这是我的新nginx.conf

代码语言:javascript
复制
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;
                 }
        }

}
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/44338724

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档