Deploying a Django application in a virtual Ubuntu Server
- by mfsaint
I have a virtualbox machine running Ubuntu Server 10.04LTS. My intention is to this machine to work like a VPS, this way I can learn and prepare for when I get a VPS service.
Apache+mod_wsgi for deploying the Django app seems the right choice to me.
I have the domain (marianofalcon.com.ar) but nothing else, no DNS.
The problem is that I'm pretty lost with all the deployment stuff. I know how to configure mod_wsgi(with the django.wsgi file) and apache(creating a VirtualHost).
Something is missing and I don't know what it is. I think that I lack networking skills ant that's the big problem. Trying to host the app on a virtualbox adds some difficulty because I don't know well what IP to use.
This is what I've got:
file placed at: /etc/apache2/sites-available:
NameVirtualHost *:80
<VirtualHost *:80>
ServerAdmin [email protected]
ServerName www.my-domain.com
ServerAlias my-domain.com
Alias /media /path/to/my/project/media
DocumentRoot /path/to/my/project
WSGIScriptAlias / /path/to/your/project/apache/django.wsgi
ErrorLog /var/log/apache2/error.log
LogLevel warn
CustomLog /var/log/apache2/access.log combined
</VirtualHost>
django.wsgi file:
import os, sys
wsgi_dir = os.path.abspath(os.path.dirname(__file__))
project_dir = os.path.dirname(wsgi_dir)
sys.path.append(project_dir)
project_settings = os.path.join(project_dir,'settings')
os.environ['DJANGO_SETTINGS_MODULE'] = 'myproject.settings'
import django.core.handlers.wsgi
application = django.core.handlers.wsgi.WSGIHandler()