解决nginx无法访问的问题
- 解决方案-->恢复Nginx默认配置:
- cd /usr/local/nginx/conf
- rm nginx.conf
- cp nginx.conf.default nginx.conf
查看正在监听的所有Tcp端口与Nginx进程
netstat -lntup 查看所有tcp端口监听
ps -ef | grep nginx 查看nginx进程
netstat -unltp|grep nginx 查看nginx端口监听
恢复nginx.conf 默认配置文件,重新启动nginx
/usr/local/nginx/sbin/nginx -s reload
错误:
nginx: [error] open() "/usr/local/nginx/logs/nginx.pid" failed (2: No such file or directory)
解决步骤:
vim /usr/local/nginx/conf/nginx.conf 修改配置文件 /usr/local/nginx/sbin/nginx -s reload 重启nginx 报错 --> [error] open() "/usr/local/nginx/logs/nginx.pid" failed (2: No such file or directory) /usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf 重新指定配置文件 --> 验证:ps -ef | grep nginx 有了nginx的主目录 /usr/local/nginx/sbin/nginx -s reload 再次重启nginx 没有报错 再次测试访问nginx 成功