0

I'm a new in all about Django deployment, i'm actually try to deploy my first app in my server, but i want do this in a subdomain and, in a future, in others subdomains deploy more apps.

Exist any guide for do this for Django 1.6?

I've seen a lot of blogs for deploy Django with mod_wsgi but are so old (2010, 2011, 2012, etc) and are only for deploy only one app.

I've seen too that some people use Virtual Host and others use httpd configuration without Virtual Host, and that is so confused for me.

Its more easy if i use GUnicorn and Nginx?

Which solution is better?

Centos 6.5
Python 2.7 
Django 1.6.2 

This is my configuration that isn't work:

httpd.conf

NameVirtualHost *:80

holding.conf

<VirtualHost *:80>

     ServerName www.myserver.com
     ServerAlias www.myserver.com/holding

     DocumentRoot /var/www/html/holding/src
     ErrorLog /var/www/html/holding/log/holding.log
     CustomLog /var/www/html/holding/log/access.log combined
     ServerAdmin helio.gutierrez@myserver.com

     WSGIScriptAlias / /var/www/html/holding/src/wsgi.py


     Alias /robots.txt /var/www/html/holding/src/robots.txt
     Alias /favicon.png /var/www/html/holding/src/static/ico/favicon.png
     Alias /static/admin/ /usr/local/lib/python2.7/site-packages/django/contrib/admin/static/admin
     Alias /static/ /var/www/html/holding/src/static
     Alias /media/ /var/www/html/holding/src/media

     <Directory /var/www/html/holding/src>
         Order allow,deny
         Allow from all
     </Directory>

     <Directory /var/www/html/holding/src/media>
     Order deny,allow
         Allow from all
     </Directory>

     <Directory /var/www/html/holding/src/static>
         Order deny,allow
         Allow from all
     </Directory>

</VirtualHost>

wsgi.py

import os, sys
sys.path.append('/usr/local/lib/python2.7')
sys.path.append('/usr/local/lib/python2.7/site-packages/django')

sys.path.append('/var/www/html/holding')
sys.path.append('/var/www/html/holding/src')
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "src.settings")

#from django.core.wsgi import get_wsgi_application
#application = get_wsgi_application()

from django.core.handlers.wsgi import WSGIHandler

application = WSGIHandler()
Maxime Lorant
  • 34,607
  • 19
  • 87
  • 97
He2
  • 1
  • 2

1 Answers1

0

Here is a past Stack Overflow post where there is an example of adding multiple sites.

It is from 2009, but it should still work.

I personally used uwsgi with nginx, but gunicorn is really easy to setup too.

Community
  • 1
  • 1
user2707389
  • 817
  • 6
  • 12
  • Hi, Thanks for your answer, my problem is because i already have a web page in "myserver.com" and is for that reason i need work with a subdomain "www.example.com/myapp". My webpage isn't a Django page, is read only and i need my Django app in a subdomain. – He2 May 27 '14 at 16:49
  • Gotcha ! Just FYI, www.example.com/myapp is called a sub-directory. Sub-domain is myapp.example.com . Also, have you looked at a class-based view called templateview. It spits out static "read-only" page. So, you can deliver your root-domain with django as well. – user2707389 Jun 02 '14 at 14:44