Apache in linux-vserver won't start, can't create socket

Solution

As I said in the first sentence, I already found the solution: I rebuilt the libapr1 package inside the guest.

I found the solution by googling for "Invalid argument: alloc_listener: failed to get a socket for (null)", the 5th hit was Invalid argument crap which mentions the kernel upgrade and refers to another blogger talking about Fedora 11 httpd problems:

The issue is related to three kernel calls that are used in apr-1.3.8-1: accept4(), dup3() and epoll_create1(). Without these calls, apache is unable to start.

He mentions the Fedora team fixed so I checked out the bug report: https://bugzilla.redhat.com/show_bug.cgi?id=516331, specifically the second comment:

.. if you build your own APR on that Xen instance, it will correctly pick up the older functions and work ..

That ringed a bell. All I had to do was to rebuilt the libapr1 package because the configure script will automatically figure out that accept4 is not available and will revert to accept. That's how I did it:

  • apt-get source libapr1
  • tar -xf apr_1.4.6.orig.tar.gz
  • cd apr-1.4.6
  • tar -xf ../apr_1.4.6-3.debian.tar.gz
  • dpkg-buildpackage
    This failed at first because of missing dependencies: apt-get install debhelper autoconf autotools-dev uuid-dev doxygen libtool
  • After some time this produced a debian package outside the directory which I installed:
    dpkg -i libapr1_1.4.6-3_amd64.deb
  • Then I just started apache and it worked!
    /etc/init.d/apache2 start

On a disk-starved systems, you may want to remove doxygen after compilation: on my system it needed over 600MB together with its dependencies.