我正在尝试在新安装的 Ubuntu 20.04 上安装 apache。
我跑了:
sudo apt-get install apache2
但我收到以下错误:
AH00558: apache2: Could not reliably determine the server's fully qualified domain name,
using 127.0.1.1. Set the 'ServerName' directive globally to suppress this message
以下是屏幕截图:
并以文本形式输出:
Created symlink /etc/systemd/system/multi-user.target.wants/apache2.service → /lib/systemd/system/apache2.service.
Created symlink /etc/systemd/system/multi-user.target.wants/apache-htcacheclean.service → /lib/systemd/system/apache-htcacheclean.service.
Job for apache2.service failed because the control process exited with error code.
See "systemctl status apache2.service" and "journalctl -xe" for details.
invoke-rc.d: initscript apache2, action "start" failed.
● apache2.service - The Apache HTTP Server
Loaded: loaded (/lib/systemd/system/apache2.service; enabled; vendor preset: enabled)
Active: failed (Result: exit-code) since Thu 2021-12-30 20:23:49 CET; 17ms ago
Docs: https://httpd.apache.org/docs/2.4/
Process: 31745 ExecStart=/usr/sbin/apachectl start (code=exited, status=1/FAILURE)
dic 30 20:23:49 xxx-laptop apachectl[31755]: AH00558: apache2: Could not reliably determine the server's fully qualified domain name, using 127.0.1.1. Set the 'ServerName' directive globally to suppress this message
dic 30 20:23:49 xxx-laptop apachectl[31755]: (98)Address already in use: AH00072: make_sock: could not bind to address [::]:80
dic 30 20:23:49 xxx-laptop apachectl[31755]: (98)Address already in use: AH00072: make_sock: could not bind to address 0.0.0.0:80
dic 30 20:23:49 xxx-laptop apachectl[31755]: no listening sockets available, shutting down
dic 30 20:23:49 xxx-laptop apachectl[31755]: AH00015: Unable to open logs
dic 30 20:23:49 xxx-laptop apachectl[31745]: Action 'start' failed.
dic 30 20:23:49 xxx-laptop apachectl[31745]: The Apache error log may have more information.
dic 30 20:23:49 xxx-laptop systemd[1]: apache2.service: Control process exited, code=exited, status=1/FAILURE
dic 30 20:23:49 xxx-laptop systemd[1]: apache2.service: Failed with result 'exit-code'.
dic 30 20:23:49 xxx-laptop systemd[1]: Failed to start The Apache HTTP Server.
Processing triggers for ufw (0.36-6ubuntu1) ...
Processing triggers for systemd (245.4-4ubuntu3.13) ...
Processing triggers for man-db (2.9.1-1) ...
Processing triggers for libc-bin (2.31-0ubuntu9.2) ...
任何想法?
答案1
问题似乎不在于您描述的错误。更可能是由于端口 80 已被使用而导致的。
dic 30 20:23:49 xxx-laptop apachectl[31755]: (98)Address already in use: AH00072: make_sock: could not bind to address [::]:80
dic 30 20:23:49 xxx-laptop apachectl[31755]: (98)Address already in use: AH00072: make_sock: could not bind to address 0.0.0.0:80
检查什么使用了端口并将其停止,这应该有帮助。
要检查使用端口的内容,您可以使用netstat -tulpn | grep 80
示例输出 -
root@server:~# netstat -tulpn | grep 80
tcp6 0 0 :::80 :::* LISTEN 761/apache2
所以就我而言,该端口已被 apache 占用。