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
OR$ sudo /etc/init.d/apache2 restart
OR$ sudo service apache2 restart
To stop Apache 2 web server, enter:
# /etc/init.d/apache2 stop
OR$ sudo /etc/init.d/apache2 stop
OR$ sudo service apache2 stop
To start Apache 2 web server, enter:
# /etc/init.d/apache2 start
OR$ sudo /etc/init.d/apache2 start
OR$ 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