Oct 10, 2008

Restart APACHE Safely

In all the Unix like machines ,there is an INIT script running for APACHE. Normally it is located in /etc/init.d/httpd (In case of REDHAT based systems). But in Debian based systems it could be /etc/init.d/apache2. For restarting we use the following

#/etc/init.d/httpd restart (Redhat Based Systems)

OR

#/etc/init.d/apache2 restart (Debian Based Systems)


While doing this command,it will KILL all the listening processes in the machine and stopping and starting Apache. But the problem is while applying the command CLIENTS will losts its all the established connections and result may be an error.


There is a wonderful command is in Apache for preventing this,the command is APACHECTL. Normally called Apache Control. Before restarting apache think once and apply the following


#apachectl -k graceful

The impact is Apache will serve all the established requests to the server. Then only it go for RE-start. User wont have a feelings of this COLD restart.

No comments: