loading...

How to Start, Stop and Restart Apache Ubuntu – Apache2

How to Start, Stop and Restart Apache Ubuntu – Apache2

The most common question to every newbie on the apache web server is how to start, stop or restart apache ubuntu server on Linux and ubuntu like systems. We cover all the possible options for you in the following guide. 

Table of contents –

Apache is one of the most powerful and widely used web servers in the world. Apache is not a physical server but instead it a server software with many powerful features. 

Do you know that 42.3% of the internet runs on the apache server? It is free of cost and open-source, lets you customize according to your needs. 

Using the apache server you can dynamically load modules, have robust media support, and also integrate with other popular software.

The common problem with newbies on the apache server is how to start, stop, and restart the apache server? There are no hard buttons and you don’t want to lose data. 

We cover the complete guide on how to start, stop, and restart apache on ubuntu systems. 

restart apache ubuntu

Pre-requisites – 

  1. SUDO/ROOT access to the Apache webserver.
  2. Properly installed and configured Apache 

Compile and install  apache on ubuntu from the official documentation here


We use the command-line terminal to perform operations on the apache server and these commands are for ubuntu users with versions 16.04 and 18.04 and Debian 9.x users

Start apache server in ubuntu using terminal commands – 

To start the apache web server on your ubuntu system, type the following command – 

sudo systemctl start apache2

To check the status of the apache server and make sure it is running, use the following command – 

sudo systemctl status apache2

This command will display “Active ( running )” if the apache server is successfully running. If it does not display the active status, check for configurations or reinstall the apache server.

start apache ubuntu

Stop apache server in ubuntu using terminal commands – 

To stop apache, type the following command – 

sudo systemctl stop apache2

Make sure you save all the changes on your apache server before performing the stop apache command. 

You can check if the apache server is successfully stopped using the status command, type the following command in the terminal – 

sudo systemctl status apache2

In the status information if the message is ” inactive (dead) ” then you have successfully stopped the Apache server. 

stop ubuntu apache

Restart apache server in ubuntu terminal – 

To restart apache on ubuntu like systems, you can use the following command in the terminal window – 

sudo systemctl restart apache2

Restarting is a good practice when you make new software integrations or load new modules on your apache server. Make sure you save all your necessary configurations before restarting your apache server. 

If apache was previously disabled then you can use the status command in your terminal window to check the active state. Use the following command in terminal – 

sudo systemctl status apache2

restart apache ubuntu

These commands are helpful to start, stop, and restart apache on ubuntu like systems with versions 16.04 and 18.04 and Debian 9.x users. 

Also read: How to check the version of Linux? Check Linux Version

There are other commands to start, stop, and restart apache on Debian Linux version 7.x or Ubuntu 14.10 or older. 


Start, stop and restart apache on Debian Linux version 7.x or Ubuntu 14.10 or older using the following commands – 

Command to start apache server – 

To start the apache server we use the init operations on older ubuntu systems (14.10 or lesser) and Debian (7.x) and start apache.

# /etc/init.d/apache2 start

(or)

$ sudo /etc/init.d/apache2 start

(or)

$ sudo service apache2 start

Command to stop apache server –

To stop the apache server we use the same init operations on older ubuntu systems (14.10 or lesser) and Debian (7.x) and stop apache.

# /etc/init.d/apache2 stop

(or)

$ sudo /etc/init.d/apache2 stop

(or)

$ sudo service apache2 stop

Also read: How to delete files and directories in Linux – Simple Guide

Command to restart apache server – 

To restart the apache server we use the same init operations on older ubuntu systems (14.10 or lesser) and Debian (7.x) and restart apache.

# /etc/init.d/apache2 restart

(or)

$ sudo /etc/init.d/apache2 restart

(or)

$ sudo service apache2 restart


CentOS and Red Hat Linux version to start, stop and restart apache ubuntu server – 

To start apache on CentOS and Red Hat Linux version – 

systemctl start httpd.service

Stop apache on CentOs and Red Hat Linux version – 

systemctl stop httpd.service

Restart apache on CentOs and Red Hat Linux version – 

systemctl restart httpd.service

Also read: Things to do after installing kali Linux – Most Important


Start, stop and restart apache ubuntu using the generic method – 

To start apache ubuntu server using the generic method – 

apachectl -f /path/to/your/httpd.conf

apachectl -f /usr/local/apache2/conf/httpd.conf

Stop apache ubuntu server using the generic method – 

apachectl -k stop

Restart apache ubuntu server using the generic method – 

apachectl -k restart

Graceful restart – 

apachectl -k graceful


Conclusion – 

Using the above commands you can start, stop, and restart the apache server. 


Frequently Asked Questions – 

How do I restart Apache server on ubuntu?

There are different commands to restart apache server on ubuntu and ubuntu like systems such as CentOS, Debian based Linux, Red Hat and more.

restart apache server on ubuntu versions 16.04 and 18.04 and Debian 9.x

Type the following command -

sudo systemctl restart apache2

Restart apache server on Debian Linux version 7.x or Ubuntu 14.10 or older

Type the following command -

$ sudo /etc/init.d/apache2 restart

Restart apache ubuntu server on CentOS and Red Hat Linux

Type the following command -

systemctl restart httpd.service

How do I restart Apache gracefully?

To restart Apache gracefully, use the following ubuntu command -

apachectl -k graceful

Does restarting Apache kill sessions?

When you restart Apache normally, it will kill any established and active connections to all visitors browsing any site hosted through your Apache web server instance.

What is httpd service?

httpd is the Apache HyperText Transfer Protocol (HTTP) server program. It is designed to be run as a standalone daemon process. When used like this it will create a pool of child processes or threads to handle requests.

What is the difference between Apache and Tomcat?

Apache is a web-server meant to serve static web-pages.

Apache Tomcat is an application server meant to serve Java applications (Servlets, JSPs and more).

You can serve web-pages as well through Tomcat, but it is less efficient at that as compared to Apache.


See Also: Best Password Managers in 2020

Leave a Reply

Your email address will not be published.