Linux Ask!

Linux Ask! is a Q & A web site specific for Linux related questions. Questions are collected, answered and audited by experienced Linux users.

Jan 082010
 

How to check the Apache configuration file (httpd.conf)?

Answer:

When you have made changes to the Apache configuration file (httpd.conf), you should always perform a syntax check on the file before restarting the Apache. Especially if it is on a production environment.

Use the following command to perform a config test

apachectl configtest

Jan 082010
 

Apache restart explained

Answer:

1. apachectl -k restart

Sending a restart signal to the Apache parent process and causes it to kill off its children, but the parent process doesn't exit. It re-reads its configuration files, re-opens any log files and continues serving users.

2. apachectl -k graceful

Similar to (1), except the the child process will exit after they have finished their current request.

3. apachectl -k stop && apachectl -k start

The Apache parent process is killed immediately and the Apache is start up again. This is the only way to cleanup cached program data (e.g. using mod_perl) stored in the Apache parent process, method (1) and (2) do not work in this case since only child process are killed.

Reference: http://httpd.apache.org/docs/2.2/stopping.html

Jan 082010
 

How to restart Apache without disconnecting user

Answer:

If you have made changes to the apache configuration (httpd.conf), you would need to restart Apache to re-read the new configuration.

However, you don't need to disconnect user immediately, you can tell the Apache's parent process to advise their children to exit after they have finished their current request. So users will not experience a sudden disconnect.

To do so, use the graceful flag

apachectl -k graceful