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.

I have a main domain www.example.com

I want to have a sub domain like this

www.pictures.example.com

I (think) have a choice of either:

  1. using virtual servers to match the different addresses (i.e. main domain and sub domain), to the same Apache server process
  2. using two seperate Apache servers (albeit on the same machine) to process requests independently

My questions are:

  1. What are the pros and cons of 1 and 2 above?
  2. How may I implement 1 or 2 (i.e. what are the steps required to implemet for each of the alternatives mentioned above)?
share|improve this question
    
Note: this is a great question but it already has dozens of answers which you'll quickly find by doing a search. –  Patrick R Jan 30 '10 at 19:09
add comment

1 Answer

You don't actually have a choice here. If you run two seperate apache instances, they can't both grab port 80. Using virtualhosts is the best solution.

Add the following to your apache configuration:

NameVirtualHost *:80

<VirtualHost *:80>
DocumentRoot /var/www/example.com
ServerName example.com
ServerAlias www.example.com

# the remainder of your example.com configuration goes here

</VirtualHost>

<VirtualHost *:80>
DocumentRoot /var/www/pictures.example.com
ServerName pictures.example.com
ServerAlias www.pictures.example.com

# the remainder of your pictures.example.com configuration goes here

</VirtualHost>
share|improve this answer
add comment

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.