nginx启动失败nginx: [emerg] bind() to 0.0.0.0:7001 failed (98: Address already in use)

./nginx 启动nginx,在启动时报错端口被占用

[root@localhost sbin]# ./nginx
nginx: [emerg] bind() to 0.0.0.0:7001 failed (98: Address already in use)
nginx: [emerg] bind() to 0.0.0.0:7001 failed (98: Address already in use)
nginx: [emerg] bind() to 0.0.0.0:7001 failed (98: Address already in use)
nginx: [emerg] bind() to 0.0.0.0:7001 failed (98: Address already in use)
nginx: [emerg] bind() to 0.0.0.0:7001 failed (98: Address already in use)

lsof -i:7001,查看被占用的进程

[root@localhost sbin]# lsof -i:7001
COMMAND    PID USER   FD   TYPE DEVICE SIZE/OFF NODE NAME
java    104324 root 1514u  IPv6 822256      0t0  TCP localhost.localdomain:afs3-callback (LISTEN)
java    104324 root 1515u  IPv6 811847      0t0  TCP localhost:afs3-callback (LISTEN)
java    104324 root 1516u  IPv6 810961      0t0  TCP localhost:afs3-callback (LISTEN)
java    104324 root 1517u  IPv6 810962      0t0  TCP localhost.localdomain:afs3-callback (LISTEN)
java    104324 root 1518u  IPv6 822257      0t0  TCP localhost.localdomain:afs3-callback (LISTEN)

解决办法:

方法一:如果涉及的进程不需要则将它杀死,杀死后./nginx重新启动nginx,80端口同理

[root@localhost nginx]# kill -9 7001

[root@localhost sbin]# ./nginx

方法二:涉及进程需要,则修改端口

进入sbin目录下修改nginx.conf文件

修改前:

server {
        listen      7001;
        server_name  localhost;

修改后:

listen端口改为其他端口

server {
        listen      17001;
        server_name  localhost;

 ./nginx 重新启动nginx

[root@localhost sbin]# ./nginx

ps -ef | grep nginx查看进程:已启动

[root@localhost sbin]# ps -ef | grep nginx
root     106562      1  0 23:19 ?        00:00:00 nginx: master process ./nginx
nobody   106563 106562  0 23:19 ?        00:00:00 nginx: worker process
nobody   106564 106562  0 23:19 ?        00:00:00 nginx: worker process
root     106568 106205  0 23:19 pts/0    00:00:00 grep --color=auto nginx

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值