Power full way to Restart Apache2 server in Ubuntu
Contents
Restarting the Apache2 server is a regular procedure when operating an Ubuntu web server that could be required following updates or configuration changes. This tutorial will show you how to use the systemctl or service command to restart the Apache2 server on Ubuntu.
Using systemctl to Restart Apache2
- Open your terminal. OR Press Ctrl+Alt+T to open a terminal window quickly.
- To restart Apache using service, use the following command:
sudo service apache2 restart
For Ubuntu 16.04 and later, use the following command:
sudo systemctl restart apache2
For older Ubuntu versions (14.10 or earlier), use this command:
sudo /etc/init.d/apache2 restart
Verify the Restart
After executing either of the above commands, it’s a good practice to verify that Apache has restarted successfully. You can check the status of Apache using:
sudo systemctl status apache2
or, for systems using the service command:
sudo service apache2 status
Look for any error messages or issues in the output to ensure a smooth restart.
Additional notes for Restart Apache Server
The sudo
command is used to execute commands with administrative privileges, which are required to manage system services like Apache.
- To stop Apache:
sudo systemctl stop apache2
- To start Apache:
sudo systemctl start apache2