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

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

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

如下图:

[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列表

fuser -n tcp 443

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

[root@ZTE_OPLUS_1 nginx-1.12.0]# fuser -n tcp 443
443/tcp:              2330  2337  2338  2339  2340  2341

使用kill -9 PID删除进程

[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

然后启动即可

[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启动的时候提示端口被占用怎么解决办法的详细内容,更多请关注其它相关文章!