定制设计Nginx 403 forbidden 错误的原因及解决方法

403 forbidden 定制设计错误的原因及解决方法

一、定制设计由于启动用户和nginx定制设计工作用户不一致所致

1.1查看nginx的启动用户,发现是nginx,而为是用root启动的

[root@iZwz96xkbmh1v1n08cvb5dZ /]# ps aux|grep nginxroot        2773  0.0  0.0   9068   844 ?        Ss   13:56   0:00 nginx: master process /usr/sbin/nginxnginx       2774  0.0  0.1   9476  2360 ?        S    13:56   0:00 nginx: worker processroot        2916  0.0  0.0 221460   836 pts/0    R+   13:59   0:00 grep --color=auto nginx
  • 1
  • 2
  • 3
  • 4

1.2将nginx.config的user改为和启动用户一致,

命令:vim etc/nginx.conf

# For more information on configuration, see:#   * Official English Documentation: http://nginx.org/en/docs/#   * Official Russian Documentation: http://nginx.org/ru/docs/user root; //就是这里worker_processes auto;error_log /var/log/nginx/error.log;pid /run/nginx.pid;
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9

1.3 也可以使用如下命令直接查看

ps aux| nginx

[root@iZwz96xkbmh1v1n08cvb5dZ nginx]# ps aux|grep nginxroot        2983  0.0  0.0   9068   848 ?        Ss   14:02   0:00 nginx: master process /usr/sbin/nginxroot        2984  0.0  0.1   9476  2356 ?        S    14:02   0:00 nginx: worker processroot        2986  0.0  0.0 221460   848 pts/0    R+   14:02   0:00 grep --color=auto nginx
  • 1
  • 2
  • 3
  • 4

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

 server {        listen       80;        listen       [::]:80;        server_name  _;        root         /usr/share/nginx/html;            # Load configuration files for the default server block.        include /etc/nginx/default.d/*.conf;        location / {        root /root/xiaoaodi/index/dist;        index index.html;        }
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14

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

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

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

  1. chmod -R 777 /data

  2. chmod -R 777 /data/www/

  3. [root@iZwz96xkbmh1v1n08cvb5dZ data]# chmod 777 www[root@iZwz96xkbmh1v1n08cvb5dZ data]# ls -ltotal 4drwxrwxrwx 3 root root 4096 Apr 10 14:26 www
    • 1
    • 2
    • 3
    • 4
    • 5
网站建设定制开发 软件系统开发定制 定制软件开发 软件开发定制 定制app开发 app开发定制 app开发定制公司 电商商城定制开发 定制小程序开发 定制开发小程序 客户管理系统开发定制 定制网站 定制开发 crm开发定制 开发公司 小程序开发定制 定制软件 收款定制开发 企业网站定制开发 定制化开发 android系统定制开发 定制小程序开发费用 定制设计 专注app软件定制开发 软件开发定制定制 知名网站建设定制 软件定制开发供应商 应用系统定制开发 软件系统定制开发 企业管理系统定制开发 系统定制开发