How to Start/Stop and Restart Apache 2 Web Server

In this article, We show you how to start/stop and restart Apache 2 web server. Under web server, you can see the different type of operating systems like CentOS, Ubuntu, Debian, RHEL and Fedora, etc. So each and every operating system has a different type of commands to start/stop and rester Apache 2. Apache can be started or restarted using the following methods on Linux or Unix.
Note: You need to run the command as root or via the sudo.
CentOS/Red Hat Linux version 4/5/6 or older particular commands
The following commands are works in CentOS and Red Hat for the versions 4/5/6 or older.
1 2 3 4 5 6 |
# Start Apache Web Server # service httpd start # Stop Apache Web Server# service httpd stop # Restart Apache Web Server # service httpd restart |
CentOS/Red Hat Latest version 7 or newer particular commands
The following commands are works in CentOS and Red Hat 7 or newer.
1 2 3 4 5 6 |
# Start Apache Web Server # systemctl start httpd.service # Stop Apache Web Server # systemctl stop httpd.service # Restart Apache Web Server # systemctl restart httpd.service |
Start/Stop/Restart Apache on Debian/Ubuntu Linux
You can use service or /etc/init.d/ command to start/stop/restart Apache on Debian and Ubuntu.
Start Apache 2 Web Server
1 |
sudo service apache2 start |
Or
1 |
sudo /etc/init.d/apache2 start |
Or
1 |
/etc/init.d/apache2 start |
Stop Apache 2 Web Server
1 |
sudo service apache2 stop |
Or
1 |
sudo /etc/init.d/apache2 stop |
Or
1 |
/etc/init.d/apache2 stop |
Restart Apache 2 Web Server
1 |
sudo service apache2 restart |
Or
1 |
sudo /etc/init.d/apache2 restart |
Or
1 |
/etc/init.d/apache2 restart |
Debian and Ubuntu systemd Users
The following systemctl command for latest version Debian(8) and Ubuntu(15) or above latest version.
1 2 3 4 5 6 |
# Start Apache Web Server # systemctl start apache2.service # Stop Apache Web Server # systemctl stop apache2.service # Restart Apache Web Server # systemctl restart apache2.service |
The normal method to start/stop/restart Apache on a Linux/Unix
The following commands you need to be run as root or sudo user.
1 2 3 4 5 6 7 |
# Start Apache Web Server # apachectl -f /path/to/your/httpd.conf apachectl -f /usr/local/apache2/conf/httpd.conf # Stop Apache Web Server # apachectl -k stop # Restart Apache Web Server # apachectl -k restart |
ApacheCentOSCentOS 7DebianRedhatubuntu
Mraj
Creative Designer & Developer specialist by the spirit and a loving blogger by thoughts. If you have any questions let me drop an email with the article name to the following email id: [email protected]