【发布时间】:2020-01-15 01:46:42
【问题描述】:
我无法启动 nginx。每次我在命令行中输入“nginx”时,我都会看到:
nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)
nginx: [emerg] bind() to [::]:80 failed (98: Address already in use)
打印了几次
我使用的是 ubuntu 14.04
我已经累了:
-
将本地地址更改为80以外的其他东西,例如70,但是错误是
nginx: [emerg] bind() to 0.0.0.0:70 failed (98: Address already in use)
nginx: [emerg] bind() to [::]:70 failed (98: Address already in use)
;
- 定影器-k 80/tcp:
我的 netstat -tulpn 显示如下:
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:80 0.0.0.0:* LISTEN 18170/nginx
tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 3156/sshd
tcp6 0 0 :::80 :::* LISTEN 18170/nginx
tcp6 0 0 :::22 :::* LISTEN 3156/sshd
之后 定影器 -k 80/tcp 我得到: 80/tcp: 18170 18171 netstat 显示:
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 3156/sshd
tcp6 0 0 :::22 :::* LISTEN 3156/sshd
我尝试重启 nginx
service nginx stop
service nginx start
但是当我再次输入 nginx 时,我看到了
nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)
nginx: [emerg] bind() to [::]:80 failed (98: Address already in use)
再一次,几次。
nginx -t
显示:
nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful
另外,我没有安装 apache。
我的 /etc/nginx/conf.d/[站点名称]conf:
server {
listen 80;
listen [::]:80 ipv6only=on;
server_name [sitename] www.[sitename];
root /var/www/[sitename];
index index.html;
gzip on;
gzip_comp_level 3;
gzip_types text/plain text/css application/javascript image/*;
}
我试着跑了:
grep -r listen /etc/nginx/*
检查listen是否没有设置两次,但只显示:
/etc/nginx/conf.d/[sitename].conf: listen 80;
/etc/nginx/conf.d/[sitename].conf: listen [::]:80 ipv6only=on;
/etc/nginx/nginx.conf:# listen localhost:110;
/etc/nginx/nginx.conf:# listen localhost:143;
我很困惑,因为 netstat 显示 nginx 实际上在那个端口上,但我仍然收到错误消息并且我的网页无法访问(404 未找到,nginx)
我还能尝试什么?
【问题讨论】:
-
为什么要手动运行nginx?它作为服务运行。
-
我正在通过 linode ssh 进行操作,并且由于他们的指示,我已经完成了所有操作 - 我不知道如何以任何其他方式进行操作;尤其是我的网站没有运行。
标签: nginx