PDA

View Full Version : Quick Apache2 VirtualHost question



autogun
April 24th, 2009, 09:20 AM
Howdy all,

I have a VirtualHosts configured in my httpd.conf file.

NameVirtualHost MY_IP_ADDRESS

<VirtualHost MY_IP_ADDRESS>
ServerName subdomain.domain.com
DocumentRoot /path/to/phpmyadmin
</VirtualHost>
So every time I browse to 'subdomain.domain.com' it points me to /path/to/phpmyadmin

How can I configure Apache so each time i come directly to MY_IP_ADDRESS it will point me to Apache's DefaultRoot and not to the VirtualHost?

mrsteveman1
April 24th, 2009, 09:53 AM
You need to have a default vhost setup to serve requests that aren't matched by another specific vhost. Apache comes with one by default, is it not still there? It should be in /etc/apache2/sites-available/default or something similar.

autogun
April 24th, 2009, 10:58 AM
Found what I was looking for -


<VirtualHost _default_:80>
DocumentRoot "/usr/local/apache2/htdocs/"
...
</VirtualHost>

sahabcse
April 24th, 2009, 11:04 AM
Hi

Pls do the folowing

vim /etc/apache2/sites-available/virtualdomain.com

NameVirtualHost xx.xx.xxx.xxx
<VirtualHost virtualdomain.com >
ServerAdmin webmaster@virtualdomain.com
DocumentRoot /var/www/virtual/
ServerName virtualdomain.com
ServerAlias www.virtualdomain.com
</VirtualHost>

ln -s /etc/apache2/sites-available/virtualdomain.com /etc/apache2/sites-enabled

a2ensite virtualdomain.com

autogun
April 24th, 2009, 11:07 AM
Thank you but I already found what I was looking for in post #3. =D