Ubuntu Server – Apache 2.4 Upgrade Changes

As many of you may have noticed, upgrading to Apache 2.4 can either cause the “apache2” service to fail to start altogether or may render your websites more or less inoperable. Luckily, there are only a few minor changes to look for that will hopefully get you back up and running with a minimal period of downtime.

  1. During the upgrade, if you decided to keep your original versions of your config files like I did (always a good idea), you will then end up with some extra files with “.dpkg-dist” on the end of the filename. These are the latest version of the config files. As a best practice with any major config file changes, I would suggest to create a backup directory and get in the habit of copying any files with the date in the filename before you make changes. There have been many instances where this has come back to bite me in the past and I have learned my lesson over the years so save yourself some time, stress, and headaches.
    cd /etc/apache2
    mkdir backups
    mv apache2.conf backups/apache2.conf.09_25_2014
    
    mv apache2.conf backups/apache2.conf.09_25_2014
    mv apache2.conf.dpkg-dist apache2.conf
    mv envvars.dpkg-dist envvars

    After that, in your favorite text editor, you will need to analyze both versions of each config file and add any necessary customizations to your new files.

  2. All config files must now end in a “.conf” file extension. If you had your old apache2.conf file still in place and it was pointing to a custom httpd.conf with an include statement and the file is no longer there, this will cause the service to fail to start. This is why it is important to use the latest config file because the whole beginning section explains the new config file directory structure which allows us to keep changes during future upgrades. Any custom apache2 config files such as httpd.conf should now be placed in the “conf-available” directory with a symlink ending in a “.conf” extension in the “conf-enabled” folder to make them active. You need to use the new apache commands to automatically create the symlinks for you with the correct path from the web directory. The new shell commands are: “a2enconf”, “a2disconf”, “a2enmod”, “a2dismod”, “a2ensite”, and “a2dissite”. Here are a few examples of their usage:
    a2enconf httpd.conf
    a2enmod php5
    a2ensite 000-default.conf

    The same applies to the “sites-available” and “sites-enabled” directories. If you had any existing sites enabled such as the pre-2.4 installation default,”000-default”, then you need to add the “.conf” file extension to each file for it to work properly.

    mv sites-enabled/000-default sites-enabled/000-default.conf
  3. In your site-specific config files, the “Options” field directives such as “+Indexes”, “-MultiViews”, “FollowSymLinks”, or “+ExecCGI”, all directives must either contain a plus or a minus or none of them can in each section.
  4. The Access Control directives “Order”, “Allow”, “Deny”, and “Satisfy” have changed and must be updated in all your config files to the new structure or else this really screws everything up. Straight from the Apache website, these all need to be changed.In this example, all requests are denied.
    2.2 configuration:
    Order deny,allow
    Deny from all
    2.4 configuration:
    Require all denied

    In this example, all requests are allowed.

    2.2 configuration:
    Order allow,deny
    Allow from all
    2.4 configuration:
    Require all granted

    In the following example, all hosts in the example.org domain are allowed access; all other hosts are denied access.

    2.2 configuration:
    Order Deny,Allow
    Deny from all
    Allow from example.org
    2.4 configuration:
    Require host example.org
  5. NameVirtualHost has been deprecated and will pop up an error message. This won’t prevent any services from being started but the message will get annoying eventually so you should comment out or remove this from your config files.
    #NameVirtualHost *:80

Once you’ve taken care of all of these issues, hopefully your service should at least start and if you’re lucky your website works.

Leave a Reply