第一种报错:找不到nginx.pid文件
具体报错内容:
nginx: [error] open() “/run/nginx.pid” failed (2: No such file or directory)
解决方案:
- 手动创建进行文件
sudo touch /run/nginx.pid sudo chmod 644 /run/nginx.pid
- 查看nginx进程id
> sudo ps aux | grep nginx root 16021 0.0 0.1 57660 6336 ? Ss 2023 0:00 nginx: master process nginx www-data 3580220 0.0 0.1 57900 7516 ? S 2023 0:00 nginx: worker process www-data 3580221 0.0 0.2 58176 8104 ? S 2023 0:42 nginx: worker process root 4019076 0.0 0.0 9032 724 pts/0 S+ 09:05 0:00 grep --color=auto nginx
- 把主进程id写到文件中
sudo echo "16021" > /run/nginx.pid
- 启动nginx
nginx -s reload
第二种报错:无效的PID进程编号
具体报错内容:
[error] invalid PID number “” in “/run/nginx.pid”
解决方案:
- 修改nginx.pid文件权限
sudo chmod 644 /run/nginx.pid
- 查看nginx进程id
> sudo ps aux | grep nginx root 16021 0.0 0.1 57660 6336 ? Ss 2023 0:00 nginx: master process nginx www-data 3580220 0.0 0.1 57900 7516 ? S 2023 0:00 nginx: worker process www-data 3580221 0.0 0.2 58176 8104 ? S 2023 0:42 nginx: worker process root 4019076 0.0 0.0 9032 724 pts/0 S+ 09:05 0:00 grep --color=auto nginx
- 把主进程id写到文件中
sudo echo "16021" > /run/nginx.pid
- 启动nginx
nginx -s reload