首次启动nginx报错 nginx: [error] open() “/var/run/nginx.pid” failed (2: No such file or directory)
背景
-
阿里云服务器CentOS 7, 比较新 干净!
-
严格按照官网安装Nginx, 但首次启动报错 nginx: [error] open() “/var/run/nginx.pid” failed (2: No such file or directory)
解决
-
修改核心配置文件中pid的值为: /etc/nginx/logs/nginx.pid
vim /etc/nginx/nginx.conf;要分号结尾, 否则报错信息也能指向这个错误!
去/etc/nginx/中新建logs文件夹
-
进入conf.d, 并执行命令
cd /etc/nginx/conf.d/usr/sbin/nginx -c /etc/nginx/nginx.conf但是会报错
nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use) nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use) nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use) nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use) nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use) nginx: [emerg] still could not bind() -
强杀80端口
sudo fuser -k 80/tcp再次运行3中-c命令, 解决!
小结
-
https://www.jianshu.com/p/efa0968eb581资料对我帮助很大, 但是需要注意要认真适配自己具体的情况!
-
误打误撞, 拼拼凑凑, 必须记下来, 因为能感觉到下次还能顺利解决的概率太低!!!
1333




被折叠的 条评论
为什么被折叠?



