5/5 - (4 votes)

How do restart or enable an Apache2 in Debian / Ubuntu / CentOS / RHEL / Fedora Linux or UNIX-like operating systems? follow the command to start or stop Apache 2 web server running on Linux.

First, login to your web server using ssh client, if the server is not in your local data centre:
ssh [email protected] #elyspace box
ssh [email protected] # AWS
ssh [email protected] # My home dev server

Debian/Ubuntu Linux Specific Commands to Start/Stop/Restart Apache

You can either use service or /etc/init.d/ command as follows on Debian Linux version 7.x or Ubuntu Linux version Ubuntu 14.10 or older:

Restart Apache 2 web server, enter:

# /etc/init.d/apache2 restart
$ sudo /etc/init.d/apache2 restart
$ sudo service apache2 restart

To stop Apache 2 web server, enter:

# /etc/init.d/apache2 stop
$ sudo /etc/init.d/apache2 stop
$ sudo service apache2 stop

To start Apache 2 web server, enter:

# /etc/init.d/apache2 start
$ sudo /etc/init.d/apache2 start
$ sudo service apache2 start

Use the following systemctl command on Debian Linux version 8.x+ or Ubuntu Linux version Ubuntu 15.04+ or above:
## Start command ##
systemctl start apache2.service
## Stop command ##
systemctl stop apache2.service
## Restart command ##
systemctl restart apache2.service

We can view status using the following command:
$ sudo systemctl status apache2.service

About the Author

Shahid Malla

Shahid Malla is an accomplished system admin and web developer, renowned for his expertise in various fields. With a strong background in WHMCS development, WordPress development, and PHP development, Shahid has honed his skills over the years to deliver exceptional results. As a top-rated freelancer, he has consistently garnered praise and recognition, earning a stellar 5-star rating from a pool of 500 reviews. Shahid's proficiency extends beyond coding and development, encompassing server configuration, server management, and web security. With his extensive knowledge and dedication to delivering high-quality solutions, Shahid Malla is your go-to professional for all your technical needs.

View All Articles