<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Perplexed Labs &#187; cpanel</title>
	<atom:link href="http://blog.perplexedlabs.com/tag/cpanel/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.perplexedlabs.com</link>
	<description>web development war stories from the frontlines to the backend</description>
	<lastBuildDate>Mon, 16 May 2011 14:19:38 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.1.2</generator>
		<item>
		<title>Setup Python 2.5, mod_wsgi, and Django 1.0 on CentOS 5 (cPanel)</title>
		<link>http://blog.perplexedlabs.com/2008/11/10/setup-python-25-mod_wsgi-and-django-10-on-centos-5-cpanel/</link>
		<comments>http://blog.perplexedlabs.com/2008/11/10/setup-python-25-mod_wsgi-and-django-10-on-centos-5-cpanel/#comments</comments>
		<pubDate>Mon, 10 Nov 2008 15:53:56 +0000</pubDate>
		<dc:creator>Matt</dc:creator>
				<category><![CDATA[CSS]]></category>
		<category><![CDATA[Development]]></category>
		<category><![CDATA[Django]]></category>
		<category><![CDATA[Infrastructure]]></category>
		<category><![CDATA[Python]]></category>
		<category><![CDATA[centos]]></category>
		<category><![CDATA[cpanel]]></category>
		<category><![CDATA[mod_wsgi]]></category>

		<guid isPermaLink="false">http://www.perplexedlabs.com/?p=57</guid>
		<description><![CDATA[Please read the update to this article Setup Python 2.6.4, mod_wsgi 2.6, and Django 1.1.1 on CentOS 5.3 (cPanel) Installing Python 2.5 dependencies Install sqlite3: $ wget http://www.sqlite.org/sqlite-amalgamation-3.6.4.tar.gz $ tar xvfz sqlite-amalgamation-3.6.4 $ cd sqlite-amalgamation-3.6.4.tar.gz $ ./configure $ make $ make install Install Python 2.5 Download Python 2.5 source package, unzip, and enter working directory: [...]


Related posts:<ol><li><a href='http://blog.perplexedlabs.com/2009/11/15/setup-python-2-6-4-mod_wsgi-2-6-and-django-1-1-1-on-centos-5-3-cpanel/' rel='bookmark' title='Permanent Link: Setup Python 2.6.4, mod_wsgi 2.6, and Django 1.1.1 on CentOS 5.3 (cPanel)'>Setup Python 2.6.4, mod_wsgi 2.6, and Django 1.1.1 on CentOS 5.3 (cPanel)</a></li>
<li><a href='http://blog.perplexedlabs.com/2008/02/04/building-a-rails-capable-slice-from-scratch/' rel='bookmark' title='Permanent Link: Ruby On Rails and SliceHost Part 1: Initial Setup'>Ruby On Rails and SliceHost Part 1: Initial Setup</a></li>
<li><a href='http://blog.perplexedlabs.com/2009/01/13/installing-ruby-enterprise-edition-with-phusion-passenger/' rel='bookmark' title='Permanent Link: Installing Ruby Enterprise Edition with Phusion Passenger'>Installing Ruby Enterprise Edition with Phusion Passenger</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p><strong>Please read the update to this article <a href="http://blog.perplexedlabs.com/2009/11/15/setup-python-2-6-4-mod_wsgi-2-6-and-django-1-1-1-on-centos-5-3-cpanel/">Setup Python 2.6.4, mod_wsgi 2.6, and Django 1.1.1 on CentOS 5.3 (cPanel)</a></strong></p>
<h3>Installing Python 2.5 dependencies</h3>
<h4>Install sqlite3:</h4>
<blockquote><p>$ wget http://www.sqlite.org/sqlite-amalgamation-3.6.4.tar.gz<br />
$ tar xvfz sqlite-amalgamation-3.6.4<br />
$ cd sqlite-amalgamation-3.6.4.tar.gz<br />
$ ./configure<br />
$ make<br />
$ make install</p></blockquote>
<h3>Install Python 2.5</h3>
<h4>Download Python 2.5 source package, unzip, and enter working directory:</h4>
<blockquote><p>$ cd<br />
$ wget http://python.org/ftp/python/2.5/Python-2.5.tgz<br />
$ tar xvfz Python-2.5.tgz<br />
$ cd Python-2.5</p></blockquote>
<h4>Configure Python 2.5 so that we're not overwriting the system's python installation:</h4>
<blockquote><p>$ ./configure --prefix=/opt/python2.5 --with-threads --enable-shared</p></blockquote>
<h4>Make and install:</h4>
<blockquote><p>$ make<br />
$ make install</p></blockquote>
<h4>Add an alias to root's .bash_profile:</h4>
<blockquote><p>alias python='/opt/python2.5/bin/python'</p></blockquote>
<h4>Make a symbolic link:</h4>
<blockquote><p>$ ln -s /opt/python2.5/bin/python /usr/bin/python2.5</p></blockquote>
<h4>Configure ld to find your shared libs:</h4>
<blockquote><p>$ cat &gt;&gt; /etc/ld.so.conf.d/opt-python2.5.conf<br />
/opt/python2.5/lib <span style="color: #c0c0c0;">(hit enter)</span><br />
<span style="color: #c0c0c0;">(hit ctrl-d to return to shell)</span><br />
$ ldconfig</p></blockquote>
<h4>Test python 2.5 installation:</h4>
<blockquote><p>$ python</p></blockquote>
<p>You should get an interactive Python 2.5 session like:</p>
<blockquote><p>Python 2.5 (r25:51908, Nov  9 2008, 23:18:24)<br />
[GCC 4.1.2 20071124 (Red Hat 4.1.2-42)] on linux2<br />
Type "help", "copyright", "credits" or "license" for more information.</p>
<p>&gt;&gt;&gt;</p>
<p><span style="color: #c0c0c0;">Hit ctrl-d to exit</span></p></blockquote>
<h4>Install setuptools:</h4>
<blockquote><p>$ cd<br />
$ wget http://pypi.python.org/packages/2.5/s/setuptools/setuptools-0.6c9-py2.5.egg<br />
$ sh setuptools-0.6c9-py2.5.egg --prefix=/opt/python2.5</p></blockquote>
<h4>Install MySQLdb package:</h4>
<blockquote><p>$ cd<br />
$ wget http://internap.dl.sourceforge.net/sourceforge/mysql-python/MySQL-python-1.2.2.tar.gz<br />
$ tar xvfz MySQL-python-1.2.2.tar.gz<br />
$ cd MySQL-python-1.2.2<br />
$ python setup.py build<br />
$ python setup.py install</p></blockquote>
<h4>Verify Python 2.5 Installation:</h4>
<blockquote><p>$ cd<br />
$ python<br />
Python 2.5 (r25:51908, Nov  9 2008, 23:18:24)<br />
[GCC 4.1.2 20071124 (Red Hat 4.1.2-42)] on linux2<br />
Type "help", "copyright", "credits" or "license" for more information.<br />
&gt;&gt;&gt; import sqlite3<br />
&gt;&gt;&gt; import MySQLdb<br />
&gt;&gt;&gt;</p></blockquote>
<h3>Installing mod_wsgi</h3>
<h4>What is mod_wsgi?</h4>
<p>The aim of mod_wsgi is to implement a simple to use Apache module which can host any Python application which supports the Python WSGI interface. The module would be suitable for use in hosting high performance production web sites, as well as your average self managed personal sites running on web hosting services.</p>
<h4>Why mod_wsgi?</h4>
<p>The consensus seems to be that mod_wsgi is the prefered Apache module (as opposed to mod_python).  It's stable, less memory intensive, and faster.</p>
<h4>Configure mod_wsgi to link with Python 2.5 shared libs:</h4>
<blockquote><p>$ cd /opt/python2.5/lib/python2.5/config<br />
$ ln -s ../../libpython2.5.so .<br />
$ cd<br />
$ wget http://modwsgi.googlecode.com/files/mod_wsgi-2.3.tar.gz<br />
$ tar xvfz mod_wsgi-2.3.tar.gz<br />
$ cd mod_wsgi-2.3<br />
$ ./configure --with-python=/opt/python2.5/bin/python</p></blockquote>
<h4>Make and install:</h4>
<blockquote><p>$ make<br />
$ make install</p></blockquote>
<p>It’s important to read the mod_wsgi docs on building with shared libs - mod_wsgi should compile to around 250kb.</p>
<h4>Confirm that the size of mod_wsgi.so is around 250kb:</h4>
<blockquote><p>$ ls -Al /usr/local/apache/modules/mod_wsgi.so</p></blockquote>
<h4>Add mod_wsgi to Apache 2.x:</h4>
<p>With cPanel/WHM you can simply add these lines to your 'Pre-Virtualhost Include' file accessible in WHM:</p>
<blockquote><p>LoadModule wsgi_module /usr/local/apache/modules/mod_wsgi.so<br />
AddHandler wsgi-script .wsgi</p></blockquote>
<h3>Setup a Django 1.0 test project</h3>
<p>Create a new user/domain via WHM/cPanel</p>
<h4>Edit users .bash_profile:</h4>
<blockquote><p>alias python='/opt/python2.5/bin/python'<br />
export PYTHONPATH='$PYTHONPATH:/home/username/sites/domain.com'</p></blockquote>
<h4>Create a new project directory:</h4>
<blockquote><p>$ mkdir -p /home/username/sites/domain.com<br />
$ cd /home/username/sites/domain.com<br />
$ svn co http://code.djangoproject.com/svn/django/trunk/ django-trunk<br />
$ ln -s django-trunk/django django<br />
$ mkdir .python-eggs<br />
$ chmod 777 .python-eggs<br />
$ /home/username/sites/domain.com/django/bin/django-admin.py startproject testproject<br />
$ chown -R username: /home/username/sites</p></blockquote>
<h4>Create your apps .wsgi script:</h4>
<blockquote><p>$ pico /home/username/public_html/test.wsgi</p>
<p>#!/opt/python2.5/bin/python<br />
import os, sys<br />
sys.path.insert(0,'/home/username/sites/domain.com')<br />
os.environ['DJANGO_SETTINGS_MODULE'] = 'testproject.settings'<br />
os.environ['PYTHON_EGG_CACHE'] = '/home/username/sites/domain.com/.python-eggs'<br />
import django.core.handlers.wsgi<br />
application = django.core.handlers.wsgi.WSGIHandler()</p>
<p>$ chown username: /home/username/public_html/test.wsgi</p></blockquote>
<h4>Setup a vhost include (as root)</h4>
<blockquote><p>$ mkdir -p /usr/local/apache/conf/userdata/std/2/username/domain.com<br />
$ pico /usr/local/apache/conf/userdata/std/2/username/domain.com/vhost.conf</p>
<p>&lt;IfModule mod_alias.c&gt;<br />
Alias /robots.txt /home/username/sites/domain.com/testproject/media/robots.txt<br />
Alias /site_media /home/username/sites/domain.com/testproject/media<br />
Alias /admin_media /home/username/sites/domain.com/django/contrib/admin/media<br />
&lt;/IfModule&gt;</p>
<p>&lt;IfModule mod_wsgi.c&gt;<br />
# See the link below for an introduction about this mod_wsgi config.<br />
# http://groups.google.com/group/modwsgi/browse_thread/thread/60cb0ec3041ac1bc/2c547b701c4d74aa</p>
<p>WSGIScriptAlias / /home/username/public_html/test.wsgi<br />
WSGIDaemonProcess username processes=7 threads=1 display-name=%{GROUP}<br />
WSGIProcessGroup username<br />
WSGIApplicationGroup %{GLOBAL}<br />
&lt;/IfModule&gt;</p>
<p># This fixes the broken ErrorDocument directive we inherit that breaks auth<br />
# if we use a WSGI app.<br />
ErrorDocument 401 "Authentication Error"<br />
ErrorDocument 403 "Forbidden"</p>
<p>$ /scripts/verify_vhost_includes<br />
$ /scripts/ensure_vhost_includes --user=username</p></blockquote>
<p>domain.com should now be serving a django site.</p>
<h4>To restart a django instance:</h4>
<blockquote><p>$ touch ~/public_html/test.wsgi</p></blockquote>


<p>Related posts:<ol><li><a href='http://blog.perplexedlabs.com/2009/11/15/setup-python-2-6-4-mod_wsgi-2-6-and-django-1-1-1-on-centos-5-3-cpanel/' rel='bookmark' title='Permanent Link: Setup Python 2.6.4, mod_wsgi 2.6, and Django 1.1.1 on CentOS 5.3 (cPanel)'>Setup Python 2.6.4, mod_wsgi 2.6, and Django 1.1.1 on CentOS 5.3 (cPanel)</a></li>
<li><a href='http://blog.perplexedlabs.com/2008/02/04/building-a-rails-capable-slice-from-scratch/' rel='bookmark' title='Permanent Link: Ruby On Rails and SliceHost Part 1: Initial Setup'>Ruby On Rails and SliceHost Part 1: Initial Setup</a></li>
<li><a href='http://blog.perplexedlabs.com/2009/01/13/installing-ruby-enterprise-edition-with-phusion-passenger/' rel='bookmark' title='Permanent Link: Installing Ruby Enterprise Edition with Phusion Passenger'>Installing Ruby Enterprise Edition with Phusion Passenger</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://blog.perplexedlabs.com/2008/11/10/setup-python-25-mod_wsgi-and-django-10-on-centos-5-cpanel/feed/</wfw:commentRss>
		<slash:comments>36</slash:comments>
		</item>
	</channel>
</rss>

