• 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/

    拼一个春夏秋冬.赢一个无悔人事。
  • 相关阅读:
    Opengl编程指南第三章:视图
    OpenGL编程指南第四章:颜色
    OpenGL编程指南第七章:显示列表
    推荐:字体、排版简明入门
    OpenGL编程指南第八章:绘制像素、位图、字体和图像
    推荐:字体、排版简明入门
    OpenGL编程指南第五章:光照
    转载一篇密码学基本介绍
    ARM_异常和中断学习笔记
    ARM指令学习笔记
  • 原文地址:https://www.cnblogs.com/wylb/p/10633006.html
Copyright © 2020-2023  润新知