網站首頁 編程語言 正文
一、由于啟動用戶和nginx工作用戶不一致所致
1.1查看nginx的啟動用戶,發現是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目錄的操作權限,也會出現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
總結
原文鏈接:https://blog.csdn.net/qq_46087622/article/details/124080391
相關推薦
- 2023-04-18 C語言計算連續無序數組中缺省數字方法詳解_C 語言
- 2022-11-29 redis命令行操作庫、鍵、和五大數據類型詳解
- 2023-07-08 CMake Error at CMakeLists.txt:4 (find_package): By
- 2022-05-22 asp.net?Core中同名服務注冊的實現代碼_實用技巧
- 2022-05-20 Spring注入bean的常用的六種方式
- 2022-06-13 ASP.NET?Core?MVC中的模型(Model)_基礎應用
- 2022-08-04 深入理解pytorch庫的dockerfile_python
- 2023-01-07 Python數據類型轉換實現方法_python
- 最近更新
-
- window11 系統安裝 yarn
- 超詳細win安裝深度學習環境2025年最新版(
- Linux 中運行的top命令 怎么退出?
- MySQL 中decimal 的用法? 存儲小
- get 、set 、toString 方法的使
- @Resource和 @Autowired注解
- Java基礎操作-- 運算符,流程控制 Flo
- 1. Int 和Integer 的區別,Jav
- spring @retryable不生效的一種
- Spring Security之認證信息的處理
- Spring Security之認證過濾器
- Spring Security概述快速入門
- Spring Security之配置體系
- 【SpringBoot】SpringCache
- Spring Security之基于方法配置權
- redisson分布式鎖中waittime的設
- maven:解決release錯誤:Artif
- restTemplate使用總結
- Spring Security之安全異常處理
- MybatisPlus優雅實現加密?
- Spring ioc容器與Bean的生命周期。
- 【探索SpringCloud】服務發現-Nac
- Spring Security之基于HttpR
- Redis 底層數據結構-簡單動態字符串(SD
- arthas操作spring被代理目標對象命令
- Spring中的單例模式應用詳解
- 聊聊消息隊列,發送消息的4種方式
- bootspring第三方資源配置管理
- GIT同步修改后的遠程分支