Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I have a production server that in the last 24 hours has been hard rebooted 4 times due to freezes. Ping is fine but all other services time-out (Apache, SSHd, etc). I have now diagnosed it to Apache running out of memory due to an exorbitant amount of child processes forking suddenly within seconds of starting Apache. Stopping Apache just after rebooting keeps the server stable again.

My two questions are:

  1. Is there a way to detect which of the vhosts is being suddenly hammered without looking into each vhost's access log one by one?

  2. Is there a way to quickly enable/disable vhosts without commenting (#) them all out in httpd.conf?

A few system details:

Fedora 10, x86_64, PHP 5, Apache 2.2

share|improve this question
add comment

2 Answers

up vote 3 down vote accepted

Try setting up a status page using mod_status. If you can get in after starting up your server you should see a page like this which shows each connection with its corresponding vhost, and URL.

If your site is so heavily flooded that you can't get in, try running netstat -nt | grep :80 or lsof -ni tcp:80 to see if one or two addresses are flooding your site and apply iptables accordingly.

share|improve this answer
Good point about the mod_status. The two other suggestions worked out well too. Another way I approached it was like this tail -f /home/*/logs/access_log. –  mr-euro May 6 '10 at 20:08
add comment

1) I often use lsof to see what files/directories apache has open during time of high load. So for instance (on debian/ubuntu) you could run:

lsof -u www-data

and then to get something more useful, only search for open files in the correct location (e.g. /home) and then exclude the log files which should always be open.

lsof -u www-data | grep /home | grep -v *.log

You may have to run this a few times to get an idea of what is running often.

2) If your running debian/ubuntu you can use the a2ensite and a2dissite to automatically add and remove vhosts from your apache setup.

share|improve this answer
Thx Coops, I tried lsof but no files appear listed (apart from log files) when grepping only /home (where the vhosts are located). I have updated the initial question with system details. –  mr-euro May 5 '10 at 16:39
@mr-euro it's a bit strange that no files appearing! Either your not looking for the right entries, or they are happening to quickly (which is strange for an over loaded box). What about doing the lsof command combined with watch, so for instance: watch -n 0.5 'lsof...' This will run the lsof command for you every half second. –  Coops May 5 '10 at 20:42
Shortening the timeframe did show something thanks. –  mr-euro May 6 '10 at 20:05
This was such a lifesaver today! On a Plesk server you need to use lsof -u www-data | grep httpdocs | grep -v *.log because on a Apache Plesk shared server Apache has 100s of log files open, therefor the httdocs –  Eugene van der Merwe Dec 28 '13 at 13:48
add comment

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.