The objective of this article is to provide the user with information on how to restart Apache 2 web-server on Ubuntu 20.04 Focal Fossa.
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 |
Software | Apache 2 |
Other | Privileged access to your Linux system as root or via the sudo command. |
Conventions |
# – requires given linux commands to be executed with root privileges either directly as a root user or by use of sudo command$ – requires given linux commands to be executed as a regular non-privileged user |
How to restart Apache on Ubuntu 20.04 step by step instructions
There 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 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. - 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.
Even though both above methods check the configuration during the restart/reload procedure it is always advisable to check the Apache web-server configuration using the following command:
$ apachectl configtest Syntax OK
Since the Ubuntu 20.04 Focal Fossa Server/Desktop is based on systemd
the 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 PID
number using the sudo systemctl status apache2
command before and after the restart. - Using the
systemclt
command gracefully reloads the Apache webserver:$ sudo systemctl reload apache2
- This method fully restarts the Apache 2 web-server:
$ sudo systemctl restart apache2