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

I host several applications by IP in subfolders (http://ip/app). I would also now like to host a domain, I've been able to setup the virtual hosts so that the domain loads properly in it's document root however the rest of my applications stop working and point to the same virtual host document root of the domain.

How do I maintain my existing setup so all other requests behave the same?

share|improve this question

2 Answers 2

up vote 1 down vote accepted

It sounds like you want the server's IP to serve the content separate from the new VirtualHost you configured.

The Apache server will default to the DocumentRoot specified outside of the VirtualHost when accessing the IP unless configured otherwise. Specifying a VirtualHost with IP or a _default_ VirtualHost would also work.

If you require additional assistance, please provide additional information including your Apache configuration file in full.

share|improve this answer

If you had no VirtualHosts defined before, requests to the server will filter through the standard configuration in httpd.conf/apache2.conf.

This will mean that the hosts will bind to whatever's specified on the Listen line, and be served from the standard DocumentRoot specified in the Apache config file (by default this is /var/www/html on Redhat-based systems).

Once you start adding VirtualHost and NameVirtualHost directives, instead of following these conventions, requests to an unspecified ServerName will instead filter-through to the first specified VirtualHost stanza.

You can see this if you dump the Apache configuration with httpd -S (apache2 -S on debuntu):

[root@server]$ httpd -S
VirtualHost configuration:
wildcard NameVirtualHosts and _default_ servers:
*:80                   is a NameVirtualHost
     default server somesite.com (/etc/httpd/conf/httpd.conf:1050)
     port 80 namevhost somesite.com (/etc/httpd/conf/httpd.conf:1050)
     port 80 namevhost othersite.org (/etc/httpd/conf/httpd.conf:1074)
Syntax OK

You basically just need to define a VirtualHost which matches your default configuration, i.e set the DocumentRoot to whatever the main config DocumentRoot is, and configure the basic directives again so they're not overwritten. You need to place this VirtualHost as the first one in the Apache configuration.

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.