zen of coding

Upgrading Ubuntu to 14.04, 500 errors because of .htaccess and other fun things…

Did you notice? The site was down for a bit today, because I’ve decided to upgrade Ubuntu to 14.04 LTS.

First of all a bad idea to do so during the day, since I had a bunch of work meetings scheduled already.

Secondly (as it always happens), after a very smooth upgrade, apache failed to start. (httpd.conf was missing)…
oh yea?

touch /etc/apache2/httpd.conf

Restart apache.

I guess we need a blank file. Cool.

Now, with apache successfully started, my site started responding with a good ol’ “500”.

OK, nothing in the error logs, what’s next?

Probably mod “rewrite”. Check all the settings. Disable. Enable. Restart. Fail.

I google some more and wonder if it has something to do with the .htaccess file in the WordPress install of this blog.

mv .htaccess old.htaccess
service apache2 restart

Whoa the site is working, but redirects are broken. We obviously need .htaccess, but why does it break the site?

What else can I check? The virtual host file:

<VirtualHost *:80>
     ServerAdmin admin@zenofcoding.com
     ServerName zenofcoding.com
     ServerAlias www.zenofcoding.com
     DocumentRoot /srv/www/zenofcoding.com/public_html/
     ErrorLog /srv/www/zenofcoding.com/logs/error.log
     CustomLog /srv/www/zenofcoding.com/logs/access.log combined
</VirtualHost>

Feels kinda empty, let’s look at what the internet suggests as decent vhost file for WordPress and Ubuntu 14.04.
Somewhat surprised, most of the examples, look just like mine… but one has the following:

<Directory "/your/server/path/">
   AllowOverride All
</Directory>

Let’s try to add it.

<VirtualHost *:80>
     ServerAdmin admin@zenofcoding.com
     ServerName zenofcoding.com
     ServerAlias www.zenofcoding.com
     DocumentRoot /srv/www/zenofcoding.com/public_html/
     ErrorLog /srv/www/zenofcoding.com/logs/error.log
     CustomLog /srv/www/zenofcoding.com/logs/access.log combined
  <Directory "/srv/www/zenofcoding.com/public_html/">
        AllowOverride All
  </Directory>
</VirtualHost>

Restart apache.

Welcome back.

Looks like things are a bit more strict now, so if you don’t have AllowOverride All in your vhost file and you are getting a 500, chances are you need to enable Overrides somewhere in your apache conf. (The details of how to set it, would depend on your specific environment. The above finally worked for me.)

Enjoy.

%d bloggers like this: