Restart Apache2 Web Server in Ubuntu/Debian/RHEL/CentOS

Apache is a cross-platform and open-source HTTP server loaded with powerful features. This can be extended further using different modules. You could be dealing with Apache on a regular basis if you are a system administrator or developer.

It is mainly utilized to facilitate both dynamic Web pages and static content on the Internet. A lot of Web apps are created based on the Apache environment and features.

Start, Stop, Restart/Reload tasks

The most common tasks done when using the Apache web server are starting, restarting/reloading, and stopping. However, the commands you can use when managing the Apache service are varied across Linux distributions.

That said, there are basic tools to start or restart Apache using specific methods on the Linux or any Unix-like systems. In a Debian or Ubuntu environment, the Apache service is named Apache2.

Steps to manage the Apache service

Before everything else, you have to be logged in as a root or a user with sudo privileges. Note that both SysVinit script and Systemd service units take arguments such as the following to manage the Apache service.

  • Start – turns on the Apache service
  • Stop – turns off the Apache service
  • Restart – turns off and then turns on the Apache service
  • Reload – restarts the Apache service gracefully. Upon reload, the main Apache service will shut down the child processes, loads the new configuration, and starts new child processes
  • Status – the service status will be displayed

 Start/stop/restart Apache on Debian and Ubuntu

The systemd is a system and service manager intended for the most recent releases of Debian and Ubuntu. You can start the Apache service by executing the command ‘$ sudo systemctl start apache2’.

On the other hand, you can stop the Apache service by executing the command ‘$ sudo systemctl stop apache2’. You may also restart the server processes whenever you need to make changes to the Apache configuration by executing the command ‘$ sudo systemctl restart apache2’.

Start/stop/restart Apache on RHEL/CentOS

Systemd is the system and service manager for the RHEL/CentOS version 7 and 8. Thus, you can start the Apache service by executing the command ‘$ sudo systemctl start httpd’. You can also stop the Apache service by executing the command ‘$ sudo systemctl stop httpd’.

The restart command for restarting the Apache service is executed using the command ‘$ sudo systemctl restart httpd’. However, if you have an earlier system or a CentOS 6 that uses SysV, the following command options can be used for the Apache daemon.

  • $ sudo service httpd start
  • $ sudo service httpd stop
  • $ sudo service httpd restart

Note that you can either use the service or the /etc/init.d/ command for Debian and Ubuntu.

Start Apache2 Web server

Thus, you can restart the Apache2 Web server by using any of the following commands:

  • # /etc/init.d/apache2 restart

or

  • $ sudo /etc/init.d/apache2 restart

or

  • $ sudo service apache2 restart

Stop Apache2 Web server

  • # /etc/init.d/apache2 stop

or

  • $ sudo /etc/init.d/apache2 stop

or

  • $ sudo service apache2 stop

Overall, the process of starting, stopping, and restarting the Apache2 Web server is fairly easy. In fact, you can do this in as fast as 1 minute.

Total
0
Shares
Leave a Reply

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

Previous Post

What Makes Linux Computers Different?

Next Post

Safely Check Linux Version Using Some Basic Commands

Related Posts