An Apache server that I was working with was having an issue starting in a reasonable amount of time. This particular server was running on Ubuntu 8.04 on top of VMware ESX 3.5. The service would start eventually, but would hang for a fairly significant amount of time. In the Apache error logs it would show the following line:
[notice] Digest: generating secret for digest authentication ...
Eventually, the digest generation would finish and my websites would come back. Sometimes it would take just a few seconds and other times it would take about 30 seconds. After doing a little digging, I found that a number of people were having this issue, with very few answers.
The root problem, as I found out, was that the OS was running out of entropy. One can see how much entropy is available with the following command:
sudo cat /proc/sys/kernel/random/entropy_avail
My system was returning a value somewhere around 150-200 and went down to nothing while Apache was generating its digtest. When I looked at the same file on other systems, they were all 2000+, an obvious problem.
According to a couple of blog posts, installing rng-tools and running the rngd daemon seemed to be the answer.
I did a quick install of rng-tools:
sudo apt-get install rng-tools
However, rngd failed to start, reporting that it couldn't find the hardware generator:
/etc/init.d/rng-tools: Cannot find a hardware RNG device to use.
invoke-rc.d: initscript rng-tools, action "start" failed.
After a little more searching, I found out that you simply have to change the source for the generation to /dev/urandom:
sudo vim /etc/default/rng-tools
And changed the line:
Save the changes and start rngd:
sudo /etc/init.d/rngd start
Now, 'catting' my entropy_avail file displayed over 2000 like my other systems and Apache starts right up on a restart.