1

I have defined several virtual hosts in my apache 2.4.12. They all are listening on port 80, but have different names. The problem is that I have 2 slightly similar virtual hosts, and the first one gets loaded when I try to acess the second one. What can be the issue?

the escr.dev host

<VirtualHost *:80>
    ServerAdmin webmaster@localhost
    ServerName escr.dev
    ServerAlias www.escr.dev
    DocumentRoot /var/www/escr.dev/application/web/
    <Directory /var/www/escr.dev/application/web/>
        Options Indexes FollowSymLinks MultiViews
        AllowOverride All
        Order allow,deny
        allow from all
    </Directory>
    ErrorLog /var/log/apache2/escr.dev-error.log
    # Possible values include: debug, info, notice, warn, error, crit,
    # alert, emerg.
    LogLevel warn
    CustomLog /var/log/apache2/escr.dev-access.log combined
</VirtualHost>

the esca.dev host

<VirtualHost *:80>
    ServerAdmin webmaster@localhost
    ServerName esca.dev
    ServerAlias www.esca.dev
    DocumentRoot /var/www/esca.dev/public/
    <Directory /var/www/esca.dev/public/>
        Options Indexes FollowSymLinks MultiViews
        AllowOverride All
        Order allow,deny
        allow from all
    </Directory>
    ErrorLog /var/log/apache2/esca.dev-error.log
    # Possible values include: debug, info, notice, warn, error, crit,
    # alert, emerg.
    LogLevel warn
    CustomLog /var/log/apache2/esca.dev-access.log combined
</VirtualHost>

So when I access "esca.dev" I am getting loaded the "escr.dev" host instead.

2
  • 1
    Are you sure you’re not just getting the default vhost because something doesn’t match? Check whether the Host header contains the expected value.
    – Daniel B
    Jul 8, 2015 at 12:32
  • Yes, I am sure, I have lots of other hosts that have same config but different document root and name. If I change the Server name and Alias to something like "iesca.dev" it works flawlessly.
    – Vit Kos
    Jul 8, 2015 at 12:42

1 Answer 1

0

Did you enabled "NameVirtualHost" directive?

You should uncomment the following in your httpd.conf:

NameVirtualHost *:80

This directive is needed to work with name-based virtual hosts.

1
  • Well, I think this is not the case, because I get this message when I restart the server : AH00548: NameVirtualHost has no effect and will be removed in the next release /etc/apache2/apache2.conf:226
    – Vit Kos
    Jul 8, 2015 at 12:18

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .