zoukankan      html  css  js  c++  java
  • nginx 403 问题解决

    一、由于启动用户和nginx工作用户不一致所致

    /etc/nginx/nginx.conf

      

    vim nginx.conf
    user  root;
    worker_processes  2;
    
    error_log  /var/log/nginx/error.log warn;
    pid        /var/run/nginx.pid;
    
    
    events {
        worker_connections  65535;
    }
    
    
    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_tokens off;
    }

    需要修改的地方为 user:root, 默认为 user:nginx

    修改后就可以访问了

    二、缺少index.html或者index.php文件,就是配置文件中index index.html index.htm这行中的指定的文件。

    1.    server {  

    2.      listen       80;  

    3.      server_name  localhost;  

    4.      index  index.php index.html;  

    5.      root  /data/www/;

    6.    }

    如果在/data/www/下面没有index.php,index.html的时候,直接文件,会报403 forbidden。

    三、权限问题,如果nginx没有web目录的操作权限,也会出现403错误。

    解决办法:修改web目录的读写权限,或者是把nginx的启动用户改成目录的所属用户,重启Nginx即可解决

    1.    chmod -R 777 /data

    2.    chmod -R 777 /data/www/

    拼一个春夏秋冬.赢一个无悔人事。
  • 相关阅读:
    Gevent高并发网络库精解
    python多线程参考文章
    python多线程
    进程与线程
    golang 微服务以及相关web框架
    微服务实战:从架构到发布
    python 常用库收集
    总结数据科学家常用的Python库
    20个最有用的Python数据科学库
    自然语言处理的发展历程
  • 原文地址:https://www.cnblogs.com/wylb/p/10633006.html
Copyright © 2011-2022 走看看