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'm trying to setup Apache virtual hosting in openSUSE, for a site called abc.com (example purposes only). When I go to http://localhost/mysites/abc.com/index.html on my browser, it opens correctly. However, when I go to http://abc.com, it doesn't open the said index.html file, which is located on /files/htdocs/mysites/abc.com/index.html. Instead, it opens the website of the TV network.

Here is my configuration:

default-server.conf:

DocumentRoot "/files/htdocs"
<Directory "/files/htdocs">
    Options None
    AllowOverride All
    Order allow,deny
    Allow from all
</Directory>
NameVirtualHost 127.0.0.1

Note: I didn't change the other default values.

vhost.conf inside vhosts.d/, included thru httdp.conf:

<VirtualHost 127.0.0.1>
 DocumentRoot /files/htdocs/mysites/abc.com
 servername abc.com
</VirtualHost>

Any ideas?

share|improve this question

2 Answers 2

up vote 2 down vote accepted

You need to make abc.com resolve to an IP address on which your webserver is listening. You appear to have everything on the loopback address 127.0.0.1. The easiest way to do this is to add abc.com to the line in your /etc/hosts file that defines localhost.

127.0.0.1    localhost abc.com

You say

However, when I go to http://abc.com, it doesn't open the said index.htmlHTML file, which is located on /files/htdocs/mysites/abc.com/index.html. Instead, it opens the website of the TV network.

If you really are using abc.com then this would not be a good thing. You'd be much better off using abc.lan or abc.local or similar.

share|improve this answer
    
It works! Thank you very much! –  Obay Ouano Sep 19 '11 at 9:15

Add the abc.com domain to your /etc/hosts file:

127.0.0.1   localhost.localdomain    abc.com
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.