Nginx erreur它没有打开


9

请我服务器上的nginx确实启动了,请关注我

root@s45-****:/home/arabico# nmap 45.****

PORT   STATE SERVICE
22/tcp open  ssh
5/tcp open  smtp
80/tcp open  http

Nmap done: 1 IP address (1 host up) scanned in 0.06 seconds
root@s45-****:/home/arabico# sudo service apache2 stop
 * Stopping web server apache2                                                      * 
root@s45-****:/home/arabico# nmap 45.****

Starting Nmap 6.40 ( http://nmap.org ) at 2015-06-05 19:33 MST

PORT   STATE SERVICE
22/tcp open  ssh
25/tcp open  smtp

Nmap done: 1 IP address (1 host up) scanned in 0.06 seconds
root@s45-***:/home/arabico# sudo service nginx restart
 * Restarting nginx nginx          
          [fail] 


root@s45-***:/home/arabico# nginx -t
nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: [emerg] socket() [::]:80 failed (97: Address family not supported by protocol)
nginx: configuration file /etc/nginx/nginx.conf test failed

root@s45***:/home/arabico# sudo nginx
nginx: [emerg] socket() [::]:80 failed (97: Address family not supported by protocol)

如何让它开始


你到底在问什么
spacegeek224

它如何工作,如何使其启动
user14576 2015年

Answers:


11
nginx: [emerg] socket() [::]:80 failed (97: Address family not supported by protocol)

根据错误消息,您的服务器上似乎已禁用了ipv6。编辑nginx默认服务器配置,并将其更改为仅在ipv4上侦听或启用ipv6。

listen 80 default_server;
# comment to disable ipv6
# listen [::]:80 default_server;

7

我只是删除了这一行

听[::]:80 default_server ipv6only = on;

/ etc / nginx / sites-available / default,它可以工作:D


我做了同样的事,它也可以。但是谁能解释为什么默认配置不起作用?
Loredra L

0

感谢您提及ipv6。

就我而言,我在nginx conf中有一行

proxy_pass http://localhost:3028/;

当我在内核配置中禁用ipv6时,发生了问题。重新启用ipv6可以解决问题,但这不是我想要的。

解决的办法是删除

::1     localhost ip6-localhost ip6-loopback
ff02::1     ip6-allnodes
ff02::2     ip6-allrouters

/etc/hosts

因此,本地主机将始终遵循默认的ipv4目标,即127.0.0.1

仅删除该::1行就足够了。由于ipv6已完全禁用,因此我将全部删除。

localhostnginx配置更改为127.0.0.1也可以解决此问题。

By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.