重新安装 apache2 时出错 E:子进程 /usr/bin/dpkg 返回错误代码 (1)

重新安装 apache2 时出错 E:子进程 /usr/bin/dpkg 返回错误代码 (1)

我已经重新安装了 apache2,因为我的网站都是缓存,现在当我尝试安装它时,我得到:

root@vps139242:~# sudo apt-get install apache2
Reading package lists... Done
Building dependency tree
Reading state information... Done
apache2 is already the newest version.
0 upgraded, 0 newly installed, 0 to remove and 48 not upgraded.
1 not fully installed or removed.
After this operation, 0 B of additional disk space will be used.
Do you want to continue? [Y/n] y
Setting up apache2 (2.4.7-1ubuntu4.18) ...
ERROR: Config file dir.conf not properly enabled: /etc/apache2/mods-enabled/dir.conf is a real file, not touching it
dpkg: error processing package apache2 (--configure):
 subprocess installed post-installation script returned error exit status 1
Errors were encountered while processing:
 apache2
E: Sub-process /usr/bin/dpkg returned an error code (1)

我已尝试清除它并自动删除,但仍然没有任何效果,我不知道该怎么做,如能得到任何帮助我将不胜感激。

答案1

如果您确实想重置 apache2 配置,请执行以下步骤。

# Rename your Apache2 configuration folder (just in case of).
sudo mv /etc/apache2 /etc/apache2.old

# Look up for all Apache2 package installed
dpkg -l | grep apache2

# Remove all Apache packages, usualy the following
apt remove --purge apache2 apache2-data apache2-bin

# Finally reinstall your Apache2 server
apt install apache2

相关内容