Apache: Graceful Server Reboot From Shell

To gracefully reboot the Apache server from the shell in Linux or Unix-based systems, you can use the apachectl command with the -k graceful option. Here are the steps:

  1. Open a terminal window on your Linux or Unix-based system.
  2. Switch to the root user or use the sudo command to run the following command:
    apachectl -k graceful

    This will send a “graceful” restart signal to the Apache server, which will allow it to complete any existing requests and connections before shutting down and restarting.

    If the apachectl command is not found, you may need to install it first. In most cases, it can be installed with the Apache web server package.

  3. Verify that the Apache server has restarted successfully by checking the Apache error log file. The default location of the error log file is /var/log/httpd/error_log on Red Hat-based systems, and /var/log/apache2/error.log on Debian-based systems.

    You can use the following command to view the last 10 lines of the error log file:

    tail -n 10 /var/log/httpd/error_log

    If the Apache server has restarted successfully, you should see a message indicating that it has started, along with the date and time.

That’s it! You should now have successfully restarted the Apache server using the apachectl command with the -k graceful option.

Leave a Comment