Apache: Graceful Server Reboot From Shell

How do I gracefully restart Apache web server from a shell prompt?

Use the following commands as root user. Login over ssh session.

ADVERTISEMENTS

Debian / Ubuntu Linux

Type the following command to gracefully restart Apache 2 web server under Debian / Ubuntu Linux:
apache2ctl graceful
OR
sudo apache2ctl graceful

Redhat / CentOS / RHEL / Fedora Linux

Type the following command as the root user:
apachectl -k graceful
OR
sudo apachectl -k graceful

How do I view graceful restart log?

Type the following command under CentOS / RHEL:
tail -f /var/log/httpd/error_log
OR type the following command under Debian / Ubuntu Linux:
tail -f /var/log/apache2/error.log
Sample outputs:

[Tue Oct 27 00:45:38 2009] [notice] Graceful restart requested, doing restart
[Tue Oct 27 00:45:38 2009] [notice] Digest: generating secret for digest authentication ...
[Tue Oct 27 00:45:38 2009] [notice] Digest: done
[Tue Oct 27 00:45:38 2009] [notice] Apache/2.2.3 (Red Hat) configured -- resuming normal operations
🐧 Get the latest tutorials on SysAdmin, Linux/Unix, Open Source/DevOps topics:
CategoryList of Unix and Linux commands
File Managementcat
FirewallCentOS 8 OpenSUSE RHEL 8 Ubuntu 16.04 Ubuntu 18.04 Ubuntu 20.04
Network Utilitiesdig host ip nmap
OpenVPNCentOS 7 CentOS 8 Debian 10 Debian 8/9 Ubuntu 18.04 Ubuntu 20.04
Package Managerapk apt
Processes Managementbg chroot cron disown fg jobs killall kill pidof pstree pwdx time
Searchinggrep whereis which
User Informationgroups id lastcomm last lid/libuser-lid logname members users whoami who w
WireGuard VPNCentOS 8 Debian 10 Firewall Ubuntu 20.04

ADVERTISEMENTS
1 comment… add one
  • Jeff Mcneill Apr 25, 2016 @ 4:58

    Apache on Centos no longer supports -k for anything but start, stop, restart (and even then -k is not used).

    So do:

    apachectl graceful
    -or-
    systemctl reload httpd.service

Leave a Reply

Your email address will not be published.

Use HTML <pre>...</pre>, <code>...</code> and <kbd>...</kbd> for code samples.