howto start stop and restart apache

The Apache web server is an open-source web application that can be used for deploying dynamic websites and web-based applications. It is fast, secure, stable, reliable and one of the most widely-used web server in the world.
It can be run on Linux and Windows operating systems.

There are several ways to start, stop and restart Apache web server in various Linux-based operating systems.

In this tutorial, we will show you how to start, stop and restart Apache webserver on Debian, Ubuntu and CentOS operating system.

Start/Stop/Restart Apache Web Server on Ubuntu/Debian Linux

There are different commands to start, stop and restart Apache webserver on a different version of Ubuntu/Debian operating system.

Commands for Debian Linux version 7.x or Ubuntu Linux version Ubuntu 14.10 or older

You can start the Apache webserver with the following command:

/etc/init.d/apache2 start

Or

service apache2 start

You can restart the Apache webserver with the following command:

/etc/init.d/apache2 restart

Or

service apache2 restart

You can stop the Apache webserver with the following command:

/etc/init.d/apache2 stop

Or

service apache2 stop

You can also check the status of Apache webserver whether it is running or not with the following command:

/etc/init.d/apache2 status

Or

service apache2 status

Commands for Debian Linux version 8.x+ or Ubuntu Linux version Ubuntu 15.04+ or above

Debian version 8.x+ and Ubuntu version 15.04+ uses systemd to start, stop and restart Apache web server.

To start the Apache webserver run the following command:

systemctl start apache2

To restart the Apache webserver run the following command:

systemctl restart apache2

To stop the Apache webserver run the following command:

systemctl stop apache2

To check the status of Apache webserver run the following command:

systemctl status apache2

Start/Stop/Restart Apache Web Server on CentOS/RHEL

There are different commands to start, stop and restart Apache webserver on a different version of CentOS/RHEL operating system.

Commands for CentOS/RHEL version 4.x/5.x/6.x or older

To start the Apache webserver run the following command:

service httpd start

To restart the Apache webserver run the following command:

service httpd restart

To stop the Apache webserver run the following command:

service httpd stop

To check the status of the Apache webserver run the following command:

service httpd status

Commands for CentOS/RHEL version 7.x or newer

To start the Apache webserver run the following command:

systemctl start httpd

To restart the Apache webserver run the following command:

systemctl restart httpd

To stop the Apache webserver run the following command:

systemctl stop httpd

To check the status of the Apache webserver run the following command:

systemctl status httpd

start/stop/restart Apache webserver with Generic Method

You can start the Apache webserver on CentOS/RHEL operating system by running the following command:

apachectl -f /etc/httpd/conf/httpd.conf

You can start the Apache webserver on Ubuntu/Debian operating system by running the following command:

apachectl -f /etc/apache2/apache2.conf

You can restart the Apache webserver on Ubuntu, Debian, RHEL and CentOS operating system by running the following command:

apachectl -k restart

You can stop the Apache webserver on Ubuntu, Debian, RHEL and CentOS operating system by running the following command:

apachectl -k stop

Conclusion

In the above tutorial, we learned how to start, stop and restart Apache webserver on different Unix-based operating systems. I hope you have now enough knowledge to manage Apache web service.

Leave a Reply

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