Nginx 启动失败,The system cannot find the file specified错误解决方案
问题介绍
nginx执行nginx -s reload
时,出现如下错误:
nginx: [error] CreateFile() "C:\web\nginx-1.17.9/logs/nginx.pid" failed (2: The system cannot find the file specified)
排查方法
执行命令nginx -t
查看配置文件是否正确,大部分问题都是因为配置文件造成的,此命令会列出配置文件错误项。如下:
C:\web\nginx-1.17.9>nginx.exe -t
nginx: the configuration file C:\web\nginx-1.17.9/conf/nginx.conf syntax is ok
nginx: [emerg] bind() to 0.0.0.0:8090 failed (10013: An attempt was made to access a socket in a way forbidden by its access permissions)
nginx: configuration file C:\web\nginx-1.17.9/conf/nginx.conf test failed
可以看出,配置文件中监听端口号无法正常启动,应是被占用了,修改端口之后,重新执行nginx -s reload
即可。
P.S. 本人nginx并不熟悉,此文也仅是记录下本次碰到此问题的解决过程。故此方案未必能解决所有同类问题。