3

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)?
  • 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
1

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>

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.