nginx reload 报错,彻底杀死nginx进程

1. nginx -s reload 报错

报错现象
[root@localhost ~]# nginx -s reload
nginx: [error] invalid PID number "" in "/run/nginx.pid"

解决方案
[root@localhost run]# nginx -c /etc/nginx/nginx.conf
[root@localhost run]# 

执行该命令是 指定 nginx 的配置文件, 如上,执行完后没有报错 表示 nginx 正常运行了

2. nginx -c 报错

现象
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()

顺便看看 nginx -c 指令的作用, 如下可看

[root@localhost run]# nginx -h
nginx version: nginx/1.16.1
Usage: nginx [-?hvVtTq] [-s signal] [-c filename] [-p prefix] [-g directives]

Options:
  -?,-h         : this help
  -v            : show version and exit
  -V            : show version and configure options then exit
  -t            : test configuration and exit
  -T            : test configuration, dump it and exit
  -q            : suppress non-error messages during configuration testing
  -s signal     : send signal to a master process: stop, quit, reopen, reload
  -p prefix     : set prefix path (default: /usr/share/nginx/)
  -c filename   : set configuration file (default: /etc/nginx/nginx.conf)
  -g directives : set global directives out of configuration file

-c filename : set configuration file (default: /etc/nginx/nginx.conf) 用来设置配置文件 的

解决方案

杀死 nginx 程序即可重启nginx

  1. 通过 netstat 指令查询 出 80 端口的 占用程序

注意不要 直接 kill 3306 , 很多人这样干了, 杀不死

[root@localhost run]# netstat -ntlp | grep 80
tcp        0      0 0.0.0.0:80              0.0.0.0:*               LISTEN      3036/nginx: master  
tcp6       0      0 :::80                   :::*                    LISTEN      3036/nginx: master  
  1. 通过 ps 查出占用 程序的 端口号
[root@localhost run]# ps -ef | grep nginx
root       3036      1  0 15:01 ?        00:00:00 nginx: master process nginx -c /etc/nginx/nginx.conf
nginx      3037   3036  0 15:01 ?        00:00:00 nginx: worker process
nginx      3038   3036  0 15:01 ?        00:00:00 nginx: worker process
nginx      3039   3036  0 15:01 ?        00:00:00 nginx: worker process
nginx      3040   3036  0 15:01 ?        00:00:00 nginx: worker process
root       3074   2999  0 15:24 pts/0    00:00:00 grep --color=auto nginx

直接 grep nginx 程序 可以发现 占用端口 3036,3037,3038,3039,3040 , 全部 kill 掉即可

  1. kill 占用程序的 端口号
kill -9 3036
kill -9 ....

windows 杀进程方法

windows杀进程

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值