How to Restart Apache2 in Ubuntu 18.04 Server

Let's talk about how to restart Apache web server on Ubuntu server 18.04. There are a couple ways we can restart apache in Ubuntu 18.04. The standard and most common method is to use the systemctl command.

To restart Apache server, run:

systemctl restart apache2

Note that, you need root privileges to restart apache2 in Ubuntu 18.04. You can also run the systemctl command with sudo to get root privileges.

The systemctl command has an option called reload (graceful restart) which will reload the Apache server configuration without restarting the entire Apache process.

systemctl reload apache2

A graceful restart will reload apache2 configuration while allowing Apache to continue to serve their current requests.

The apachectl command

Alternatively, you can use  apachectl command to restart apache 2 in Ubuntu 18.04 server:

apachectl restart

Will restarts  the Apache server.

apachectl graceful

Will reload the config file and currently open connections are not aborted.