Apache commands failing with: AH00141: Could not initialize random number generator
According to this Debian bug report, it looks like Apache expects a kernel function to be there, that isn't necessarily there with every kernel:
The issue is that if the library is configured (at build time) to USE_GETRANDOM, then it assumes that the getrandom() call will be available and if it fails it becomes a fatal error. On my system, I don't have getrandom() because I'm running an ancient kernel, but others could (more legitimately) have the option disabled on a recent custom-built kernel.
The best solution would probably be to update to a more recent version of Ubuntu. Ubuntu 16.04 is more than five years or ten release cycles old and will lose support in less than a month. Or as the maintainer of the mentioned PPA put it:
With the experience of Ubuntu 14.04 Trusty EOL, I can't stress enough that you should plan ahead and have your servers already upgraded by now. Yesterday was too late.
I'd like to thank @Liam Morland for his answer above which led me to rectify this issue after an ill-advised apt-get update on Ubuntu 16.04. For those who might find it useful, here's exactly what I did:
-
Checked the log for apt-get to see exactly what software had been upgraded in the last round, and therefore what needed downgrading.
sudo tail /var/log/apt/history.log
-
Searched through the data there to ascertain what varies of libapr1 and libutil1 I had installed. I ascertained that for me it was:
- libapr1
- libaprutil1
- libaprutil1-dbd-sqlite3
- libaprutil1-ldap
Your system may vary!
-
Installed aptitude (
sudo apt-get install aptitude
). It is incredibly useful and gave me guidance on how to fix the dependencies, whereas apt-get gave me gibberish when I tried to downgrade. -
Using the command
sudo aptitude versions libapr1
sudo aptitude versions libaprutil1
I noted the exact version numbers that aptitude could supply. In my case, the version of libaprutil1 couldn't just be 1.5.4, it had to be 1.5.4-1build1. -
Using the = sign to specify version, I ran
sudo aptitude install libapr1=1.5.2-3
. Aptitude then gave me a list of other software which would have been downgraded or stop working if I proceeded. I quit the install process, and using the error, crafted a single command to downgrade all the software that aptitude had identified. This was mine:
sudo aptitude install libapr1=1.5.2-3 libaprutil1=1.5.4-1build1 libaprutil1-ldap=1.5.4-1build1 libaprutil1-dbd-sqlite3=1.5.4-1build1 apache2=2.4.18-2ubuntu3.17 apache2-bin=2.4.18-2ubuntu3.17 apache2-data=2.4.18-2ubuntu3.17
This was based on my specific installation, so please check what you have before running this command.
- I gave Apache a restart and everything was working fine again!
I hope this helps anyone else on the road.