![无法重新安装 apache2 - Ubuntu 20.04 服务器](https://linux22.com/image/1024421/%E6%97%A0%E6%B3%95%E9%87%8D%E6%96%B0%E5%AE%89%E8%A3%85%20apache2%20-%20Ubuntu%2020.04%20%E6%9C%8D%E5%8A%A1%E5%99%A8.png)
我已经用以下命令卸载了 apache2:
sudo service apache2 stop
sudo apt-get purge apache2 apache2-utils apache2.2-bin apache2-common
sudo apt-get autoremove --purge
我发现了此命令剩下的内容:
whereis apache2
然后删除所有这些文件和目录。
现在,当我尝试安装 apache2 并运行它时出现错误:
sudo apt install apache2
sudo systemctl start apache2
Job for apache2.service failed because the control process exited with error code.
See "systemctl status apache2.service" and "journalctl -xe" for details.
sudo systemctl status apache2.service
● apache2.service - The Apache HTTP Server
Loaded: loaded (/lib/systemd/system/apache2.service; enabled; vendor preset: enabled)
Active: failed (Result: exit-code) since Sun 2021-10-03 10:34:31 UTC; 2min 38s ago
Docs: https://httpd.apache.org/docs/2.4/
Process: 12449 ExecStart=/usr/sbin/apachectl start (code=exited, status=203/EXEC)
Oct 03 10:34:31 machina systemd[1]: Starting The Apache HTTP Server...
Oct 03 10:34:31 machina systemd[12449]: apache2.service: Failed to execute command: No such file or directory
Oct 03 10:34:31 machina systemd[12449]: apache2.service: Failed at step EXEC spawning /usr/sbin/apachectl: No such file or directory
Oct 03 10:34:31 machina systemd[1]: apache2.service: Control process exited, code=exited, status=203/EXEC
Oct 03 10:34:31 machina systemd[1]: apache2.service: Failed with result 'exit-code'.
Oct 03 10:34:31 machina systemd[1]: Failed to start The Apache HTTP Server.
apache2 -v
Server version: Apache/2.4.41 (Ubuntu)
Server built: 2021-09-28T11:00:45
apache2ctl -S
Command 'apache2ctl' not found, but can be installed with:
apt install apache2
Please ask your administrator.
然后我这样做:
sudo apt install apache2
但我遇到了同样的错误。
尝试过这个:
sudo apt-get --reinstall install apache2-bin
同样的错误。
答案1
这就是我解决这个问题的方法。
首先,您需要停止 Apache2 服务并将其完全卸载:
sudo service apache2 stop
sudo apt-get purge apache2 apache2-utils apache2.2-bin apache2-common
sudo apt-get autoremove --purge
在那之后重启你的机器然后才再次安装 Apache2:
sudo apt install apache2