Upgrading to Apache 2.4 – Ubuntu 13.10 upgrade stories


I upgraded to Ubuntu 13.10 when it came out hoping that it will all be a smooth upgrade and I wouldn’t have any problems at all. I knew better though, but upgraded anyway. There were hardly any changes at all and at a first glance, it looked that I should get back to work in no time. I realized that it was not to be the following morning.

When I started development on my local server, I was greeted by the “Server not found” page. I tried starting Apache and got a config error. Simple enough! Apparently, all options in the “Options” directive should either start with a “+” or “-“, or none of them. I quickly fixed this by changing the line to:

Options +FollowSymLinks -MultiViews

apache24_update

Apache started fine after that, but trying to access my pages gave me a “Access Denied” page. I checked the logs and found this error message:

[Fri Oct 18 09:39:20.212868 2013] [authz_core:error] [pid 8042:tid 139941267957504] [client 127.0.0.1:42329] AH01630: client denied by server configuration: /home/hw/www/index.html

I searched for this issue and found that there is a new authorization system for Apache 2.4, but there was a compatibility layer and it was enabled for me. I disabled the authz_host module anyway but no change. So, I did not think that this was the problem (it actually, was, as authz_core was enabled). After a few trials which involved disabling modules like fastcgi and few other tweaks, I changed the logging level to debug. This is what I saw:


[Fri Oct 18 09:39:29.588554 2013] [authz_core:debug] [pid 8043:tid 139941267957504] mod_authz_core.c(802): [client 127.0.0.1:42330] AH01626: authorization result of Require all denied: denied
[Fri Oct 18 09:39:29.588656 2013] [authz_core:debug] [pid 8043:tid 139941267957504] mod_authz_core.c(802): [client 127.0.0.1:42330] AH01626: authorization result of <RequireAny>: denied

I already had a hunch on this, and it seems I was right. It was not enough to just disable authz_host, but authz_core entirely. Instead of doing that, however, I just add “Require” directives next to “Allow from” directives. It started working, at least for static resources.

I am using PHP-FPM, which works over FastCGI and requests to PHP scripts produced a similar error:


[Fri Oct 18 09:41:26.141676 2013] [authz_core:error] [pid 8304:tid 139925370713856] [client 127.0.0.1:42343] AH01630: client denied by server configuration: /var/lib/apache2/fastcgi/php5.fastcgi

/php5.fastcgi is the alias I use to pass the requests to FPM manager, as I describe in my other post.

As a shortcut, I just added “Require all granted” directive to <Directory /> section as well. It started working (but don’t do this on live server).

Almost there! I had a problem with my virtual hosts. They worked off the same DocumentRoot as my default host. I quickly realized that it was not loading my virtual host config file at all. For one thing, it did not report a config error for “Options” directive which I had for my default config file in beginning. I fixed that and added “Require all granted” directives. No change.

I started searching for this and found a post which described how the sites-enabled files get loaded. When I checked my own apache2.conf, I found this:

# Include the virtual host configurations:
IncludeOptional sites-enabled/*.conf

It seems that a move was moved to rename all site configuration files to end with .conf extension, as mirrored by the answer here. I deleted the symbolic link from sites-enabled directory, renamed my virtualhost file to virtualhost.conf and ran a2ensite virtualhost. I restarted the server, and it all worked!

Update: I just spoke to someone who had the same problems with the Ubuntu update. In addition, his htaccess rules stopped working, even though AllowOverride was set to All. It turned out that the 000-default.conf site had been disabled and running a2ensite 000-default.conf fixed the issue.

Happy upgrades!