在 CentOS 中,默认并不叫 apache2,而是叫 httpd(Apache HTTP Server)。下面分情况说明如何卸载。
rpm -qa | grep httpd
# 或
which httpd
systemctl status httpd
systemctl stop httpd
systemctl disable httpd
yum remove httpd httpd-tools
(CentOS 8 用 dnf remove httpd)
rm -rf /etc/httpd
rm -rf /var/www
rm -rf /var/log/httpd
CentOS 一般没有 apache2 这个包名,如果你是自己编译安装的 apache2:
which apache2
whereis apache2
进入当初编译的目录:
make uninstall
或手动删除:
rm -rf /usr/local/apache2
httpd -v
# 或
apachectl -v
提示 command not found 即说明已卸载。
如果你能贴一下:
cat /etc/centos-release)我可以给你更精确的命令。