The objective of this article is to provide the user with an information 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
ALTTEXT
CAPTIONHERE

Software Requirements and Conventions Used

Software Requirements and Linux Command Line Conventions
Category Requirements, Conventions or Software Version Used
System Installed 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 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 to catch the most obvious errors. However, it is still possible for the daemon to die because of problems with the configuration.

  • SUBSCRIBE TO NEWSLETTER
    Subscribe to Linux Career NEWSLETTER and receive latest Linux news, jobs, career advice and tutorials.


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.
DID YOU KNOW?
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.
  1. Using the systemcltcommand gracefully reload the Apache webserver:
    $ sudo systemctl reload apache2
    
  2. This method fully restarts the Apache 2 web-server:
    $ sudo systemctl restart apache2
    
ARE YOU LOOKING FOR A LINUX JOB?
Submit your RESUME, create a JOB ALERT or subscribe to RSS feed on LinuxCareers.com.
LINUX CAREER NEWSLETTER
Subscribe to NEWSLETTER and receive latest news, jobs, career advice and tutorials.
DO YOU NEED ADDITIONAL HELP?
Get extra help by visiting our LINUX FORUM or simply use comments below.