Last updated on 2005-11-13
Several notes before we start: if you just want to play around with Django, you can skip this whole document. Django comes with its own web server for development purposes. The best thing you can do in this scenario is check out the official documentation and follow these instructions.
If you’d like to install Django and try deploying it locally on the standard OS X Apache you can use it with the FastCGI handler.
The guide below is for trying out Django with the mod_python handler.
This is a rough guide to get Django working on a Mac OS X (10.4.3 as I write) machine with Apache 2 and mod_python 3.1.4. It involves lots of fiddling with the command line and it assumes you know what you are doing.
Be sure to have installed a recent build of Django. I recommend
using the development version, by checking out the head revision of
the Subversion trunk: svn co
http://code.djangoproject.com/svn/django/trunk/
This is the stuff I had already installed on my machine before starting (your mileage may vary):
/usr/local/bin/pythonI then had to install Apache 2 and mod_python 3.1.4. I tried using the default Apache 1.3 install which comes with Tiger, together with mod_python 2.7 which I already had installed, but they didn’t work with Django. So:
Download and install Apache 2.0.54 (thanks, Scott Sanders)
cd ~/Desktop
wget http://www.apache.org/dist/httpd/httpd-2.0.54.tar.gz
gunzip httpd-2.0.54.tar.gz
tar xvf httpd-2.0.54.tar
cd httpd-2.0.54
./configure –-enable-so –-with-mpm=worker
make
sudo make install
This will install Apache 2 in /usr/local/apache2
Download and install mod_python 3.1.4
cd ~/Desktop
wget
http://www.apache.org/dist/httpd/modpython/mod_python-3.1.4.tgz
gunzip mod_python-3.1.4.tgz
tar xvf mod_python-3.1.4.tar
cd mod_python-3.1.4
./configure --with-apxs=/usr/local/apache2/bin/apxs
--with-python=/usr/local/bin/pythonmakesudo make installThen activate it, by editing
/usr/local/apache2/conf/httpd.conf and writing in it
the following line: LoadModule python_module
modules/mod_python.so
Now that you have Apache 2 and mod_python, you can move on to
Django. Follow along the first
and second
tutorial and create the project myproject inside
the ~/Sites directory.
/etc/hosts file and add a line like this
one: 127.0.0.1 django.loc
/usr/local/apache2/conf/httpd.conf file and
add the following at the end of it (remember to edit [YOUR
USER NAME]):
<VirtualHost django.loc>
DocumentRoot /Users/[YOUR USER NAME]/Sites
<Location /admin/>
SetHandler mod_python
PythonHandler django.core.handlers.modpython
PythonPath sys.path+['/Users/[YOUR USER NAME]/Sites']
SetEnv DJANGO_SETTINGS_MODULE myproject.settings.admin
</Location>
</VirtualHost>
sudo /usr/sbin/apachectl stop
sudo /usr/local/apache2/bin/apachectl start
Point your browser to django.loc/admin/ and you should see the following screen:
That should be pretty much it: now you can go on and create the users for the admin section, as detailed towards the end of the second django tutorial.
If it worked for you, share and enjoy. If it didn’t, well, I’m sorry
I haven’t been of any help. The best thing you can do is log on to
the #django IRC channel
on irc.freenode.net and ask for help.