Read MoreThe best VPS hosting starts from $5 per month!

How to Stop, Start & Restart Apache in Linux

If your website runs on Apache web server and you made some modification or upgrade such as Added a new virtual host or added some line to httpd.conf file or other configuration file, You may need to restart apache2 to changes take effect.

To start, stop and restart apache from command line in SSH interface using Windows, Mac (OSX) or Linux, follow the instructions below:

Note: You need to have root privileges or the following code need to be executed under root user using sudo prefix right before the commands. for Your easiness to understand, I’ve added sudo prefix to these commands, Simply copy and execute these commands to your SSH interface.

How to start, stop and restart Apache

There are various methods available that can start, stop and restart apache web server. Here we will talked about some common and popular methods. These methods are:

  • init.d is the best method to start, stop, reload and restart apache web server. This method also supports most Linux distribution including Red Hat, Gentoo and Ubuntu.
  • apache2ctl is the most common commands to start, stop and restart apache. This commands works on most linux and Unix operating system.
  • service command is the most common method to start, stop, reload or restart apache server. This method supports most linux distribution including Debian and Ubuntu.

Start, Stop, Restart & Reload apache using init.d method:

Start apache2 server:

sudo /etc/init.d/apache2 start

Stop apache2 server:

sudo /etc/init.d/apache2 stop

Restart apache2 server:

sudo /etc/init.d/apache2 restart

Graceful reload:

reload command is the most recommended way to restart your web server. It doesn’t kill any process and keeps server running. This command just reload the apache2 configuration file.

sudo /etc/init.d/apache2 reload

Start, Stop, Reload and Restart apache using apache2ctl:

Start apache2 server:

sudo apache2ctl start

Stop apache2 server:

sudo apache2ctl stop

Restart apache2:

sudo apache2ctl restart

Graceful restart Apache server in linux:

sudo apache2ctl graceful

Start, Stop, Reload and Restart apache using service:

Start apache2:

sudo service start

Stop apache2:

sudo service stop

Restart apache2:

sudo service restart

To gracefully restart apache2 using service command:

sudo service reload

Start Stop Restart Apache2
Above these methods are most popular and still there are a lot of commands can start, stop and restart apache server. systemctl command is one of them, Which only works on systemd based Ubuntu operating system. In order to start apache using systemctl command you have to type:

sudo systemctl start apache2.service

To stop apache2 using systemctl command, type:

sudo systemctl stop apache2.service

Restart Apache2 using systemctl command:

sudo systemctl restart apache2.service

Do you know any other methods of Start, Stop and Restarting Apache in linux based distribution? Please let us know using the comments box below.

Leave a Reply