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

Possible Duplicate:
Multiple vhosts on multiple IP addresses

I'm running Ubuntu 11.10, I have two IP addresses assigned to my VPS (Linode).

I have followed their guide to enable static addresses (can be found here: http://www.linode.com/wiki/index.php/Configure_Static_IPs)

The current situation is that I have 3 websites on that Linode and I want to set them up so site1 and site2 will use IP1 and site3 will use IP3

/etc/apache2/sites-available/site1.com

<VirtualHost 1.1.1.1:80>

  # Admin email, Server Name (domain name) and any aliases
  ServerAdmin info@site1.com
  ServerName  site1.com
  ServerAlias www.site1.com


  # Index file and Document Root (where the public files are located)
  DirectoryIndex index.html index.php
  DocumentRoot /home/site1/public_html


  # Custom log file locations
  LogLevel warn
  ErrorLog  /home/site1/public_html/log/error.log
  CustomLog /home/site1/public_html/log/access.log combined

</VirtualHost>

/etc/apache2/sites-available/site2.com

<VirtualHost 1.1.1.1:80>

  # Admin email, Server Name (domain name) and any aliases
  ServerAdmin info@site2.com
  ServerName  site2.com
  ServerAlias www.site2.com


  # Index file and Document Root (where the public files are located)
  DirectoryIndex index.html index.php
  DocumentRoot /home/site2/public_html


  # Custom log file locations
  LogLevel warn
  ErrorLog  /home/site2/public_html/log/error.log
  CustomLog /home/site2/public_html/log/access.log combined

</VirtualHost>

/etc/apache2/sites-available/site3.com

<VirtualHost 2.2.2.2:80>

  # Admin email, Server Name (domain name) and any aliases
  ServerAdmin info@site3.com
  ServerName  site3.com
  ServerAlias www.site3.com


  # Index file and Document Root (where the public files are located)
  DirectoryIndex index.html index.php
  DocumentRoot /home/site3/public_html


  # Custom log file locations
  LogLevel warn
  ErrorLog  /home/site3/public_html/log/error.log
  CustomLog /home/site3/public_html/log/access.log combined

</VirtualHost>

Relevant excerpt from ports.conf:

NameVirtualHost 1.1.1.1:80
NameVirtualHost 2.2.2.2:80
Listen 1.1.1.1:80
Listen 2.2.2.2:80

Problem is, I'm getting the content of site1 on all three sites. I have no idea why this is happening. Can you please assist?

Note: I have ran a2ensite for all 3 websites, no errors/warnings appear when i start the apache2 service.

share|improve this question

migrated from superuser.com Jan 3 '12 at 0:23

This question came from our site for computer enthusiasts and power users.

marked as duplicate by Chris S Feb 17 '12 at 16:25

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

2  
Are you able to run /etc/init.d/apache2 virtualhosts? That's the command on Gentoo, I'm not sure if it would work on Ubuntu as well but it's worth a shot. It should print out the entire vhost configuration as parsed from the config files, which will let you check directly whether your configurations are being parsed correctly. –  David Z Jan 2 '12 at 22:59
1  
What is the contents of the /etc/apache2/sites-enabled/ directory? –  becomingwisest Jan 3 '12 at 0:38
    
I think need clarity on following matters to get proper answer. 1. How configuration folder is setup in main httpd.conf file. Like whether it is *.conf or just *. 2. Where is this port.conf file located. –  Suku Jan 9 '12 at 2:04
    
This all looks correct. Did you remember to remove the default configuration files in sites-enabled? –  nicgrayson Jan 17 '12 at 22:24

1 Answer 1

Assuming your configuration is as you've put above, that's perfect. Make sure you have enabled all the sites you've put in to sites-available though, for example a2ensite site3.com. What that command does is create a symlink from the file in sites-available to sites-enabled. Apache by default on Ubuntu is configured to parse anything in sites-enabled but nothing from sites-available; sites-available is just a repository.

Also make sure you're not using *:80 anywhere in your VirtualHost directives.

Failing all of that, run apache2ctl -t -D DUMP_VHOSTS and see what it says your active VirtualHosts are. Post the output here.

share|improve this answer

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