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/

    拼一个春夏秋冬.赢一个无悔人事。
  • 相关阅读:
    C++11 std标准库chrono获取系统时间戳
    求取激光光斑质心
    Windows多网卡UDP广播问题
    IP地址分类
    C++各种时间的含义、区别和相互转换
    MFC中控件显示提示信息tooltip
    IP地址 网关 子网掩码之间的关系
    MFC动态添加菜单选项
    opencv函数学习:rotate()的使用
    opencv函数学习:flip()的使用
  • 原文地址:https://www.cnblogs.com/wylb/p/10633006.html
Copyright © 2011-2022 走看看