Solved

Virtual Hosts on Apache2 and server root

Posted on 2004-08-05
4
1,066 Views
Last Modified: 2013-11-18
Hi everyone
I have apache2 installed in /usr/local/apache. In the conf dir is my main httpd.conf file. It's virtual host settings are defined as:

NameVirtualHost *:80
Include /usr/local/apache/conf/vhosts/*.conf

In the directory conf/vhosts I have the virtual hosts defined in their seperate files, a typical site looks like this:

<VirtualHost *:80>
ServerName website.com
ServerAlias www.website.com 
DocumentRoot /www/sites/w/website/public_html
ScriptAlias /cgi-bin/ /www/sites/w/website/cgi-bin
ErrorLog /www/sites/w/website/logs/error.log
CustomLog /www/sites/w/website/logs/access.log combined
Alias /stats /www/sites/w/website/stats
<Directory />
Options Includes Indexes FollowSymLinks
</Directory>
</VirtualHost>

The problem is that when I type the the ip address of the server directly into the browser the first alphabetical virtual host site is displayed. e.g if I have a-site.conf, b-site.conf, c-site.conf etc in the vhosts folder then a-site.conf is displayed when the IP Address is typed in.

does anyone know why this would happen?

Thanks
0
Comment
Question by:fast74
4 Comments
 
LVL 6

Accepted Solution

by:
philjones85 earned 50 total points
ID: 11729261
It probably doesn't know which virtual host to send it to, so it sends it to the first by default.

I've always setup a "default" configuration in the main httpd.conf file which I always get when typing the ip directly.

If you want a specific virtual host to come up when the ip is typed, try adding that as a server alias
  ServerAlias www.website.com  XXX.XXX.XXX.XXX
0
 
LVL 15

Assisted Solution

by:periwinkle
periwinkle earned 50 total points
ID: 11743077
philjones is correct - Apache serves the first page that matches the IP address if an IP address is given in the URL.

If a-site.conf, b-site.conf, c-site.conf all have the same IP address specification, then Apache has no way of determining which site to serve.  If you have unique IP addresses, then you can do:

<VirtualHost xxx.xxx.xxx.xxx:80>

where xxx.xxx.xxx.xxx is the unique IP address.  
0

Featured Post

Edgartown IT Case Study

Learn about Edgartown's quest to ensure the safety and security of the entire town's employee and citizen data. Read the case study!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Hyper V Cluster/Storage Question 5 73
Company website 6 44
asp Google Map 2 55
Amazon Glacier backup 6 37
By default, Carbonite Server Backup manages your encryption key for you using Advanced Encryption Standard (AES) 128-bit encryption. If you choose to manage your private encryption key, your backups will be encrypted using AES 256-bit encryption.
The Delta outage: 650 cancelled flights, more than 1200 delayed flights, thousands of frustrated customers, tens of millions of dollars in damages – plus untold reputational damage to one of the world’s most trusted airlines. All due to a catastroph…
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.
Video by: Mark
This lesson goes over how to construct ordered and unordered lists and how to create hyperlinks.

713 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question