Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

multiple domains, multiple django projects, one server

Hi I'm new to apache and mod_wsgi and am trying to figure out how to configure both so that i can have www.example1.com use djangoproject1 and www.example2.com use djangoproject2.

I followed this tutorial to hook up example1.com to djangoproject1 and it works beautifully, but the tutorial doesn't exactly give the most detailed explanations for what is going on and why i need to do certain things.

what i have so far:

1) a dns zone for example2.com pointing to the server ip

2) installed python environment and django and started a new django project for djangoproject2 per the instuctions on the tutorial

I'm pretty sure i'm going to have to create a new wsgi config file and add a site configuration in /etc/apache2/sites-available/ called example2.com and then enable it, but i'm not sure about what else i'd need to do.

like image 705
Derick F Avatar asked Dec 21 '25 00:12

Derick F


1 Answers

You can have 2 virtual hosts in your apache configuration.

The first virtual host on (default) - port 80 second one on port 81

In the virtual host, you can specify it this way:

NameVirtualHost *:80

<VirtualHost *.80>
   DocumentRoot django_project_1_path
   .... other config
   WSGIScriptAlias / path_to_wsgi_config_1
</VirtualHost>

NameVirtualHost *:81

<VirtualHost *.81>
   DocumentRoot django_project_2_path
   .... other config
   WSGIScriptAlias / path_to_wsgi_config_2
</VirtualHost>
like image 185
karthikr Avatar answered Dec 23 '25 15:12

karthikr



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!