fedora26中解决nginx: [emerg] bind() to [::]:80 failed (98: Address already in use)

我在fedora26中启动nginx服务时遇到过以上问题

nginx: [warn] could not build optimal types_hash, you should increase either types_hash_max_size: 2048 or types_hash_bucket_size: 64; ignoring types_hash_bucket_size
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: [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: [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: [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: [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: [emerg] still could not bind()


然后使用netstat -lntp | grep 80查看端口占用情况时发现

tcp        0      0 0.0.0.0:80              0.0.0.0:*               LISTEN      3433/nginx: master  
tcp6       0      0 :::80                   :::*                    LISTEN      3433/nginx: master

原来是nginx先监听了ipv4的80端口之后又监听了ipv6的80端口,于是就重复占用了。于是杀死nginx进程

killall -9 nginx

然后重启nginx就可以了。

但是,发现每次启动均有如下的步骤,为了不必要的麻烦,我们可以修改nginx配置文件

vim /etc/nginx/nginx.conf

listen 80; 

listen [::]:80 default_server;

改为

listen 80; 

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

重启即可。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值