Sam Hammamy
Sam Hammamy

Reputation: 11017

Apache2 serving multiple sites on one IP

I have two domains that point to the same IP, which is an Ubuntu VPS with apache2. I need to server both domains out of apache. I've read the config manual at http://httpd.apache.org/docs/2.0/vhosts/examples.html#purename and added the following two files:

1) webikenconsultants

<VirtualHost *:80>
    ServerName www.webikenconsultants.com
    DocumentRoot /var/www/coming_soon
    <Directory  /var/www/coming_soon>
    Order allow,deny
    Allow from all
    </Directory>
</VirtualHost>

2) webikentrading

<VirtualHost *:80>
    ServerName www.webikentrading.net
    #WSGIScriptAlias / /opt/webikentrading/current/src/webikentrading/django.wsgi
    DocumentRoot /var/www
    <Directory /var/www >
    Order allow,deny
    Allow from all
    </Directory>
</VirtualHost>

As you can see, webikentrading is a Django project, but for the time being, just to get things working, I am serving it as a static site, until I figure out what's going on. The problem is that when I visit either domain, only the coming_soon content shows up, what am I doing wrong??

Upvotes: 0

Views: 1191

Answers (1)

Sam Hammamy
Sam Hammamy

Reputation: 11017

I figured out the problem. The vhost entry points to www.webikentrading.net however, the browser was using webikentrading.net so i added a separate entry for just webikentrading.net and all is fine

EDIT:

This is quite old, but I have a new and improved way of doing this now and I hope it can help someone else.

Use the mod_wsgi daemon directive which allows you to add the python path of your choice. Example config is:

<VirtualHost *:80>
    ServerName qa.webiken.net
    ....
    WSGIDaemonProcess qa.webiken.net processes=2 threads=15 python-path=/usr/local/pythonenv/QA-WEBIKEN-1/lib/python2.5/site-packages display-name=%{GROUP}
    WSGIProcessGroup  qa.webiken.net
</VirtualHost>

<VirtualHost *:80>
    ServerName staging.webiken.net
    ....
    WSGIDaemonProcess staging.webiken.net processes=2 threads=15 python-path=/usr/local/pythonenv/staging-WEBIKEN-1/lib/python2.5/site-packages display-name=%{GROUP}
    WSGIProcessGroup  staging.webiken.net
</VirtualHost>

Upvotes: 1

Related Questions