在Linux中禁止Apache自启动?

时间:2019-11-20 08:53:37  来源:igfitidea点击:

如何禁止在Linux系统启动时,启动Apache服务?
在Linux系统重启时如何阻止Apache启动?

在CentOS/RHEL/Fedora/Oracle Linux中禁止Apache启动

执行下面systemctl命令查看apache的状态:

sudo systemctl status httpd

检查系统启动时是否启用了httpd:

sudo systemctl is-enabled httpd

如果在系统引导时启用了httpd,则禁用它:

sudo systemctl disable httpd

停止apache服务:

sudo systemctl stop httpd
sudo systemctl mask httpd

确认一下:

sudo systemctl status httpd
sudo systemctl is-enabled httpd

在Ubuntu/Debian Linux中,禁止Apache开机自启动

语法如下:

sudo systemctl status apache2
sudo systemctl is-enabled apache2
sudo systemctl disable apache2
sudo systemctl stop apache2
sudo systemctl mask apache2

还可以使用apt命令/apt-get命令删除apache2服务器软件包:

sudo apt remove apache2

查看systemctl命令帮助信息:

man systemctl
systemctl --help

CentOS 6.x和Apache Linux AMI中阻止Apache自启动

检查httpd服务的状态:

sudo service httpd status

使用chkconfig命令查看系统引导时是否启动httpd服务:

sudo chkconfig --list httpd

如果在系统引导时启用了httpd,则禁用它:

sudo chkconfig httpd off

停止apache服务:

sudo service httpd stop

确认一下:

sudo service httpd status
sudo chkconfig --list httpd