I am slowly working all of this out and the first 3 or 4 times I tried to setup Django on our cPanel server I kept getting the same 403 Forbidden error. I scrapped everything and started from scratch as I wanted to use Python 2.7 instead of 2.5. Now I am receiving completely different errors I've never encountered before. I used the below post on the cpanel forums as a guide, making my own changes as necessary, documenting my full progress along the way. The new error lists in the browser as a 200 error which has me confused as I thought a 200 meant everything was good. I'm re-checking everything for a typo but I really have no idea what's causing this.
http://forums.cpanel.net/f5/django-python-cpanel-71229-p2.html#post439009 -- You received this message because you are subscribed to the Google Groups "Django users" group. To view this discussion on the web visit https://groups.google.com/d/msg/django-users/-/bl1zmYqAQUoJ. To post to this group, send email to django-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
// Server Setup \\ \\==============// // download and innstall Python 2.7 // file URL http://www.python.org/ftp/python/2.7.3/Python-2.7.3.tgz tar -xvzf Python-2.7.3.tgz cd Python-2.7.3 ./configure --enable-shared --prefix=/opt/python2.7 make install // alias python so always opens 2.7 cd /root echo alias python='/opt/python2.7/bin/python' >> .bash_profile // fix LD_LIBRARY_PATH echo /opt/python2.7/lib > /etc/ld.so.conf.d/python2.7.conf ldconfig / install setuptools // URL http://peak.telecommunity.com/dist/ez_setup.py python ez_setup.py / install MySQLdb for Python // http://pypi.python.org/pypi/MySQL-python/1.2.3 tar -xvzf MySQL-python-1.2.3.tar.gz cd MySQL-python-1.2.3 python setup.py build python setup.py install // test import python import sqlite3 import MySQLdb quit() // install mod_wsgi // http://modwsgi.googlecode.com/files/mod_wsgi-3.4.tar.gz tar -xvzf mod_wsgi-3.4.tar.gz cd mod_wsgi-3.4 ./configure --with-apxs=/usr/local/apache/bin/apxs --with-python=/opt/python2.7/bin/python make make install // In WHM | Apache Setup, in Pre VirtualHost Include, add: LoadModule wsgi_module /usr/local/apache/modules/mod_wsgi.so AddHandler wsgi-script .wsgi WSGISocketPrefix run/wsgi // create a “run” directory for Apache's .pid files mkdir -p /usr/local/apache/run chmod a+w /usr/local/apache/run =============== Client Setup =============== // Add to user's .bash_profile: # Use python 2.7 alias python='/opt/python/bin/python' # Set python path export PYTHONPATH='$PYTHONPATH:/home/[username]/sites/[domain.com]' // Prepare the project folder mkdir -p /home/[user]/sites/[domain] cd /home/[user]/sites/[domain] svn co http://code.djangoproject.com/svn/django/trunk/ django-trunk =====OR===== svn co http://code.djangoproject.com/svn/django/branches/releases/1.4.X/ django ln -s django-trunk/django django mkdir .python-eggs chmod 777 .python-eggs /home/[username]/sites/domain.com/django/bin/django-admin.py startproject foobar cd /home/[username] chown -R [username]: sites // test imports as user python import MySQLdb import sqlite3 import django quit() // create bootstrap nano /home/username/public_html/something.wsgi // contents of bootstrap: #!/opt/python2.7/bin/python import os, sys sys.path.insert(0,'/home/username/sites/domain.com') os.environ['DJANGO_SETTINGS_MODULE'] = 'foobar.settings' os.environ['PYTHON_EGG_CACHE'] = '/home/username/sites/domain.com/.python-eggs' import django.core.handlers.wsgi application = django.core.handlers.wsgi.WSGIHandler() // setup vhost mkdir -p /usr/local/apache/conf/userdata/std/2/username/domain.com nano /usr/local/apache/conf/userdata/std/2/username/domain.com/vhost.conf // contents of vhost.conf <IfModule mod_alias.c> Alias /robots.txt /home/username/sites/domain.com/foobar/media/robots.txt Alias /site_media /home/username/sites/domain.com/foobar/media Alias /admin_media /home/username/sites/domain.com/django/contrib/admin/media </IfModule> <IfModule mod_wsgi.c> # See the link below for an introduction about this mod_wsgi config. # http://groups.google.com/group/modwsgi/browse_thread/thread/60cb0ec3041ac1bc/2c547b701c4d74aa WSGIScriptAlias / /home/username/public_html/something.wsgi WSGIDaemonProcess [username] processes=7 threads=1 display-name=%{GROUP} WSGIProcessGroup [username] WSGIApplicationGroup %{GLOBAL} </IfModule> # This fixes the broken ErrorDocument directive we inherit that breaks auth # if we use a WSGI app. ErrorDocument 401 "Authentication Error" ErrorDocument 403 "Forbidden" // include the vhost in apache /scripts/verify_vhost_includes /scripts/ensure_vhost_includes --user=username // restart django just to be sure touch /home/username/public_html/something.wsgi