How do I stop Apache from starting on Linux?

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.

ADVERTISEMENTS

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 systemctl disable httpd && sudo systemctl stop httpd on RHEL/CentOS/Oracle/Fedora Linux.
  4. Ubuntu/Debian users run sudo systemctl disable apache2 && sudo systemctl 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.

Conclusion

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

🐧 Get the latest tutorials on SysAdmin, Linux/Unix, Open Source/DevOps topics:
CategoryList of Unix and Linux commands
File Managementcat
FirewallAlpine Awall CentOS 8 OpenSUSE RHEL 8 Ubuntu 16.04 Ubuntu 18.04 Ubuntu 20.04
Network Utilitiesdig host ip nmap
OpenVPNCentOS 7 CentOS 8 Debian 10 Debian 8/9 Ubuntu 18.04 Ubuntu 20.04
Package Managerapk apt
Processes Managementbg chroot cron disown fg jobs killall kill pidof pstree pwdx time
Searchinggrep whereis which
User Informationgroups id lastcomm last lid/libuser-lid logname members users whoami who w
WireGuard VPNAlpine CentOS 8 Debian 10 Firewall Ubuntu 20.04

ADVERTISEMENTS
0 comments… add one

Leave a Reply

Your email address will not be published.

Use HTML <pre>...</pre>, <code>...</code> and <kbd>...</kbd> for code samples.