change apache configuration without restarting

How to Change Apache Config Without Restarting

Apache is a popular web server used by millions of websites & organizations. It supports high traffic websites in production environments. However, often system administrators need to make changes to Apache server configuration. But these changes are not applied immediately after modifying the server configuration file. Typically, you need to restart Apache server to apply the changes. But this can take your website offline until the server restarts fully, spoiling user experience. So how to change Apache config without restarting? In this article, we will learn how to do this.


How to Change Apache Config Without Restarting

To modify Apache config without restarting, we need to do a graceful restart. You can do this using the following command if you are logged in as root user.

$ apachectl -k graceful
OR

$ apache2ctl -k graceful

If you are managing Apache via systemd process, you can gracefully restart Apache using reload command.

# CentOS/RHEL/Fedora Linux
$ sudo systemctl reload httpd
# Debian/Ubuntu Linux
$ sudo systemctl reload apache2

If the above commands do not work for you, then you can also use the following ones depending on your Linux distribution.

# RHEL/CentOS Linux 
$ /etc/init.d/httpd graceful
OR

$ /sbin/service httpd graceful

# Debian / Ubuntu Linux

$ /etc/init.d/apache2 reload

In graceful restart, we send a USR1 signal to Apache parent process which instructs the child processes to exit after serving the latest request, or immediately in case it is not doing anything. Then the parent reads the latest configuration file and reopens the log files. It replaces each child process that has died, with a new child process according to the latest configuration file, which starts serving requests immediately.

In this article, we have learnt how to change Apache configuration file, without restarting Apache server.

Also read:

How to Change NGINX Config Without Restarting
How to Get Selected Text from Dropdown Using jQuery
How to Get Data-ID Attribute in jQuery/JavaScript
How to Check if Image is Loaded in jQuery/JavaScript
How to Fix Ambiguous Column Names in MySQL

Leave a Reply

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