What you have to install
sudo apt-get install python-mysqldb //make python be able to connect to mysql serverwget https://www.djangoproject.com/download/1.5.1/tarball/
tar xzvf Django-1.5.1.tar.gz
cd Django-1.5.1
sudo python setup.py install
install mysql and apache2
sudo apt-get install libapache2-mod-wsgi //to host your python project
These are pretty much what you need to install.
Files you need to create
In my case, create /home/ubuntu/firstweb.wsgiimport os
import sys
sys.path = ['/var/www/firstweb'] + sys.path
os.environ['DJANGO_SETTINGS_MODULE'] = 'firstweb.settings'
import django.core.handlers.wsgi
application = django.core.handlers.wsgi.WSGIHandler()
Another file you need to create is /etc/apache2/sites-available/firstweb
WSGIScriptAlias / /home/ubuntu/firstweb.wsgi
ServerAdmin webmaster@localhost
ServerName firstweb.com
Alias /static /var/www/firstweb/static/
Order allow,deny
allow from all
ErrorLog ${APACHE_LOG_DIR}/error.log
Note: remember to change the corresponding directory to suit your server. Here I list the full path of the files on my computer is only as a showcase such that you know where the files are.
Enable the sites and Restart Apach2 server
a2ensite /etc/apache2/sites-available/freeweb/etc/init.d/apache2 restart
Having problems?
if you have any problems to get Django runing, one quick way to debug it out is to check out your log file as follows:less /var/log/apache2/error.log
Still cannot follow it?
watch the video and be patient since this is a 30+m long video.
Post a Comment