Find the answer to your Linux question:
Results 1 to 5 of 5
Hello, so I have two sites, first.site.com and second.site.com and I am attempting to serve them both from the same server. Currently I have two the virtual hosts setup as ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1
    Just Joined!
    Join Date
    Jun 2005
    Posts
    70

    virtual hosts!


    Hello,

    so I have two sites, first.site.com and second.site.com and I am attempting to serve them both from the same server. Currently I have two the virtual hosts setup as follows:

    Code:
    NameVirtualHost *:80
    
    <VirtualHost *&#58;80>
       DocumentRoot /var/www/html/site1
    
        <Directory "/var/www/html/site1/">
    	Options Indexes FollowSymLinks
    	AllowOverride None
    	Order allow,deny
    	Allow from all
        </Directory>
    
       ServerName first.site.com
       ErrorLog logs/site1
       CustomLog logs/site1 common
    </VirtualHost>
    
    <VirtualHost *&#58;80>
        DocumentRoot /var/www/html/site2
    
        <Directory "/var/www/html/site2/">
    	Options Indexes FollowSymLinks
    	AllowOverride None
    	Order allow,deny
    	Allow from all
        </Directory>
    
        ServerName second.site.com
        ErrorLog logs/site2
        CustomLog logs/site2 common
    </VirtualHost>
    Now they are being served, they just are not being served correctly. If I go to first.site.com, a apache server config page comes up saying apache running correctly. But if i goto first.site.com/site1 the site is served as if it is starting from the beginning of the site. So, it seems that the documentroot is not being set properly in the <virtual host> directives. I have removed the documentroot directive from the conf file (from outside of the <virtualhost> directives) and also the servername directive.

    I am puzzled and have been working on this for about a day. Anyone have any idea?

  2. #2
    Just Joined!
    Join Date
    May 2005
    Posts
    52
    I had similar problems. I made a default deny VH first. Here part of mine, simplified.

    # First Virtual Host denies access to anyone
    # asking for a non-existant VH. Then, VHs specified.
    #
    NameVirtualHost *:80

    <VirtualHost *:80>
    ServerName default.only
    <Location />
    Order allow,deny
    Deny from all
    </Location>
    </VirtualHost>

    <VirtualHost *:80>
    DocumentRoot "/var/www/html/site1"
    ServerName site1.domain.com
    </VirtualHost>

    <VirtualHost *:80>
    DocumentRoot "/var/www/html/site2"
    ServerName www.site2.domain.com
    </VirtualHost>

  3. #3
    Linux Newbie
    Join Date
    Apr 2003
    Location
    Pontypridd, Wales
    Posts
    104
    But if i goto first.site.com/site1
    Not sure what you mean? Please explain.
    \"One World, One Web, One Program.\" -- Advertisement for Internet Explorer.
    \"Ein Volk, Ein Reich, Ein Fuehrer.\" -- Adolf Hitler.

  4. #4
    Just Joined!
    Join Date
    May 2005
    Posts
    52
    I took it to mean that the default apache site, or whatever site is configured as the first VH always comes up, wether he goes to www.site1.domain.com or www.site2.domain.com

  5. #5
    Just Joined!
    Join Date
    May 2005
    Posts
    52
    just try this first in your vhost.conf


    <VirtualHost *:80>
    ServerName default.only
    <Location />
    Order allow,deny
    Deny from all
    </Location>
    </VirtualHost>

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •