问题
访问测试环境一直报错 NS_ERROR_CONNECTION_REFUSED
现象
使用ps查看,只能看到一条nginx进程
[root@iZwz918g1z0sb8tcwfjri3Z sbin]# ps -ef|grep nginx
root 6772 4449 0 12:12 pts/1 00:00:00 grep --color=auto nginx
使用 ./nginx -s reload 重新加载配置文件,注意此处invalid PID number,目录 /usr/local/nginx/logs 中 PID文件大小为0k
[srm-test@iZwz918g1z0sb8tcwfjri3Z ~]$ cd /usr/local/nginx/sbin
[srm-test@iZwz918g1z0sb8tcwfjri3Z sbin]$ ./nginx -s reload
nginx: [alert] could not open error log file: open() "/usr/local/nginx/logs/error.log" failed (13: Permission denied)
2023/06/15 14:16:21 [notice] 14734#0: signal process started
2023/06/15 14:16:21 [error] 14734#0: invalid PID number "" in "/usr/local/nginx/logs/nginx.pid"
解决
[root@iZwz918g1z0sb8tcwfjri3Z usr]# cd local/nginx
[root@iZwz918g1z0sb8tcwfjri3Z nginx]# /usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf
[root@iZwz918g1z0sb8tcwfjri3Z nginx]# cd sbin/
[root@iZwz918g1z0sb8tcwfjri3Z sbin]# ll
total 6036
-rw-r--r-- 1 root root 2 Jun 15 12:09 access.log
-rwxr-xr-x 1 root root 16930 Mar 16 2020 dso_tool
-rwxr-xr-x 1 root root 6153752 Mar 16 2020 nginx
注意此处,下面这种情况才算是重启成功
[root@iZwz918g1z0sb8tcwfjri3Z sbin]# ./nginx -t
nginx: the configuration file /usr/local/nginx/conf/nginx.conf syntax is ok
nginx: configuration file /usr/local/nginx/conf/nginx.conf test is successful
注意:查出来三条才算是重启成功
[root@iZwz918g1z0sb8tcwfjri3Z sbin]# ps -ef | grep nginx
root 15536 1 0 14:28 ? 00:00:00 nginx: master process /usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf
nobody 15620 15536 0 14:30 ? 00:00:00 nginx: worker process
root 15638 15006 0 14:30 pts/1 00:00:00 grep --color=auto nginx