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
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
As you can see, the process to start or restart Apache in Linux 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!
People also read: