Accelerator Django Install Guide
This tutorial is built off of The Django Setup Guide from the textuser wiki.
Alternative Instructions: Check the step-by-step Django, Accelerated tutorial from http://www.b-list.org/ for building a Django setup, using pkgsrc.
Upgrade packages
If you haven't already, upgrade the currently installed packages:
yes | sudo pkg-get upgrade
Install mod_python and MySQLdb (Python bindings)
I needed to first point my pkg-get to a different server as noted in this forum post. I'll included those instructions here as well.
first edit /opt/csw/etc/pkg-get.conf. For all the file edits in this tutorial you can use the nano command:
sudo nano /opt/csw/etc/pkg-get.conf
you need to change:
url=http://uma.textdrive.com/blastwave/unstable
in opt/csw/etc/pkg-get.conf to:
url=http://ibiblio.org/pub/packages/solaris/csw/unstable
then save the file and get the packages you need (you may need to run the update command again):
sudo pkg-get -i ap2_modpython sudo pkg-get -i pymysql
Install Django
These instructions are for the current SVN (trunk) copy of Django.
cd ~ svn co http://code.djangoproject.com/svn/django/trunk/ django_src sudo ln -s `pwd`/django_src/django /opt/csw/lib/python2.3/site-packages/django sudo ln -s `pwd`/django_src/django/bin/django-admin.py /opt/csw/bin/django-admin.py
add these lines to ~/.bashrc
alias python='/opt/csw/bin/python2.3' export PYTHONPATH=.:/opt/csw/lib/python2.3/site-packages/
when you are done run:
rehash
Setup Web user and group
sudo groupadd web sudo useradd -g web -s /usr/bin/bash web sudo passwd web
choose a password for the web user.
add media folder
I put my media in my /home/admin/ directory so I could easly access it over SFTP as the admin user. Here is how to do that:
first create a symlink between a media directory (create this in your /home/admin/ folder) and pythons site-packages:
sudo ln -s /home/admin/project_media /opt/csw/lib/python2.3/site-packages/project
you might also want to have the django admin media into this directory, I did this with another symlink:
sudo ln -s /opt/csw/lib/python2.3/site-packages/django/contrib/admin/media /home/admin/project_media/django
Setup Apache
In /opt/csw/apache2/etc/includes/dso.conf add:
LoadModule python_module libexec/mod_python.so
Add a Virtual Host file to /opt/csw/apache2/etc/virtualhosts/ (mine was in the format “project.com.conf”)
<VirtualHost xxx.xxx.xxx.xxx:80>
ServerName project.com
DocumentRoot /home/admin/project_media/
ErrorLog /var/log/project.com-error.log
CustomLog /var/log/project.com-access.log common
<Directory /home/admin/project_media>
allow from all
Options -Indexes
</Directory>
SetHandler python-program
PythonHandler django.core.handlers.modpython
SetEnv DJANGO_SETTINGS_MODULE project.settings
PythonDebug Off
<Location "/media">
SetHandler None
</Location>
Alias /media /home/admin/project_media
</VirtualHost>
Install Your Django Application
Put your Django application in the /opt/csw/lib/python2.3/site-packages/ directory.
if you setup your media the way I described above edit your project's settings.py file like this:
MEDIA_ROOT = '/home/admin/project_media/' ADMIN_MEDIA_PREFIX = 'http://project.com/media/django/' MEDIA_URL = 'http://project.com/media'
Restart Apache
sudo apachectl restart
