首页 > IT职业 > IT职场 > 学习openresty时,nginx的一个坑
nginx: [error] CreateFile() “./logs/nginx.pid” failed (2: The system cannot find the file specified)
博主在执行了nginx -s stop后,再次启动nginx时报错:

这个坑主要原因就是没有nginx.pid这个文件,./logs/下找不到nginx.pid文件,看了确实找不到。
看了网上很多方案是 需要建立nginx.pid文件,也就是要指定nginx.conf这个配置文件,然后博主很傻的这样执行了一把:
nginx -c conf/nginx.conf
还是直接说正解吧 :开启你的cmd(命令列) 然后你需要以你nginx.exe所在路径的绝对路径,比如博主的路径在 D:Program Filesopenresty-1.13.6.2-win64
那么命令列就需要这样写
"d:Program Filesopenresty-1.13.6.2-win64nginx.exe" -c “d:Program Filesopenresty-1.13.6.2-win64confnginx.conf”

生成了nginx.pid文件:
里面只有一个PID号:
来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/4686/viewspace-2824001/ ,如需转载,请注明出处,否则将追究法律责任。