zoukankan      html  css  js  c++  java
  • 启动nginx 80端口被占用:tcp 0 0 127.0.0.1:80 127.0.0.1:34932 TIME_WAIT

    1.启动nginx命令
    ./sbin/nginx

    2.提示80端口被占用

    nginx: [emerg] bind() to 0.0.0.0: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 0.0.0.0: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 0.0.0.0:80 failed (98: Address already in use)
    nginx: [emerg] still could not bind()

    3.执行netstat -antp查看谁占用了80端口

    Proto  Recv-Q  Send-Q  Local Address           Foreign Address         State               PID/Program name   

    tcp        0           0           127.0.0.1:80               127.0.0.1:34932         TIME_WAIT      -   

    4.通过调整内核参数解决

    vi /etc/sysctl.conf


    编辑文件,加入以下内容:
    net.ipv4.tcp_syncookies = 1
    net.ipv4.tcp_tw_reuse = 1
    net.ipv4.tcp_tw_recycle = 1
    net.ipv4.tcp_fin_timeout = 30
     
    然后执行/sbin/sysctl -p让参数生效。
    5.关闭窗口断开连接,重新打开

    80端口仍被占用

    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           1402/nginx: master

    6.kill占用80端口的进程

    7./sbin/nginx

    此时,启动nginx成功

    执行命令 kill -9 1402
    参考资料:https://blog.csdn.net/gzh0222/article/details/8491178

  • 相关阅读:
    Mac 应用程序中的App在Launchpad中不显示
    oh-my-zsh的安装
    用Lambda 表达式实现Runnable
    用Lambda 表达式实现Runnable
    记录Nacos配置Mysql数据库连接失败解决
    Mac最好用的终端iTerm2安装及配置
    MySQL安装设置密码策略问题
    构建微服务模块流程
    dependencies与dependencyManagement的区别
    winSocket 2 简单的可持续的socket
  • 原文地址:https://www.cnblogs.com/songsongblue/p/11788649.html
Copyright © 2011-2022 走看看