nginx启动的时候提示端口被占用怎么解决办法


本文摘自PHP中文网,作者(*-*)浩,侵删。

有时候,可能stop的时候关闭不到一些进行所占的端口,这个时候启动也会报端口被占用。

如下图:

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

[root@ZTE_OPLUS_1 nginx-1.12.0]# sh run.sh

===============================================================================

HOME=/oplusapp/PMSCMDB/ums-server/utils/nginx/nginx-1.12.0

_NGINXCMD=/oplusapp/PMSCMDB/ums-server/utils/nginx/nginx-1.12.0/sbin/nginx

===============================================================================

/oplusapp/PMSCMDB/ums-server/utils/nginx/nginx-1.12.0

@WORK_DIR@ /oplusapp/PMSCMDB/ums-server/utils/nginx/nginx-1.12.0

@C_CMD@

nginx: [emerg] bind() to 0.0.0.0:443 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 [::]: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 [::]: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 [::]: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 [::]:443 failed (98: Address already in use)

nginx: [emerg] still could not bind()

上图报443端口被占用:使用fuser -n tcp 命令查看占用该端口的PID列表

1

fuser -n tcp 443

看看是什么被占用,也可以用netstat -ntpl看看谁占用,然后KILL掉占用的PID

1

2

[root@ZTE_OPLUS_1 nginx-1.12.0]# fuser -n tcp 443

443/tcp:              2330  2337  2338  2339  2340  2341

使用kill -9 PID删除进程

1

2

3

4

5

[root@ZTE_OPLUS_1 nginx-1.12.0]# kill -9 2330

[root@ZTE_OPLUS_1 nginx-1.12.0]# kill -9 2337

[root@ZTE_OPLUS_1 nginx-1.12.0]# kill -9 2338

[root@ZTE_OPLUS_1 nginx-1.12.0]# kill -9 2339

[root@ZTE_OPLUS_1 nginx-1.12.0]# kill -9 2340

然后启动即可

1

2

3

4

5

6

7

8

[root@ZTE_OPLUS_1 nginx-1.12.0]# sh run.sh

===============================================================================

HOME=/oplusapp/PMSCMDB/ums-server/utils/nginx/nginx-1.12.0

_NGINXCMD=/oplusapp/PMSCMDB/ums-server/utils/nginx/nginx-1.12.0/sbin/nginx

===============================================================================

/oplusapp/PMSCMDB/ums-server/utils/nginx/nginx-1.12.0

@WORK_DIR@ /oplusapp/PMSCMDB/ums-server/utils/nginx/nginx-1.12.0

@C_CMD@

更多Nginx相关技术文章,请访问Nginx使用教程栏目进行学习!

阅读剩余部分

相关阅读 >>

nginx的基本特点有哪些

nginx为什么会出现403

nginx_lua能做什么

nginx如何隐藏index.php

nginx如何实现动静分离

centos7环境下如何安装nginx

apache和nginx性能差很多吗

nginx与tomcat区别有哪些?

如何在linux中使用nginx设置负载平衡

centos下nginx无法访问怎么办

更多相关阅读请进入《nginx》频道 >>



打赏

取消

感谢您的支持,我会继续努力的!

扫码支持
扫码打赏,您说多少就多少

打开支付宝扫一扫,即可进行扫码打赏哦

分享从这里开始,精彩与您同在

评论

管理员已关闭评论功能...