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.

What's the difference between these two cases:

<VirtualHost 127.0.0.1:80>
  ServerName localhost
  DocumentRoot "/home/sfprojects/jobeet/web"
  DirectoryIndex index.php
  <Directory "/home/sfprojects/jobeet/web">
    AllowOverride All
    Allow from All
  </Directory>
</VirtualHost>

and simply:

  DocumentRoot "/home/sfprojects/jobeet/web"
  DirectoryIndex index.php
  <Directory "/home/sfprojects/jobeet/web">
    AllowOverride All
    Allow from All
  </Directory>

Seems both work for me.

share|improve this question

1 Answer 1

up vote 1 down vote accepted

If you don't keep it in a virtualhost, then it will be applied to localhost automatically.

It should be inside VirtualHost if you are using named virtual hosts and when you want your virtualhost (i.e., jobeet) to serve a different path from the main host (i.e., localhost) Otherwise subdomain.domain.com will be the SAME site as domain.com

The Directory directive should be with a documentroot to define the access rights.

virtual hosts allow you to create "fake" sites like mysite.dev or host other domains from one server.

share|improve this answer
    
Can I put both maindomain and subdomain into virtual host? –  PHP Feb 10 '10 at 6:05
    
Yes, you can. I only have virtual hosts. –  ptman Feb 10 '10 at 9:43

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.