指尖上的记忆指尖上的记忆
首页
  • 基础
  • Laravel框架
  • Symfony框架
  • 基础
  • Gin框架
  • 基础
  • Spring框架
  • 命令
  • Nginx
  • Ai
  • Deploy
  • Docker
  • K8s
  • Micro
  • RabbitMQ
  • Mysql
  • PostgreSsql
  • Redis
  • MongoDb
  • Html
  • Js
  • 前端
  • 后端
  • Git
  • 知识扫盲
  • Golang
🌟 gitHub
首页
  • 基础
  • Laravel框架
  • Symfony框架
  • 基础
  • Gin框架
  • 基础
  • Spring框架
  • 命令
  • Nginx
  • Ai
  • Deploy
  • Docker
  • K8s
  • Micro
  • RabbitMQ
  • Mysql
  • PostgreSsql
  • Redis
  • MongoDb
  • Html
  • Js
  • 前端
  • 后端
  • Git
  • 知识扫盲
  • Golang
🌟 gitHub

关于ubuntu22自启动nginx服务失败的问题:

1>昨天安装了php8.3,但是过程中好像对apacahe2也自动做了操作
2>今天开机,发现nginx 服务启动不了,报: nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Unknown error),预感 80 端口被占用,于是按照下面的命令查询
k8s@HPDEV-31:~/code/sciforum-backend-v2$ sudo netstat -anp | grep 80 (记得加sudo/root权限,否则看不到最后面的进程信息)
tcp        0      0 127.0.0.1:59080         127.0.0.1:7890          ESTABLISHED 10711/chrome --type 
tcp        0      0 188.188.54.160:60980    114.42.229.233:443      ESTABLISHED 10576/clash-linux   
tcp        0      0 127.0.0.1:7890          127.0.0.1:59080         ESTABLISHED 10576/clash-linux   
tcp        0      0 188.188.54.160:44326    91.189.91.98:80         TIME_WAIT   -                   
tcp6       0      0 :::80                   :::*                    LISTEN      890/apache2         
tcp6       0      0 :::20080                :::*                    LISTEN      5607/java           
udp        0      0 0.0.0.0:631             0.0.0.0:*                           1802/cups-browsed  
...
...
果真发现 80 端口被占用,而且是 apache2 占用的,解决方法 要么 stop ,但是下次开机还是有这个问题,要么直接卸载,我这里 直接修改apacahe2使用的默认端口为8088
$ sudo vim /etc/apache2/ports.conf
# If you just change the port or add more ports here, you will likely also
# have to change the VirtualHost statement in
# /etc/apache2/sites-enabled/000-default.conf

Listen 8088

<IfModule ssl_module>
        Listen 443
</IfModule>

<IfModule mod_gnutls.c>
        Listen 443
</IfModule>

# vim: syntax=apache ts=4 sw=4 sts=4 sr noet

再重启 apache2:
$ sudo systemctl restart apache2

在执行:$ sudo netstat -anp | grep 80 现在80端口就没有被占用,同时 apache2占用了8088

3>重新启动nginx即可