Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

I have the next apache virtualhosts and NameVirtualHost settings:

NameVirtualHost 10.100.106.89

<VirtualHost 10.100.106.89>
        DocumentRoot /var/www/html/dev/novared_soporte/branches/v0.3/soporte
        ServerName 10.100.106.89
</VirtualHost>
<VirtualHost 10.100.106.89>
        DocumentRoot /var/www/html/phpmyadmin
        ServerName 10.100.106.89/phpmyadmin
        ServerAlias 10.100.106.89/pma
</VirtualHost>
<VirtualHost 10.100.106.90>
        ServerName 10.100.106.90
        DocumentRoot /var/www/html
</VirtualHost>

When I try to reach: 10.100.106.89 I can get to the site that I need: /var/www/html/dev/novared_soporte/branches/v0.3/soporte

but when I try to reach 10.100.106.89/phpmyadmin I actually get this error on error_log.txt (httpd logs):

[Thu Jun 28 12:12:59 2012] [error] [client 10.100.103.31] File does not exist: /var/www/html/dev/novared_soporte/branches/v0.3/soporte/phpmyadmin

I still cant get where is the mistake. By the way, 10.100.106.90 is working properly, at least for its DocumentRoot /var/www/html

share|improve this question

3 Answers 3

You can't have a server name consist of anything other than a FQDN - don't put a / in it - it simply won't be interpreted.

Consider doing this, then just adding a HOSTS file entry instead

<VirtualHost 10.100.106.89>
    DocumentRoot /var/www/html/dev/novared_soporte/branches/v0.3/soporte
    ServerName www.example.com
</VirtualHost>
<VirtualHost 10.100.106.89>
    DocumentRoot /var/www/html/phpmyadmin
    ServerName phpmyadmin.example.com
</VirtualHost>

Then in your HOSTS file add

10.100.106.89 www.example.com
10.100.106.89 phpmyadmin.example.com

You can freely use example.com as per the IETF guidelines

Or combine the two vhosts into a single vhost

<VirtualHost 10.100.106.89>
    DocumentRoot /var/www/html/dev/novared_soporte/branches/v0.3/soporte
    ServerName 10.100.106.89 
    ServerAlias www.example.com
    Alias /phpmyadmin /var/www/html/phpmyadmin
</VirtualHost>
share|improve this answer

you stated the DocumentRoot for 10.100.106.89 twice, you have to use an alias for phpmyadmin

NameVirtualHost 10.100.106.89
<VirtualHost 10.100.106.89>
        DocumentRoot /var/www/html/dev/novared_soporte/branches/v0.3/soporte
        ServerName 10.100.106.89
        Alias /phpmyadmin /var/www/html/phpmyadmin    
        #you need to explicitly allow access, since your alias is outside of your document root
        <Directory /var/www/html/phpmyadmin>
                Order allow,deny
                Allow from all
        </Directory>
</VirtualHost>
<VirtualHost 10.100.106.90>
        ServerName 10.100.106.90
        DocumentRoot /var/www/html
</VirtualHost>

This will only allow access via 10.100.106.89/phpmyadmin, no other virtual hosts.

This is perhaps a solution, best to just use the Include directive to include the apache that come with phpmyadmin

share|improve this answer

When you define a IP address as a NameVirtualHost, the apache server is expecting the browser to pass the domain domain associated with that host to determine which document root to serve.

An example would be something like:

NameVirtualHost 10.100.106.89

<VirtualHost 10.100.106.89>
        DocumentRoot /var/www/html/dev/novared_soporte/branches/v0.3/soporte
        ServerName mydomain.com
        ServerAlias www.mydomain.com
</VirtualHost>
<VirtualHost 10.100.106.89>
        DocumentRoot /var/www/html/phpmyadmin
        ServerName phpmyadmin.mydomain.com
</VirtualHost>
<VirtualHost 10.100.106.90>
        ServerName 10.100.106.90
        DocumentRoot /var/www/html
</VirtualHost>

Your apache will serve the first document root when a user visits mydomain.com or www.mydomain.com and the second phpmyadmin root when visiting phpmyadmin.mydomain.com. All 3 of those records would point to the same IP address. For any traffic that hits the same IP address without a matching ServerName or ServerAlias, it will default to the first VirtualHost.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.