Ubuntu系统Apache2安装后无法启动,报错apache2.service: Control process exited, code=exited status=1...

准备安装apache服务的时候,出现了服务启动失败的情况,仔细查看问题原因找到了解决办法。

一、问题:

安装完apache服务器后,自动启动时报错。截取报错原因为:

May 09 14:54:30 cloudmarvin apachectl[24982]: AH00558: apache2: Could not reliably determine the server's fully qualified domain name, us                              
ing xxx.xxx.xxx.xxx Set the 'ServerName' directive globally to suppress this message
May 09 14:54:30 cloudmarvin apachectl[24982]: (98)Address already in use: AH00072: make_sock: could not bind to address [::]:80
May 09 14:54:30 cloudmarvin apachectl[24982]: (98)Address already in use: AH00072: make_sock: could not bind to address 0.0.0.0:80
May 09 14:54:30 cloudmarvin apachectl[24982]: no listening sockets available, shutting down

2、原因及解决办法:

通过错误代码可以了解到,apache服务默认启用的80端口被占用了,导致的无法启用。一种方案是找到占用端口的服务并杀掉进程,另一种方案是调整apache默认端口,我们分别使用这两种方式解决下。

1)找到进程并kill掉,然后重启Apache服务

   netstat 命令参数含义:

  -l:仅显示监听套接字(所谓套接字就是使应用程序能够读写与收发通讯协议(protocol)与资料的程序)

  -n:不进行DNS轮询(可以加速操作)

  -p:显示进程

  netstat -lnp 常用来查看监听端口(查看网络连接情况)

杀掉进程:

kill -9 16665

重启apache服务:

sudo service apache2 start

2)修改默认端口

vi /etc/apache2/ports.conf

编辑配置文件,修改默认端口号80为81(根据个人情况设置)后保存

重启apache服务

sudo service apache2 start

我用的是阿里云服务器,所以想要设置外网可访问,还需要进入阿里云平台,在安全组规则中添加该端口的访问权限,设置好后即可外网访问。

root@iZf8z2slk85lm15so7cuorZ:~# nginx -s reload 2025/03/10 14:49:22 [notice] 201951#201951: signal process started 2025/03/10 14:49:22 [error] 201951#201951: open() "/run/nginx.pid" failed (2: No such file or directory) root@iZf8z2slk85lm15so7cuorZ:~# systemctl status nginx.service × nginx.service - A high performance web server and a reverse proxy server Loaded: loaded (/usr/lib/systemd/system/nginx.service; enabled; preset: enabled) Active: failed (Result: exit-code) since Mon 2025-03-10 14:48:30 CST; 1min 21s ago Docs: man:nginx(8) Process: 201838 ExecStartPre=/usr/sbin/nginx -t -q -g daemon on; master_process on; (code=exited, status=0/SUCCESS) Process: 201839 ExecStart=/usr/sbin/nginx -g daemon on; master_process on; (code=exited, status=1/FAILURE) CPU: 20ms Mar 10 14:48:28 iZf8z2slk85lm15so7cuorZ nginx[201839]: nginx: [emerg] bind() to 0.0.0.0:88 failed (98: Address already in use) Mar 10 14:48:28 iZf8z2slk85lm15so7cuorZ nginx[201839]: nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use) Mar 10 14:48:29 iZf8z2slk85lm15so7cuorZ nginx[201839]: nginx: [emerg] bind() to 0.0.0.0:88 failed (98: Address already in use) Mar 10 14:48:29 iZf8z2slk85lm15so7cuorZ nginx[201839]: nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use) Mar 10 14:48:29 iZf8z2slk85lm15so7cuorZ nginx[201839]: nginx: [emerg] bind() to 0.0.0.0:88 failed (98: Address already in use) Mar 10 14:48:29 iZf8z2slk85lm15so7cuorZ nginx[201839]: nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use) Mar 10 14:48:30 iZf8z2slk85lm15so7cuorZ nginx[201839]: nginx: [emerg] still could not bind() Mar 10 14:48:30 iZf8z2slk85lm15so7cuorZ systemd[1]: nginx.service: Control process exited, code=exited, status=1/FAILURE Mar 10 14:48:30 iZf8z2slk85lm15so7cuorZ systemd[1]: nginx.service: Failed with result 'exit-code'. Mar 10 14:48:30 iZf8z2slk85lm15so7cuorZ systemd[1]: Failed to start nginx.service - A high performance web server and
03-13
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值