How to Start, Stop, or Restart Apache on Ubuntu

This quick guide will show you how to start, stop or restart the Apache web server on Ubuntu.

Ubuntu Start, Stop or Restart Apache

Apache is a popular web server you can run on your Ubuntu system. If you have this web server running on your device, it can be controlled through the service installed alongside it.

Over the years, Ubuntu has had several different ways to start or stop the Apache service, but any release since 14.04 uses systemd, so we will be focusing on that within our guide.

Over the following few sections, we will show you how to start, stop or restart the Apache using the system and service manager.

Of course, to restart Apache on Ubuntu, you must either be running as the root user or have superuser privileges.

For the following steps, you will need to be using the terminal on your Ubuntu device. You can quickly open the terminal on the desktop version of Ubuntu by pressing CTRL + ALT + T.

How to Restart Apache on Ubuntu

Restarting the Apache web server on Ubuntu is as straightforward as using the following command within the terminal.

This command tells the system manager to restart the service with the name “apache2“.

sudo systemctl restart apache2

If the Apache web server has been successfully restarted on your Ubuntu device, you shouldn’t see any other message within the terminal.

You can also verify that the Apache service was restarted by checking its status.

sudo systemctl status apache2

From this result, you will want to look at the end of the “Active:” line, as this will tell you how long the service has been running.

If you restarted the service, it should show as “active (running)“, and the time since it started should be a couple of seconds like shown below.

Active: active (running) since Sun 2023-04-23 03:38:48 BST; 2s ago

How to Start Apache on Ubuntu

If your Apache web server has stopped running on your Ubuntu computer, it is easy to start it again by using systemctl.

To start Apache on your Ubuntu device, use the following command within the terminal.

sudo systemctl start apache2

You can verify that you successfully started the Apache web server by using the “status” option. This will tell us whether the specified service has been started or not.

sudo systemctl status apache2

If you have started the Apache server on your Ubuntu device, you should see that the status is marked as “active (running)“, like in the example we have shown below.

Active: active (running) since Sun 2023-04-23 03:41:42 BST; 5s ago

How to Stop Apache on Ubuntu

At some point, you may want to stop the Apache web server from running on your Ubuntu service. Luckily, that process is made simple as the server runs as a service on your device.

You only need to use the following command within the terminal to stop the Apache web server on Ubuntu.

This command will get the system manager to send a stop signal to the webserver and allow it to stop gracefully.

sudo systemctl stop apache2

You can verify that you have stopped the Apache web server by making use of the “systemctl” command and its “status” option.

sudo systemctl status apache2

If Apache has been stopped on your Ubuntu device, the status will be marked as “inactive (dead)“, as shown below. You should also see a log message saying, “Stopped The Apache HTTP Server.

inactive (dead)

How to Reload Apache on Ubuntu

If you have made configuration changes to Apache, you aren’t required to restart the service completely.

Instead, you can use the “reload” command on Ubuntu to tell Apache to re-pull its configuration files. This helps reduce downtime from Apache having to completely restart.

Please note that if your configuration changes are invalid, it could cause the Apache service to stop, and you will need to fix the error and start the service manually.

To tell Apache to reload on Ubuntu you will want to use the command shown below within the terminal.

sudo systemctl reload apache2

You can verify that the Apache web server reloaded by seeing if your configuration changes took effect or by using the status command.

sudo systemctl status apache2

Below you can see that we successfully reloaded the Apache server on our Ubuntu device by looking at the log messages.

Apr 23 03:46:44 pimyubu systemd[1]: Reloading The Apache HTTP Server.
Apr 23 03:46:44 pimyubu systemd[1]: Reloaded The Apache HTTP Server.

Conclusion

Hopefully, at this stage in the guide, you will now understand how to start, stop or restart the Apache web server on your Ubuntu device.

As Apache runs as a service managing it is a very straightforward process, especially when coupled with the “sysmctl” tool.

Please comment below if you have questions about managing the Apache web service on your Ubuntu device.

If you found this quick guide helpful, check out our many other Ubuntu guides. We also have plenty of Linux tutorials that are worth checking out.

Leave a Reply

Your email address will not be published. Required fields are marked *