How to Stop, Start & Restart Apache in Linux

Apache is the most popular web server on the web and It has been widely using by thousands of most popular companies around the world. If you are one of them who uses Apache then here some basic commands to start, stop, restart and reload Apache web-server.

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 sudoprefix 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 reload all the configuration of 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.

Subscribe To Our Newsletter

Subscribe To Our Newsletter

Join our mailing list to receive website improvement tips and tutorials.

 

We'll periodically send useful information, tips & tutorials to improve your website performance, conversion optimization, SEO and design tweaks to make your website better.

Thank you for signing up!

Please check your email and click the link provided to confirm your subscription.

Powered by Rapidology
No Comments

Post a Comment