即使重启后更新单元文件,Apache2 也无法启动

即使重启后更新单元文件,Apache2 也无法启动

问题:服务器重启后,apache2 不会自动启动(必须手动 ssh 并通过 systemctl 启动,启动没有任何问题)

错误信息:

Feb 08 05:53:46 domain1_test.com systemd[1]: Starting The Apache HTTP Server...
Feb 08 05:53:47 domain1_test.com apachectl[834]: (99)Cannot assign requested address: AH00072: make_sock: could not bind to address [xxxx:xxxx::xxxx:xxxx:xxxx:xxxx]:80
Feb 08 05:53:47 domain1_test.com apachectl[834]: no listening sockets available, shutting down
Feb 08 05:53:47 domain1_test.com apachectl[834]: AH00015: Unable to open logs
Feb 08 05:53:47 domain1_test.com apachectl[809]: Action 'start' failed.
Feb 08 05:53:47 domain1_test.com apachectl[809]: The Apache error log may have more information.
Feb 08 05:53:47 domain1_test.com systemd[1]: apache2.service: Control process exited, code=exited, status=1/FAILURE
Feb 08 05:53:47 domain1_test.com systemd[1]: apache2.service: Failed with result 'exit-code'.

当前 Apache 设置:

# port.conf
Listen xxx.xxx.xx.xx:80
Listen xxx.xxx.xx.xx:443

Listen [xxxx:xxxx::xxxx:xxxx:xxxx:xxxx]:80
Listen [xxxx:xxxx::xxxx:xxxx:xxxx:xxxx]:443

---

# domain1_VirtualHosts.conf
<VirtualHost xxx.xxx.xx.xx:80 [xxxx:xxxx::xxxx:xxxx:xxxx:xxxx]:80>
....
<VirtualHost xxx.xxx.xx.xx:443 [xxxx:xxxx::xxxx:xxxx:xxxx:xxxx]:443>

我已经测试过通过目标和需求在 apache2 单元文件中添加网络依赖项,但在重启后检查 apache2 状态时仍然出现无法绑定套接字错误

[Unit]
Description=The Apache HTTP Server
After=network.target network-online.target remote-fs.target nss-lookup.target
Wants=network-online.target
Documentation=https://httpd.apache.org/docs/2.4/

[Service]
Type=forking
Environment=APACHE_STARTED_BY_SYSTEMD=true
ExecStart=/usr/sbin/apachectl start
ExecStop=/usr/sbin/apachectl stop
ExecReload=/usr/sbin/apachectl graceful
PrivateTmp=true
Restart=on-abort

[Install]
WantedBy=multi-user.target

感谢任何有关此事的意见

环境:Ubuntu 20.04.2 LTS + Apache/2.4.41

相关内容