问题描述
1
nginx启动或者重启失败,报错nginx: [error] open() "/usr/local/var/run/nginx.pid" failed (2: No such file or directory)
方案一
- 执行命令 :open /usr/local/etc/nginx 打开nginx安装目录 nginx安装目录默认位置有:
- /etc/nginx/nginx.conf,
- /usr/local/etc/nginx/nginx.conf 或 /usr/local/nginx/conf/nginx.conf
![]()
- 放开注释,改为:
pid /usr/local/etc/nginx/logs/nginx.pid;![]()
- 执行命令:
mkdir /usr/local/etc/nginx/logs在/usr/local/etc/nginx目录下创建目录logs - 启动nginx
方案二
找到你的nginx.conf的文件夹目录,然后运行 nginx -c /usr/local/etc/nginx/nginx.conf命令 ,再运行(sudo)nginx -s reload 重启nginx就可以了

