nginx:[emerg] bind()到[::]:80失败(98:地址已经在使用中)

时间:2013-08-02 09:12:04

标签: php nginx webserver

大家好,我们试图使用nginx和php5-fpm来配置我的网络服务器。

当我尝试重新启动/启动/停止nginx时,它会显示:

Restarting nginx: 
nginx: [emerg] bind() to [::]:80 failed (98: Address already in use)
nginx: [emerg] bind() to [::]:80 failed (98: Address already in use)
nginx: [emerg] bind() to [::]:80 failed (98: Address already in use)
nginx: [emerg] bind() to [::]:80 failed (98: Address already in use)
nginx: [emerg] bind() to [::]:80 failed (98: Address already in use)
nginx: [emerg] still could not bind()
nginx.

日志显示同样的事情。

我的网站配置:

server {

            listen   80;

            listen   [::]:80;

            root /home/marker/Projects/stereoshoots/www;

            server_name stereoshoots.local;







            location / {

                    autoindex  on;

    #                try_files $uri $uri/ @rewrite;

                    try_files $uri $uri/ /index.php;

            }

    #        location @rewrite {

    #                rewrite ^/(.*)$ /index.php?q=$1;

    #        }

            location ~* \.(jpg|jpeg|gif|css|png|js|ico|xml|txt)$ {

                access_log        off;

                expires           30d;

            }

            location = /favicon.ico {

                    return 204;

                    access_log     off;

                    log_not_found  off;

            }

            location ~ \.php$ {

                    fastcgi_pass unix:/var/run/php5-fpm.sock;

                    fastcgi_index index.php;

                    include fastcgi_params;

            }

            location ~ /\.ht {

                    deny all;

            }

    }

我在终端中编写的命令列表,同时安装了nginx + php5-fpm

1.sudo apt-get install nginx
2.sudo apt-get install php5-cli php5-common php5-mysql php5-suhosin php5-gd php5-fpm php5-cgi php5-fpm php-pear php5-mcrypt
3.sudo service nginx stop
4.sudo service php5-fpm stop
5.sudo gedit /etc/php5/fpm/php.ini
cgi.fix_pathinfo = 0;
6.sudo gedit /etc/php5/fpm/pool.d/www.conf
security.limit_extensions = .php .php3 .php4 .php5
listen = /var/run/php5-fpm.sock

2 个答案:

答案 0 :(得分:1)

如果您想同时支持ipv4和ipv6(您应该,因为像Apple这样的公司已经转移到仅支持ipv6的网络,2016.8,截至目前),您需要删除listen 80并仅保留以下内容你的nginx配置,

listen [::]:80

也可能是这个,

listen [::]:443

请记住,您需要将配置中的所有listen 80listen 443更改为listen [::]:80listen [::]:443。不要忘记/etc/nginx/sites-available/default

中的配置

答案 1 :(得分:0)

Skype默认使用端口80,443,它们完全是http和https端口。尝试关闭Skype并重新启动nginx。

如果您使用Skype的“桌面版”,则可以tools>options>advanced>connections > untick use port 80 and 443 as alternatives的方式更改此设置。

如果您使用的是win8应用程序,唯一的选择似乎是完全关闭Skype或完全删除它。

有人必须确认win8应用程序,我使用linux。