How to Restart Apache in Ubuntu

Despite the surge of NGINX, Apache is still one of the most used open source server software. But this article is not about Apache vs NGINX discussion. This is just a quick tips where I’ll show you various ways to restart the Apache server in Ubuntu or other Linux distributions.

Restart Apache in Ubuntu Linux

Like many other services, there are multiple ways to restart Apache. Since Ubuntu 16.04, 18.04 and above versions use systemd, you can use the systemd commands to manage any service, including Apache. In fact, systemd is my recommended method.

But wait! Do you really need to restart Apache?

Why do you want to restart Apache server? Probably you made some configuration changes and you want those changes to take into effect. If that’s the case, you don’t need to restart Apache.

Restarting Apache means the Apache server will shut down and then start again. If you are on a production server, it will result in downtime for all the services that utilize the Apache server. You don’t want to do that, do you?

Apache supports reload which means you can reload the configuration without shutting down the server. This way, your live server won’t suffer a downtime.

sudo systemctl reload apache2

If you don’t want to use systemd command, there is an alternate command to reload apache server:

sudo service apache2 reload

Okay! You really want to restart Apache

I can understand that you may have your reason why reloading Apache won’t do the job and you must restart the Apache server. If that’s the case, you can use the systemd command:

sudo systemctl restart apache2

Alternatively, you can this command as well:

sudo service apache2 restart

Bonus Tip: Check the status of Apache server

Since you are dealing with restarting and reloading a service, it would be a good idea to check its status. You can check the status of Apache server using systemd:

systemctl status apache2.service

The non-systemd command for checking Apache server status is:

service apache2 status

Conclusion

Restarting a service is always better than rebooting the server which usually takes a lot longer.

I hope you liked this quick to tip on restarting Apache server in Ubuntu and other Linux distributions. If you have questions or suggestions, do let me know in the comment section.