卸载 apache2
apt autoremove apache2
apt autoremove apache2.2-common
apt --purge remove apache2
apt --purge remove apache2.2-common
会提示 这两个文件没有移除,一个是 配置文件,一个是 网站内容,配置文件备份后可以删除
dpkg: warning: while removing apache2, directory '/var/www/html' not empty so not removed
dpkg: warning: while removing apache2, directory '/etc/apache2/sites-enabled' not empty so not removed
检测是否卸载干净
dpkg -l | grep apache2
发现还有3个存在
ii apache2-bin 2.4.54-1~deb11u1 amd64 Apache HTTP Server (modules and other binary files)
ii libapache2-mod-php 2:7.4+76 all server-side, HTML-embedded scripting language (Apache 2 module) (default)
ii libapache2-mod-php7.4 7.4.30-1+deb11u1 amd64 server-side, HTML-embedded scripting language (Apache 2 module)
继续移除
apt --purge remove apache2-bin
apt --purge remove libapache2-mod-php
apt --purge remove libapache2-mod-php7.4