Virtual Server config help

Help
Chris
2008-08-20
2013-05-22
  • Chris
    Chris
    2008-08-20

    I'm trying to setup my server to handle more then one virtual server to run 2 or more other websites.  If I configure one virtual server to handle "any" address it works(but the second will also use the those settings).  If I try to set them up to handle their own address it defaults to /var/www/html/

    NameVirtualHost ###.###.###.###:80
    <VirtualHost www.server1.com:80>
    NameVirtualHost www.server1.com
    DocumentRoot /var/www/vhosts/server1.com/httpdocs/
    <Directory "/var/www/vhosts/server1.com/httpdocs/">
    allow from all
    Options +Indexes
    </Directory>
    ServerName server1.com
    ServerAlias www.server1.com
    </VirtualHost>

    <VirtualHost www.server2.com:80>
    NameVirtualHost www.server2.com
    DocumentRoot /var/www/vhosts/server2.com/httpdocs/
    ServerName server2.com
    ServerAlias www.server2.com
    <Directory "/var/www/vhosts/server2.com/httpdocs/">
    allow from all
    Options +Indexes
    </Directory>
    </VirtualHost>

    The end result is I'd like to have server1.com and server2.com be seperate sites running on the same server, right now I can only get one or the other to work by setting one of them to use "any" address.  Any help would be appreciated.

     
    • Anthony Cagle
      Anthony Cagle
      2008-08-20

      Try the following:

      NameVirtualHost ###.###.###.###:80
      <VirtualHost ###.###.###.###:80>
      ServerName server1.com
      ServerAlias www.server1.com
      DocumentRoot /var/www/vhosts/server1.com/httpdocs/
      <Directory "/var/www/vhosts/server1.com/httpdocs/">
      allow from all
      Options +Indexes
      </Directory>
      </VirtualHost>

      <VirtualHost ###.###.###.###:80>
      ServerName server2.com
      ServerAlias www.server2.com
      DocumentRoot /var/www/vhosts/server2.com/httpdocs/ 
      <Directory "/var/www/vhosts/server2.com/httpdocs/">
      allow from all
      Options +Indexes
      </Directory>
      </VirtualHost>

       
      • Chris
        Chris
        2008-08-20

        I tried exactly what you posted and I'm still having the same problem. I also tried with the alias's not having "http://"  If I set one of them to "any" aka * then that one works but the other will not.  Is there another apache setting outside the Virtual host settings that is messing this up?

         
    • Anthony Cagle
      Anthony Cagle
      2008-08-20

      Please note that html was inserted in my previous message, http:// should not be there and was added by the board

       
    • Chris
      Chris
      2008-08-20

      Also I didn't mention both domains are sharing the same ip address though I don't think that should matter.