Virtual Host Issues When Upgrading from Apache 2.2 to 2.4

The Debian testing repos have recently added the updated version of Apache 2 (Apache 2.4). Now most system running the Debian operating system have Apache 2.2 installed, when upgrading to 2.4 some little quirks involving the virtual host may arise. 

When I tried to add a virtual host in the common /etc/apache2/sites-available directory and run the command a2ensite yourdomain I got the following error message:

ERROR: Site yourdomain does not exist!.


Now to correct this problem there are two methods you can use to achieve the same result.

1. The first solution and simple solution, is to add a .conf extension to all your virtual host. The new Apache 2.4 reads each virtual host in the sites-available directory with .conf extension outlined in the new Apache 2.4 configuration file. 

2. The second solution is to remove the .conf extension in Apache 2.4 configuration file located in /etc/apache2/apache2.conf

In the old Apache 2.2 file the .conf file had a Include sites-enabled/ whereas the new .conf file has

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

Change that line to read:

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

The results: the command a2ensite yourdomain now runs as expected. If you are using the 2nd method; your virtual host files do not need to have the .conf extension.