Nginx?403?forbidden錯誤的原因以及解決方法
一、由于啟動用戶和nginx工作用戶不一致所致
1.1查看nginx的啟動用戶,發(fā)現(xiàn)是nginx,而為是用root啟動的
[root@iZwz96xkbmh1v1n08cvb5dZ /]# ps aux|grep nginx root 2773 0.0 0.0 9068 844 ? Ss 13:56 0:00 nginx: master process /usr/sbin/nginx nginx 2774 0.0 0.1 9476 2360 ? S 13:56 0:00 nginx: worker process root 2916 0.0 0.0 221460 836 pts/0 R+ 13:59 0:00 grep --color=auto nginx
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.3 也可以使用如下命令直接查看
ps aux|grep nginx
[root@iZwz96xkbmh1v1n08cvb5dZ nginx]# ps aux|grep nginx root 2983 0.0 0.0 9068 848 ? Ss 14:02 0:00 nginx: master process /usr/sbin/nginx root 2984 0.0 0.1 9476 2356 ? S 14:02 0:00 nginx: worker process root 2986 0.0 0.0 221460 848 pts/0 R+ 14:02 0:00 grep --color=auto nginx
二、缺少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; }
如果在/data/www/下面沒有index.html的時候,直接文件,會報403 forbidden。
三、權限問題,如果nginx沒有web目錄的操作權限,也會出現(xiàn)403錯誤。
解決辦法:修改web目錄的讀寫權限,或者是把nginx的啟動用戶改成目錄的所屬用戶,重啟Nginx即可解決
chmod -R 777 /data
chmod -R 777 /data/www/
[root@iZwz96xkbmh1v1n08cvb5dZ data]# chmod 777 www [root@iZwz96xkbmh1v1n08cvb5dZ data]# ls -l total 4 drwxrwxrwx 3 root root 4096 Apr 10 14:26 www
總結
到此這篇關于Nginx 403 forbidden錯誤的原因以及解決方法的文章就介紹到這了,更多相關Nginx 403 forbidden錯誤解決內(nèi)容請搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關文章希望大家以后多多支持腳本之家!
- Nginx 403 forbidden的解決辦法
- Nginx 出現(xiàn) 403 Forbidden 最終解決方法
- Nginx解決403 forbidden的完整步驟
- Nginx?403?forbidden錯誤的五種原因及詳細解決方法
- 詳解Nginx 出現(xiàn) 403 Forbidden 的解決辦法
- Nginx出現(xiàn)403?Forbidden的幾種簡單解決方式
- Nginx出現(xiàn)403 Forbidden問題的常見原因與解決
- 配置Nginx出現(xiàn)403(Forbidden)靜態(tài)文件加載不出來的解決方法
- Nginx出現(xiàn)403 Forbidden的四種解決方案分享
- Nginx 報403 Forbidden錯誤常見原因和解決方案
相關文章
Nginx使用limit_req_zone對同一IP訪問進行限流的方法
今天小編就為大家分享一篇Nginx使用limit_req_zone對同一IP訪問進行限流的方法,具有很好的參考價值,希望對大家有所幫助。一起跟隨小編過來看看吧2019-08-08解決nginx+uwsgi部署Django的所有問題(小結)
本篇文章主要介紹了解決nginx+uwsgi部署Django的所有問題(小結),小編覺得挺不錯的,現(xiàn)在分享給大家,也給大家做個參考。一起跟隨小編過來看看吧2018-04-04nginx 部署 vue 項目找不到js css文件的解決方法
這篇文章主要介紹了nginx 部署 vue 項目找不到js css文件的解決方法,本文給大家介紹的非常詳細,具有一定的參考借鑒價值,需要的朋友可以參考下2019-07-07