en
  English
Phone :  +370 (5) 204-1903
Email: sales@1gbits.com
  1. Dedicated server
  2. Blog
  3. How to restart Apache in Linux, CentOS and Debian

How to restart Apache in Linux, CentOS and Debian

If you are a professional in the tech world, you must have heard about the LAMP stack. LAMP is an abbreviation for Linux, Apache, MySQL, and PHP. 

Linux Tutorial Jun 30, 21 by Nisal N 3 min Read
How to restart Apache in Linux, CentOS and Debian

If you are a professional in the tech world, you must have heard about the LAMP stack. LAMP is an abbreviation for Linux, Apache, MySQL, and PHP. 

We are here to help you to understand the process to restart Apache in Linux using the terminal window.

Take a look at the prerequisites that you require:

  • User account with Sudo privileges
  • Apt package manager
  • Apache installed system
  • Terminal window

Let’s begin!

How to restart Apache in Ubuntu and Debian?

Whenever you try to execute the restart command on Apache, the speed of the execution of the command depends on the server configuration majorly. It means that if you own a complex server configuration the normal working of several users may disrupt. 

So keep this in mind and prepare beforehand!

Now, in order to restart Apache, follow the below-mentioned commands:

sudo service restart apache2

Moreover, to start the Apache web server, follow these steps.

Head towards your terminal window to start Apache. Type in the following command:

sudo systemctl start apache2

Now, you have to check the status in order to be sure if Apache is enabled. Here is the command:

sudo systemctl status apache2

As you can see in the below-presented snapshot that the status is active. It implies that Apache is in running mode on your system.

How to restart Apache in CentOS?

The first step to restart the Apache server in CentOS is via the systemctl command. Let’s understand how it works.

Go to the terminal window and type in the following command:

sudo systemctl restart httpd.service

After you execute, the service restarts. 

Moving on to the next method. 

How to restart the server using apachectl command script?

Type in the below-stated command:

sudo apachectl -k restart

Moreover, to terminate the child processes follow the given command on the terminal window:

apachectl -k stop

Now, to exit the child processes after the task is finished, execute this command:

apachectl -k graceful

To force the child processes to exit, use the -k option as follows:

apachectl -k restart

Additionally, if you wish to start the Apache webserver here, follow these commands:

sudo systemctl start httpd.service

On the other hand, to stop the service, follow this command:

sudo systemctl stop httpd.service

Here are some additional commands for you in case you encounter different situations.

If you wish to run Apache while the system boots, follow:

sudo systemctl enable httpd.service

To stop Apache from loading while the system is booting:

sudo systemctl disable httpd.service

Conclusion

As you can see, the process to start or restart the Apache webserver is not a very complicated task. You execute a few commands and the work gets done. 

Moreover, you can also use the reload command in place of the restart option. The choice is yours. 

We hope that the article assists you to execute the commands successfully!

author img

Nisal N

Computers has always fascinated me since I was a kid and here we are. I love travelling for 2 reasons: the first one to see a new part of the world and second (the most important one) to experience the rich culture hidden among the country and people. I'm pretty good at cooking but very poor when it comes to baking.

Leave A Comment