nginx 錯誤,沒有打開

nginx 錯誤,沒有打開

請我的伺服器中的 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)

請問如何讓它開始

答案1

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;

答案2

只是我刪除了這一行

監聽[::]:80 default_server ipv6only=on;

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

答案3

感謝您提到 ipv6。

就我而言,我在 nginxconf 中有一行

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可以解決此問題。

相關內容