centos6.5
,启动nginx服务,无法开启,导致网页打不开。把服务从起一下发现提示错误如下:
Starting nginx: 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服务卡死了,导致端口占用,出现此错误。
netstat -ntpl
[root@localhost /]# netstat -ntpl
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
tcp 0 0 0.0.0.0:58819 0.0.0.0:* LISTEN 2094/rpc.statd
tcp 0 0 127.0.0.1:3306 0.0.0.0:* LISTEN 5060/mysqld
tcp 0 0 0.0.0.0:21 0.0.0.0:* LISTEN 2294/vsftpd
tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 2271/sshd
tcp 0 0 127.0.0.1:631 0.0.0.0:* LISTEN 2121/cupsd
tcp 0 0 :::23527 :::* LISTEN 2094/rpc.statd
tcp 0 0 :::80 :::* LISTEN 2347/httpd
tcp 0 0 :::22 :::* LISTEN 2271/sshd
tcp 0 0 ::1:631 :::* LISTEN 2121/cupsd
kill 2347
[root@localhost /]# service nginx start
Starting nginx: [ OK ]
[root@localhost /]# ps -ef|grep nginx
root 2816 1 0 11:03 ? 00:00:00 nginx: master process /usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf
nobody 2817 2816 0 11:03 ? 00:00:00 nginx: worker process
nobody 2818 2816 0 11:03 ? 00:00:00 nginx: worker process
nobody 2819 2816 0 11:03 ? 00:00:00 nginx: worker process
nobody 2820 2816 0 11:03 ? 00:00:00 nginx: worker process
root 2823 2732 0 11:03 pts/0 00:00:00 grep nginx
nginx
启动提示
nginx
:
[emerg] b
in
d
(
)
to 0.0.0.0
:
80
failed
(
98
:
Address
already
in
use
)
nginx
启动报错
今天在centos7部署
nginx
,安装时一切顺利,但是在启动的时候却报错了,提示如下错误:
nginx
:
[emerg] b
in
d
(
)
to 0.0.0.0
:
80
failed
(
98
:
Address
already
in
use
)
nginx
:
[emerg] b
in
d
(
)
to 0.0.0.0
:
80
failed
(
98
:
Address
already
in
use
)
...
有时候我们开启或
重启
Nginx
时会报如下错误:
Nginx
[emerg]
:
b
in
d
(
)
to 0.0.0.0
:
80
failed
(
98
:
Address
already
in
use
)
原因是端口号80被其它程序占用了,那么就干掉这个程序吧:
root用户下:
f
use
r -k 80/tcp
非root用户下:
sudo f
use
r -k 80/tcp
然后开启或
重启
Nginx
即可。...
出现以下就说明成功关闭的80端口
[root@CLOUD711223430 ~]# sudo f
use
r -k 80/tcp
80/tcp
:
2010 2019 2020 2021 2022 2023 2024 2028 2029
出现...
b
in
d
(
)
to 0.0.0.0
:
1935
failed
(
98
:
Address
already
in
use
)
出现这种问题的原因是此1935端口已经被使用
常规方案:
lsof -i
:
1935查看哪一个进程占用了此端口,并使用指令kill -9 ***杀死此进程
此时问题已经得到解决,尝试再次启动
nginx
特殊情况:
经过以上操作,可以将
nginx
启动,但是也有特殊情况存在。
当我使用 ps -elf | grep
nginx
时,发现
nginx
只有一个root进程
当我尝试启动
今天在做LNMP的时候,启动
nginx
服务,无法开启,导致网页打不开。把服务从起一下发现提示错误如下:
Start
in
g
nginx
:
nginx
:
[emerg] b
in
d
(
)
to 0.0.0.0
:
80
failed
(
98
:
Address
already
in
use
)
nginx
:
[emerg] b
in
d
(
)
to 0.0.0.0
:
80
failed
(
98
...
启动
nginx
报错:[emerg]
:
b
in
d
(
)
to 0.0.0.0
:
80
failed
(
98
:
Address
already
in
use
)
原因是80端口被占用,不过最好在关闭80端口的时候先把防火墙关闭了
使用service iptables stat
us
查看防火墙的状态,如果是开启的状态就使用service iptables stop来关闭,之后关闭80端口
使用:sudo f
use
r -k 80/tcp 关闭80端口
然后重新启动:
启动完成后访问一下: