Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

having difficulties setting multiple domains

when I sudo a2ensite example2, it doesn't load regardless of whether exampe1 is enabled or disabled...and of course takes down example1 with itself . Here are the two files(example2 is a based on example1)

in sites-available I have example1 file

<VirtualHost *:80>
  ServerAdmin webmaster@localhost
  ServerName example1.com
  ServerAlias example1.com

  DocumentRoot /var/www/example1
  <Directory />
    Options FollowSymLinks
    AllowOverride None
  </Directory>
  <Directory /var/www/example1/>
    Options Indexes FollowSymLinks MultiViews
    AllowOverride All
    Order allow,deny
    allow from all
  </Directory>

  ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
  <Directory "/usr/lib/cgi-bin">
    AllowOverride None
    Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
    Order allow,deny
    Allow from all
  </Directory>

  ErrorLog /home/ubuntu/www/logs/example1/error.log

  # Possible values include: debug, info, notice, warn, error, crit,
  # alert, emerg.
  LogLevel warn

  CustomLog /home/ubuntu/www/logs/example1/access.log combined

    Alias /doc/ "/usr/share/doc/"
    <Directory "/usr/share/doc/">
        Options Indexes MultiViews FollowSymLinks
        AllowOverride None
        Order deny,allow
        Deny from all
        Allow from 127.0.0.0/255.0.0.0 ::1/128
    </Directory>

</VirtualHost>

and example2 file

<VirtualHost *:80>
  ServerAdmin webmaster@localhost
  ServerName example2.com
  ServerAlias example2.com

  DocumentRoot /var/www/example2
  <Directory />
    Options FollowSymLinks
    AllowOverride None
  </Directory>
  <Directory /var/www/example2/>
    Options Indexes FollowSymLinks MultiViews
    AllowOverride All
    Order allow,deny
    allow from all
  </Directory>

  ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
  <Directory "/usr/lib/cgi-bin">
    AllowOverride None
    Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
    Order allow,deny
    Allow from all
  </Directory>

  ErrorLog /home/ubuntu/www/logs/example2/error.log

  # Possible values include: debug, info, notice, warn, error, crit,
  # alert, emerg.
  LogLevel warn

  CustomLog /home/ubuntu/www/logs/example2/access.log combined

    Alias /doc/ "/usr/share/doc/"
    <Directory "/usr/share/doc/">
        Options Indexes MultiViews FollowSymLinks
        AllowOverride None
        Order deny,allow
        Deny from all
        Allow from 127.0.0.0/255.0.0.0 ::1/128
    </Directory>

</VirtualHost>

I got

NameVirtualHost *:80

in ports.conf

What am I missing?

share|improve this question

1 Answer 1

up vote 2 down vote accepted

You've really over complicated your configs. First of all. Look into http://httpd.apache.org/docs/2.0/vhosts/examples.html

Then, trim down those files to the bare minimum. Make sure to activate the sites and ensure the directories exist. That should do the trick. Also, don't forget to reload apache after all of that.

share|improve this answer
    
Surely there many different templates, but I'm using the defaults since they worked great with single site. But is there actually something wrong with these ? –  dobata Feb 26 '12 at 17:40
1  
There isn't anything obvious wrong with them. They're just overly complicated. It's usually advisable to start with a simple vhost and build it out as you need to. Focus on getting the sites working, then adding all those 'new-fangled' functions to it. –  Publiccert Feb 26 '12 at 17:44
    
yep taking to the bare essentials ServerAdmin, ServerAdmin, ServerAdmin and DocumentRoot worked out. –  dobata Feb 26 '12 at 19:11
    
Glad to hear it. Just scale up your configs now and see what wasn't working. Also, check your logs for some signs. –  Publiccert Feb 26 '12 at 19:25

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.