0

I am tring to configure apache virtual host for my computer. But i am facing problem in doing so.

i have made required changes in my C:\WINDOWS\system32\drivers\etc\hosts then C:\xampp\apache\conf\extra\httpd-vhosts.conf I added the following lines in httpd-vhosts.conf

########################Virtual Hosts Config below##################

NameVirtualHost 127.0.0.1

    <VirtualHost localhost>
        ServerName localhost
        DocumentRoot "C:\xampp\htdocs"
        DirectoryIndex index.php index.html

        <Directory "C:\xampp\htdocs">            
            AllowOverride All            
        </Directory>
    </VirtualHost>


    <VirtualHost virtual.cloudse7en.com>
        ServerName virtual.cloudse7en.com
        DocumentRoot "C:\development\virtual.cloudse7en.com\httpdocs"
        DirectoryIndex index.php index.html

        <Directory "C:\development\virtual.cloudse7en.com\httpdocs">
            Options Indexes FollowSymLinks Includes ExecCGI
            AllowOverride All
            Order allow,deny
            Allow from all
        </Directory>
    </VirtualHost>

    <VirtualHost virtual.app.cloudse7en.com>
        ServerName virtual.app.cloudse7en.com
        DocumentRoot "C:\development\virtual.app.cloudse7en.com\httpdocs"
        DirectoryIndex index.php index.html

        <Directory "C:\development\virtual.app.cloudse7en.com\httpdocs">
            Options Indexes FollowSymLinks Includes ExecCGI
            AllowOverride All
            Order allow,deny
            Allow from all
        </Directory>
    </VirtualHost>


########################################################################

I started my xampp and tried http://localhost in a browser. This works and open up http://localhost/xampp/

but when i try http:http://virtual.app.cloudse7en.com it again opens up http://virtual.app.cloudse7en.com/xampp/

I do not understand the reason. Also i have a windows vista 64 bit, operating system. Do i need to make some other changes too?

Regards Zee

2
  • There is probably something in a .htaccess file inside your document root (C:\development\virtual.app.cloudse7en.com\httpdocs)
    – Edwin V.
    Sep 21, 2009 at 20:33
  • This might be too trivial. But.., Did you make sure to uncomment the include line in httpd.conf for vhosts file?
    – vpram86
    Sep 22, 2009 at 6:40

3 Answers 3

1

The part after <VirtualHost has to match the part after after NameVirtualHost in every case. (This feature makes it possible to have multiple domains on multiple IP address on one machine.) In your case:

<VirtualHost 127.0.0.1>
1

Expanding on Jason's answer, Apache uses a HTTP header from the client that has to match the ServerName variable inside a given config block; the config block must match the same IP interface. The most typical way to write what you're doing is this:

NameVirtualHost *:80

<VirtualHost *:80>
  ServerName default.server.com
  ...
</VirtualHost>

<VirtualHost *:80>
  ServerName virtual-1.server.com
  ...
</VirtualHost>

<VirtualHost *:80>
  ServerName virtual-2.server.com
  ...
</VirtualHost>

If you want to specifically use 127.0.0.1 that's fine, works as well. However, there's a more interesting way to do this that doesn't involve using your hosts file - different ports. It might look like:

Listen 80
Listen 81
Listen 82

NameVirtualHost *:80
NameVirtualHost *:81
NameVirtualHost *:82

<VirtualHost *:80>
  ServerName default.server.com
  ...
</VirtualHost>

<VirtualHost *:81>
  ServerName virtual-1.server.com
  ...
</VirtualHost>

<VirtualHost *:82>
  ServerName virtual-2.server.com
  ...
</VirtualHost>

Then all you need to do is web browse using different ports:

http://localhost:80/
http://localhost:81/
http://localhost:82/

...and each one will take you to that config block.

0

Check the ServerRoot in httpd.cnf.

Also check this out: http://www.apachefriends.org/f/viewtopic.php?f=17&t=29980&start=0&sid=fbb155f1e06ce2c9564702936fe0c931&view=print

You must log in to answer this question.