In this tutorial you will learn:
- How to gracefully reload Apache
- How to restart Apache
Software Requirements and Conventions Used
|Category||Requirements, Conventions or Software Version Used|
|System||Installed Ubuntu 20.04 or upgraded Ubuntu 20.04 Focal Fossa|
|Other||Privileged access to your Linux system as root or via the
# - requires given linux commands to be executed with root privileges either directly as a root user or by use of
How to restart Apache on Ubuntu 20.04 step by step instructionsThere are two main ways on how to restart the Apache webserver on Ubuntu Linux:
- reload - Gracefully restarts the Apache daemon by sending it a SIGUSR1. If the daemon is not running, it is started. This differs from a normal restart in that currently open connections are not aborted. A side effect is that old log files will not be closed immediately. This means that if used in a log rotation script, a substantial delay may be necessary to ensure that the old log files are closed before processing them. This command automatically checks the configuration files via
apache2ctl configtestbefore initiating the restart to catch the most obvious errors. However, it is still possible for the daemon to die because of problems with the configuration.
- restart - Restarts the Apache daemon by sending it a SIGHUP. If the daemon is not running, it is started. This command automatically checks the configuration files via configtest before initiating the restart to catch the most obvious errors. However, it is still possible for the daemon to die because of problems with the configuration.
$ apachectl configtest Syntax OKSince the Ubuntu 20.04 Focal Fossa Server/Desktop is based on
systemdthe following two methods are recommended to restart the the Apache web server.
You can check whether the Apache 2 web-server has been fully restarted by checking for
Main PIDnumber using the
sudo systemctl status apache2command before and after the restart.
- Using the
systemcltcommand gracefully reloads the Apache webserver:
$ sudo systemctl reload apache2
- This method fully restarts the Apache 2 web-server:
$ sudo systemctl restart apache2