nginx: [emerg] bind() to 0.0.0.0:4433 failed (98: Address already in use)

提示:查询Nginx进程:ps -aux | grep nginx。

一、使用sudo systemctl restart nginx 重启Nginx服务出现以下错误:

[root@Zcgl_Web1_Dev nginx]# sudo systemctl restart nginx
Job for nginx.service failed because the control process exited with error code.
See "systemctl status nginx.service" and "journalctl -xe" for details.

使用 systemctl status nginx -l 查询时,看到错误:nginx: [emerg] bind() to 0.0.0.0:4433 failed (98: Address already in use)

二、解决办法:

sudo pkill -f nginx & wait $!
sudo systemctl start nginx

[root@Zcgl_Web1_Dev conf.d]# sudo pkill -f nginx & wait $!
[2] 1038336
[2]-  Done                    sudo pkill -f nginx
[root@Zcgl_Web1_Dev conf.d]# ps -aux | grep nginx
root     1038342  0.0  0.0  12136  1148 pts/2    S+   14:51   0:00 grep --color=auto nginx
[root@Zcgl_Web1_Dev conf.d]# sudo systemctl start nginx
[root@Zcgl_Web1_Dev conf.d]# ps -aux | grep nginx
root     1038353  0.0  0.0 121436  2360 ?        Ss   14:51   0:00 nginx: master process /usr/sbin/nginx
root     1038354  0.0  0.0 152040  8200 ?        S    14:51   0:00 nginx: worker process
root     1038355  0.0  0.0 152040  8200 ?        S    14:51   0:00 nginx: worker process
root     1038356  0.0  0.0 152040  8200 ?        S    14:51   0:00 nginx: worker process
root     1038357  0.0  0.0 152040  8200 ?        S    14:51   0:00 nginx: worker process
root     1038358  0.0  0.0 152040  8204 ?        S    14:51   0:00 nginx: worker process
root     1038359  0.0  0.0 152040  8204 ?        S    14:51   0:00 nginx: worker process
root     1038360  0.0  0.0 152040  8188 ?        S    14:51   0:00 nginx: worker process
root     1038361  0.0  0.0 152040  8180 ?        S    14:51   0:00 nginx: worker process
root     1038364  0.0  0.0  12136  1132 pts/2    S+   14:51   0:00 grep --color=auto nginx

三、Nginx常用命令

1、想要查看主机运行的Nginx版本,可以使用如下命令

# nginx -v
# nginx -V

2、检查Nginx配置是否有错

# nginx -t
#如果不仅想查看配置文件是否正确,还想知道Nginx都使用了哪些配置文件,只需要使用”-T”参数即可:
# nginx -T

3、启动Nginx服务

# systemctl start nginx #systemd
OR
# service nginx start   #sysvinit
OR
# start nginx #打开 nginx

4、设置Nginx服务开机自启动

# systemctl enable nginx #systemd
OR
# service nginx enable   #sysvinit

5、重新启动Nginx

# systemctl restart nginx #systemd
OR
# service nginx restart   #sysvinit
OR
# nginx -s reopen #重启Nginx
OR
# nginx -c filename #设置配置文件(默认是:/etc/nginx/nginx.conf),
#例如sudo nginx -c /etc/nginx/nginx.conf 或 
sudo nginx -t -c /etc/nginx/nginx.conf(-t可以检查验证nginx配置文件是否正确) 或 
 /usr/sbin/nginx -t -c /etc/nginx/nginx.conf

6、查看Nginx运行状态

# systemctl status nginx #systemd
OR
# service nginx status   #sysvinit

7、重新载入配置文件

# systemctl reload nginx #systemd
OR
# service nginx reload   #sysvinit
OR
# sudo nginx -s reload #重新加载Nginx配置文件,然后以优雅的方式重启Nginx

8、停止Nginx服务

# systemctl stop nginx #systemd
OR
# service nginx stop   #sysvinit
OR
# nginx -s stop #强制停止Nginx服务
OR
# nginx -s quit #优雅地停止Nginx服务(即处理完所有请求后再停止服务)

9、查看Nginx的帮助文件

# nginx -h

  • 5
    点赞
  • 13
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值