How do I stop Apache from starting on Linux?

last updated in Categories , , , ,

How do I stop Apache from starting on Linux?

Apache HTTP Server, also called Apache or HTTPD, is a web server notable for helping the growth of the World Wide Web. It is a free and open source software and default on many Linux distros. This page explains how to stop Apache from starting at boot time on Linux operating systems.


Stop Apache from Starting on Linux

The procedure to stop Apache from starting at boot time on Linux is as follows:

  1. Open the terminal application
  2. Login using ssh for remote server. For example: ssh user@server-name
  3. Use sudo systemct disable httpd && sudo systemct stop httpd on RHEL/CentOS/Oracle/Fedora Linux.
  4. Ubuntu/Debian users run sudo systemct disable apache2 && sudo systemct stop apache2 command.

Let us see all commands and examples in details.

Stop Apache on a CentOS/RHEL/Fedora/Oracle Linux from starting

Is Apache 2 service running? Run the following systemctl command:
sudo systemctl status httpd
Next find out if httpd enabled at boot time:
sudo systemctl is-enabled httpd
If enabled at boot time, disable it, run:
sudo systemctl disable httpd
Stop the service, execute:
sudo systemctl stop httpd
sudo systemctl mask httpd

Verify it:
sudo systemctl status httpd
sudo systemctl is-enabled httpd

How to stop Apache starting Linux using systemctl command
The mask option will link httpd unit files to /dev/null, making it impossible to start it. This is a stronger version of disable, since it prohibits all kinds of activation of the unit, including enablement and manual activation. Use this option with care. See Start / Stop and Restart Apache 2 Web Server Command for more info.

A note about Ubuntu/Debian Linux users

The syntax is as follows:
sudo systemctl status apache2
sudo systemctl is-enabled apache2
sudo systemctl disable apache2
sudo systemctl stop apache2
sudo systemctl mask apache2

You can delete the apache2 server package using the apt command/apt-get command:
sudo apt remove apache2
How to stop and diable apache server in Ubuntu or Debian Linux at boot time
I suggest you read man page of systemctl command, type:
man systemctl
systemctl --help

CentOS 6.x and Apache Linux AMI stop Apache from starting

Is httpd server running? Run the following service command:
sudo service httpd status
Next find out if httpd enabled at boot time using the chkconfig command:
sudo chkconfig --list httpd
If httpd is enabled at boot time, disable it, run:
sudo chkconfig httpd off
Stop the service, execute:
sudo service httpd stop
Verify it:
sudo service httpd status
sudo chkconfig --list httpd

Httpd Apache2 disable at boot time on Linux
Commands for CentOS 6 or Amazon Linux AMI

One can get more info on service and chkconfig commands:
service --help
chkconfig --help

And that is how you disable Apache at boot time on a CentOS 6 or Amazon Linux AMI.


You learned how to stop Apache starting on Linux using various command line options. See Apache 2 home page for more info.


Posted by: Vivek Gite

The author is the creator of nixCraft and a seasoned sysadmin, DevOps engineer, and a trainer for the Linux operating system/Unix shell scripting. Get the latest tutorials on SysAdmin, Linux/Unix and open source topics via RSS/XML feed or weekly email newsletter.

Start the discussion at

Historical Comment Archive

1 comment

    Still, have a question? Get help on our forum!