I have been attempting to configure two separate Django applications on a single server such that they'll be utilized at different URL's...while using below config, I'm able to access the very first application, but I am baffled at how you can range from the setup for that second application. The admin media can also be not loaded whatsoever

NameVirtualHost *:8032

ServerName localhost ServerAdmin website owner@example.com

 DocumentRoot "/usr/local/www/djcode/test"
 <Directory "/usr/local/www/djcode/test">
     Options +ExecCGI
     Order allow,deny
     Allow from all
 </Directory>
 Alias /site_media "/usr/local/www/djcode/test/site_media/"

 Alias /media "/usr/local/www/djcode/test/site_media/media/"
 WSGIDaemonProcess test user=www group=www processes=2 threads=5
 WSGIProcessGroup test
 AddHandler wsgi-script .wsgi
 RewriteEngine On
 RewriteCond %{REQUEST_FILENAME} !-f
 RewriteRule ^(.*)$ /test.wsgi/$1 [QSA,L]

ServerName localhost ServerAlias localhost DocumentRoot "/usr/local/world wide web/apache22/data"

Make two configuration files in /etc/apache2/sites-available folder. Provide them with proper logical names based on your sites (e.g. example1.com , example12.com etc). Use a2ensite command make it possible for each of them and restart your apache server.

All of your config file need to look something similar to this:

<Virtualhost *:8032>
ServerName localhost 
ServerAdmin webmaster@example.com
DocumentRoot "/usr/local/www/djcode/test"
 <Directory "/usr/local/www/djcode/test">
     Options +ExecCGI
     Order allow,deny
     Allow from all
 </Directory>
 Alias /site_media "/usr/local/www/djcode/test/site_media/"

 Alias /media "/usr/local/www/djcode/test/site_media/media/"
 WSGIDaemonProcess test user=www group=www processes=2 threads=5
 WSGIProcessGroup test
 AddHandler wsgi-script .wsgi
 RewriteEngine On
 RewriteCond %{REQUEST_FILENAME} !-f
 RewriteRule ^(.*)$ /test.wsgi/$1 [QSA,L]
 </Virtualhost *:8032>

You'll should also accumulate some directives for everyone static content. Serving static content from apache has overhead so it will be a much better idea should you server it with a couple lightweight webserver for example Lighttpd or Nginx and fasten to apache using reverse proxy for everyone the django based content. Here is a tutorial on using NginX

As you are using mod_wsgi, you are able to run each site as different user too to ensure that a couple of them might not access each other peoples data. This really is helpful when the two sites fit in with different stakeholders.

It's not obvious whether you would like them to both be located underneath the same VirtualHost or otherwise. Others go off and told you to employ separate VirtualHost's but that is not necessary and it is possible underneath the same VirtualHost. Some have given a configuration using mod_python whenever you were really using mod_wsgi. Additionally you technically did not require the Alias directives for that static media, although in which you saved them might need to change based on URL you would expect to have the ability to use to gain access to them.

That stated, for the current configuration, since you used AddHandler to map .wsgi files you are able to already host multiple programs, you'd simply need to create multiple .wsgi files within the document directory and employ the right Hyperlink to access them. Further configuration could be included to avoid requiring to specify the '.wsgi' extensions within the URL.

I'm able to provide a proper answer should you choose the next:

  • Say whether they should be underneath the same VirtualHost.

  • Say what URL inside the VirtualHost each distinct application ought to be accessible as.

  • Say what media URL ought to be employed for each distinct application.

  • Say whether each should run inside a separate process, or whether them running in various sub interpreters of the identical process is sufficient. Running in separate processes allows each to become restarted individually when creating code changes.