Virtual host on ubuntu 13.10 and apache 2.4.6 Virtual host on ubuntu 13.10 and apache 2.4.6 apache apache

Virtual host on ubuntu 13.10 and apache 2.4.6


Ubuntu 13.10 and variants have moved to Apache 2.4. Apache 2.4 wants enabled virtual host config files to end in .conf by default.

Solution

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.

Note: Configuration file is "/etc/apache2/apache2.conf" in new Apache, so please copy document root path and other configurations from "/etc/apache2/sites-available/000-default.conf" to  "/etc/apache2/apache2.conf"


I found the problem after 3h of experimenting. Apparently in the new Ubuntu 13.10 for some stupid reason the conf file for the virtual host has to look similar to this:

<VirtualHost mysite.localhost>        ServerAdmin webmaster@example.com        ServerName  mysite.localhost        ServerAlias mysite.localhost        # Indexes + Directory Root.        DocumentRoot /var/www/mysite/public_html         <Directory /var/www/mysite/public_html/>                DirectoryIndex index.php                Options Indexes FollowSymLinks                AllowOverride All                Require all granted        </Directory>        # Logfiles        ErrorLog /var/log/apache2/mysite-error.log        CustomLog /var/log/apache2/mysite-access.log common</VirtualHost>

Apparently the guys that developed Ubuntu 13.10 decided that it is no longer valuable to use

<VirtualHost *:80> 

when making a virtual host and instead it has to be

<VirtualHost mysite.localhost>

mixed with specifically specifying DirectoryIndex. This fixed the problem i had and now things are working(hopefully as they should, something may come up eventually) Apparently the configuration file of apache is different.


I had a same issue ,but None of these above postings worked for me . Later I read and reviewed each and every configuration files of Apache and PHP .

I could figure out that in apache2.conf( in ubuntu 13.10 ) there is a flag called

HostnameLookups off

By Default this will be set to off, I changed this to

HostnameLookups on

By doing so Apache started piking up my host entries and vhost config well .

Also Below is my actual Vhost file . which I used to make it working

Offcourse I too recommend adding Require all granted with in the Vhost directive .

<VirtualHost *:80>    ServerName test.yoursite.domain.in    DocumentRoot path_to_code_base/public    <Directory path_to_code_base/public>        Options -Indexes        Require all granted        DirectoryIndex index.php        AllowOverride All    </Directory>    ErrorLog  /path_to_code_base/logs/error.log    LogLevel warn    CustomLog /path_to_code_base/logs/access.log  combined</VirtualHost> 

I am posting this to help others who does not want to waste there time in downgrading Ubuntu to 13.04 from 13.10 .

I do-not see this any blogs , I also could not understand what actually the meaning of hostnameLookups is .

Hope this helps .