Configuration changes in Apache 2.4





Last Updated on 07/27/2013 by dboth

I have used Apache up through Version 2.2 for my web sites for a long time and the configuration has remained pretty consistent for a long time. As of Apache 2.4, which is provided with Fedora 19, some major changes have taken place.

If you are running only a single web site using Apache 2.4 there is little difference in what needs to be configured to make that work. The default configuration file supplied with either Apache 2.2 or 2.4 works just fine.

There are significant differences between the configuration file /etc/httpd/conf/httpd.conf from V2.2 to V2.4, however, so you will probably need start with the V2.4 configuration file, httpd.conf and reconfigure your web site from there.

The old V2.2 httpd.conf file will most definitely fail if you try to use it with Apache 2.4.

Virtual hosts

One of the big problems I found was migrating my Virtual Hosts configuration. Using virtual hosts is a method to serve two or more separate and distinct web sites using a single instance of Apache and even a single IP address.

The first change is simply that the NameVirtualHost directive has been deprecated and will be eliminated in the next version of Apache.

The real issue is that one previous method of dealing with data storage for multiple web sites has been eliminated. I used to keep my web sites in different top-level directories, such as:

  • /var/www
  • /var/www1
  • /var/www2
  • /var/example.com

…and so on.

This option for data storage fails with 403 Forbidden errors when using virtual hosts with Apache 2.4.

After a bit of experimentation, I found that using a structure like that below works.

/var
   |
   +--www
        |
        +--www
        |
        +--www1
        |
        +--www2
        |
        +--example.com
        |

…and so on. Within each of the domain directories, the standard subdirectories like html and cgi-bin are the same as always.

The new VirtualHost directives in the httpd.conf file look something like this.

<VirtualHost 192.168.0.102:80>
    ServerAdmin david@example.com
    DocumentRoot /var/www/www/html
    ServerName www.domain.com
    ErrorLog logs/error_log
</VirtualHost>

<VirtualHost 192.168.0.102:80>
    ServerAdmin david@example.com
    DocumentRoot /var/www/example.com/html
    ServerName www.example.com
    ErrorLog logs/error_log
</VirtualHost>

 

.