美文网首页
2-nginx常用命令

2-nginx常用命令

作者: Guoyubo | 来源:发表于2018-10-23 10:54 被阅读0次

查看nginx配置文件路径 nginx -t

查看nginx进程 ps -ef | grep nginx

检测配置文件规则
nginx -c /etc/nginx/default.d/websocket.conf

改完配置后需要reload nginx -s reload

启动、停止、重载命令
systemctl start nginx.service
systemctl stop nginx.service
systemctl reload nginx.service
systemctl status nginx.service

nginx错误解决办法

1 重启电脑后,执行nginx -s reload时报错 nginx: [error] open() "/var/run/nginx.pid" failed (2: No such file or directory)
执行nginx -c /etc/nginx/nginx.conf搞定

[root@localhost nginx]# nginx -s reload
nginx: [error] open() "/var/run/nginx.pid" failed (2: No such file or directory)
[root@localhost nginx]# nginx -c /etc/nginx/nginx.conf
[root@localhost nginx]# nginx -s reload
[root@localhost nginx]# 

如果执行nginx -c /etc/nginx/nginx.conf还报错

[root@instance-ww74cmok-2 nginx]# 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 [::]:80 failed (98: Address already in use)
nginx: [emerg] bind() to [::]:443 failed (98: Address already in use)
nginx: [emerg] bind() to 0.0.0.0:443 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 [::]:80 failed (98: Address already in use)
nginx: [emerg] bind() to [::]:443 failed (98: Address already in use)
nginx: [emerg] bind() to 0.0.0.0:443 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 [::]:80 failed (98: Address already in use)
nginx: [emerg] bind() to [::]:443 failed (98: Address already in use)
nginx: [emerg] bind() to 0.0.0.0:443 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 [::]:80 failed (98: Address already in use)
nginx: [emerg] bind() to [::]:443 failed (98: Address already in use)
nginx: [emerg] bind() to 0.0.0.0:443 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 [::]:80 failed (98: Address already in use)
nginx: [emerg] bind() to [::]:443 failed (98: Address already in use)
nginx: [emerg] bind() to 0.0.0.0:443 failed (98: Address already in use)
nginx: [emerg] still could not bind()

方法1:杀掉这个进程(慎重!!!,这个命令杀掉整个主机所有带有nginx的进程,包括docker容器启动的nginx镜像)
killall -9 nginx
systemctl start nginx.service

方法2:
-------------reload报错信息: nginx: [error] open() "/var/run/nginx.pid" failed (2: No such file or directory)
这个意思是在对应路径下找不到nginx的进程id,所以在/var/run目录下,新建一个nginx.pid文件,里面写上nginx的进程id即可(master process对应的那个id)


图片.png

代码

cd /var/run
touch nginx.pid
输入nginx的进程id(master process对应的那个id)
nginx -s reload

方法3:
找到所有的nginx进程,一个一个的杀掉,再重启nginx

相关文章

  • 2-nginx常用命令

    查看nginx配置文件路径 nginx -t 查看nginx进程 ps -ef | grep nginx 检测配置...

  • nginx采坑记

    采坑系列2-nginx 最近因为工作,需要配置nginx,初期nginx都运行的非常的顺利,在终端输入命令 ngi...

  • 其他

    Git常用命令mac常用命令Linux 常用命令汇总Linux 常用命令0Linux 常用命令1--ls命令

  • Docker

    目录 常用命令 常用命令

  • Linux CentOS基础知识和常用命令

    常用命令1 常用命令2 常用命令3 常用命令4 Linux 目录配置 1、根目录(/)根目录(/)所在分区应该越小...

  • Shell命令汇总

    1、一般常用命令 (1)Shell 常用命令总结 (2)Shell的18条常用命令整理 2、文件操作常用命令 (1...

  • Flutter - 常用命令

    Flutter 常用命令 Flutter 常用命令: Flutter 常用命令说明flutter列出所有的命令fl...

  • Linux常用命令

    Linux常用命令 查看系统信息常用命令 常用命令-关机或重启命令 命令前结构

  • Linux 常用命令汇总

    Linux 常用命令0Linux 常用命令1--ls命令 参考 Linux 常用命令汇总

  • 设置更改root密码、连接MySQL、MySQL常用命令

    设置更改root密码 连接MySQL 连接MySQL MySQL常用命令 MySQL常用命令MySQL常用命令 扩...

网友评论

      本文标题:2-nginx常用命令

      本文链接:https://www.haomeiwen.com/subject/ymvozftx.html