<?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; centos</title>
	<atom:link href="http://blog.perplexedlabs.com/tag/centos/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>Thu, 09 Sep 2010 17:11:02 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>Setup Python 2.6.4, mod_wsgi 2.6, and Django 1.1.1 on CentOS 5.3 (cPanel)</title>
		<link>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/</link>
		<comments>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/#comments</comments>
		<pubDate>Sun, 15 Nov 2009 20:37:38 +0000</pubDate>
		<dc:creator>Matt</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[Django]]></category>
		<category><![CDATA[Infrastructure]]></category>
		<category><![CDATA[Python]]></category>
		<category><![CDATA[centos]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[mod_wsgi]]></category>
		<category><![CDATA[mysql]]></category>
		<category><![CDATA[mysql-python]]></category>
		<category><![CDATA[mysqldb]]></category>
		<category><![CDATA[setuptools]]></category>

		<guid isPermaLink="false">http://blog.perplexedlabs.com/?p=378</guid>
		<description><![CDATA[This is an update to my previous how-to Setup Python 2.5, mod_wsgi, and Django 1.0 on CentOS 5 (cPanel). The biggest reason why I chose to go with Python 2.5 at the time was because the MySQL Python (MySQLdb) package didn't support Python 2.6. The 1.2.3c1 release does so that roadblock is lifted. The instructions [...]


Related posts:<ol><li><a href='http://blog.perplexedlabs.com/2008/11/10/setup-python-25-mod_wsgi-and-django-10-on-centos-5-cpanel/' rel='bookmark' title='Permanent Link: Setup Python 2.5, mod_wsgi, and Django 1.0 on CentOS 5 (cPanel)'>Setup Python 2.5, mod_wsgi, and Django 1.0 on CentOS 5 (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/02/08/getting-started-with-django-and-python-first-impressions/' rel='bookmark' title='Permanent Link: Getting Started with Django and Python &#8211; First Impressions'>Getting Started with Django and Python &#8211; First Impressions</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p>This is an update to my previous how-to <a href="http://blog.perplexedlabs.com/2008/11/10/setup-python-25-mod_wsgi-and-django-10-on-centos-5-cpanel/">Setup Python 2.5, mod_wsgi, and Django 1.0 on CentOS 5 (cPanel)</a>.</p>
<p>The biggest reason why I chose to go with Python 2.5 at the time was because the MySQL Python (MySQLdb) package didn't support Python 2.6.  The 1.2.3c1 release does so that roadblock is lifted.</p>
<p>The instructions are identical - nothing has really changed in that regard.  Just change the references from Python 2.5 to 2.6.  Here are the links to the versions I'm using successfully:</p>
<blockquote><p>
Python 2.6.4: <a href="http://www.python.org/ftp/python/2.6.4/Python-2.6.4.tgz">http://www.python.org/ftp/python/2.6.4/Python-2.6.4.tgz</a></p>
<p>setuptools 0.6c11: <a href="http://pypi.python.org/packages/2.6/s/setuptools/setuptools-0.6c11-py2.6.egg#md5=bfa92100bd772d5a213eedd356d64086">http://pypi.python.org/packages/2.6/s/setuptools/setuptools-0.6c11-py2.6.egg#md5=bfa92100bd772d5a213eedd356d64086</a></p>
<p>MySQLdb 1.2.3c1: <a href="http://sourceforge.net/projects/mysql-python/files/mysql-python-test/1.2.3c1/MySQL-python-1.2.3c1.tar.gz/download">http://sourceforge.net/projects/mysql-python/files/mysql-python-test/1.2.3c1/MySQL-python-1.2.3c1.tar.gz/download</a></p>
<p>mod_wsgi 2.6: <a href="http://modwsgi.googlecode.com/files/mod_wsgi-2.6.tar.gz">http://modwsgi.googlecode.com/files/mod_wsgi-2.6.tar.gz</a></p>
<p>Django 1.1.1: <a href="http://www.djangoproject.com/download/1.1.1/tarball/">http://www.djangoproject.com/download/1.1.1/tarball/</a>
</p></blockquote>


<p>Related posts:<ol><li><a href='http://blog.perplexedlabs.com/2008/11/10/setup-python-25-mod_wsgi-and-django-10-on-centos-5-cpanel/' rel='bookmark' title='Permanent Link: Setup Python 2.5, mod_wsgi, and Django 1.0 on CentOS 5 (cPanel)'>Setup Python 2.5, mod_wsgi, and Django 1.0 on CentOS 5 (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/02/08/getting-started-with-django-and-python-first-impressions/' rel='bookmark' title='Permanent Link: Getting Started with Django and Python &#8211; First Impressions'>Getting Started with Django and Python &#8211; First Impressions</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>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/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>Getting Started with Django and Python &#8211; First Impressions</title>
		<link>http://blog.perplexedlabs.com/2009/02/08/getting-started-with-django-and-python-first-impressions/</link>
		<comments>http://blog.perplexedlabs.com/2009/02/08/getting-started-with-django-and-python-first-impressions/#comments</comments>
		<pubDate>Mon, 09 Feb 2009 04:15:58 +0000</pubDate>
		<dc:creator>Matt</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[Django]]></category>
		<category><![CDATA[centos]]></category>
		<category><![CDATA[Python]]></category>

		<guid isPermaLink="false">http://www.perplexedlabs.com/?p=155</guid>
		<description><![CDATA[I decided to spend the weekend getting more comfortable working and developing in Django (and coincidentally this MacBook Pro). I've learned a lot already and I think this post might help some coming from other web development architectures to Django. In a previous post I discussed installing Django and getting it to play nice with [...]


Related posts:<ol><li><a href='http://blog.perplexedlabs.com/2009/03/20/django-and-python-first-impressions-part-ii/' rel='bookmark' title='Permanent Link: Django and Python First Impressions &#8211; Part II'>Django and Python First Impressions &#8211; Part II</a></li>
<li><a href='http://blog.perplexedlabs.com/2008/11/10/setup-python-25-mod_wsgi-and-django-10-on-centos-5-cpanel/' rel='bookmark' title='Permanent Link: Setup Python 2.5, mod_wsgi, and Django 1.0 on CentOS 5 (cPanel)'>Setup Python 2.5, mod_wsgi, and Django 1.0 on CentOS 5 (cPanel)</a></li>
<li><a href='http://blog.perplexedlabs.com/2009/08/13/adventures-in-django-and-python-part-iii/' rel='bookmark' title='Permanent Link: Adventures in Django and Python &#8211; Part III'>Adventures in Django and Python &#8211; Part III</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p>I decided to spend the weekend getting more comfortable working and developing in Django (and coincidentally this MacBook Pro).  I've learned a lot already and I think this post might help some coming from other web development architectures to Django.</p>
<p>In a previous post I discussed <a href="http://www.perplexedlabs.com/2008/11/10/setup-python-25-mod_wsgi-and-django-10-on-centos-5-cpanel/">installing Django and getting it to play nice with Apache 2 on a CentOS 5/cPanel server</a>.  Updating to <del datetime="2009-02-10T02:20:49+00:00">Django 1.02</del> the latest Django codebase is easy if you followed my previous post, simply do an <strong>svn up</strong> in your django-trunk directory.</p>
<p>The first item that makes sense to tweak is Django's settings.  Editing your <strong>settings.py</strong> file in your project's root directory is fairly straightforward.  Fill in your database settings, adjust your time zone - all that good stuff.  Also, if you followed my previous post, you'll want to make a modification to your <strong>ADMIN_MEDIA_PREFIX</strong>:</p>
<pre class="brush: python;">
ADMIN_MEDIA_PREFIX = '/admin_media/'
</pre>
<p>Initially, you'll also want to use the (excellent) built in administrative interface.  Add it to your <strong>INSTALLED_APPS</strong> tuple at the bottom of <strong>settings.py</strong>:</p>
<pre class="brush: python;">
INSTALLED_APPS = (
    #...
    'django.contrib.admin'
)
</pre>
<p>To test your database connectivity and have Django setup tables required by the default apps that are placed in <strong>INSTALLED_APPS</strong> (including the admin app you just added) run the <strong>manage.py syncdb</strong> command:</p>
<blockquote><p>
python manage.py syncdb
</p></blockquote>
<p>This brings up an issue I came across.  On my server I have a 2nd Python installation (v2.5 for Django development purposes).  You'd like to be able to give +x permissions to manage.py and simply do:</p>
<blockquote><p>
./manage.py syncdb
</p></blockquote>
<p>Internally, the <em>shebang</em> of Django's Python files is <strong>#!/usr/bin/env python</strong>.  The developers, knowing that a Python installation could be anywhere on a given system, obviously went the reliable route and utilize /usr/bin/env (which is essentially guaranteed to exist in that location) to search for a Python interpreter in the system's path.  However, on a system where your desired Python installation won't be found ahead of the system's default (perhaps, required) installation, running the script directly will cause it to be executed by the wrong Python interpreter.</p>
<p>The composition of a Django web application (site) is: <em>a site is composed of projects which are composed of apps</em>.  Apps can be completely decoupled and can be re-used on other projects (and therefor sites).  Apps seem to be the functional equivalent of Rails plugins.</p>
<p>Creating your first app is as simple as executing the <strong>python manage.py startapp appname</strong> command and adding it to your list of <strong>INSTALLED_APPS</strong>.  Personally, the fact that you have to add <em>anything</em> to a list seems cumbersome.  Is it not possible to have them placed in a directory by convention that would automatically load them?  Perhaps this is due to the fact that you may want to take advantage of certain Django bundled apps, such as auth, admin, etc.  In which case it wouldn't make sense to copy them into an "apps" directory under your project root.</p>
<p>After you've created your first app you then create your models.  If you have an familiarity with an <strong>O</strong>bject <strong>R</strong>elation <strong>M</strong>apper (ORM) Django's won't come as any surprise.  Your models extend Django's built in <strong>models.Model</strong> class and define both the database fields as properties and the actions as methods.</p>
<p>As the official Django tutorial suggests, it's helpful to overwrite some base model methods with your own custom methods to implement some important functionality.  In particular <strong>__unicode__()</strong>.  Internally <strong>__str__()</strong> calls <strong>__unicode__()</strong>, so whereas in Python your classes would implement <strong>__str__()</strong>, in Django you implement <strong>__unicode__()</strong>.  This provides a human readable representation of your object when dealing with the built-in Django admin interface, or the Django shell.</p>
<p><em>Edit below: It was late when I wrote this, sorry!</em><br />
<del datetime="2009-02-09T14:25:05+00:00">It's also worth noting that it was somewhat surprising to me that certain files were created automatically for you with the <strong>manage.py startapp</strong> command while others weren't (such as models.py).  This certainly isn't something awful, just seemed a bit inconsistent.</del>  This extends to setting up templates.  Again, it's a manual process.  You first create the templates directory and then specify it in your project's <strong>settings.py</strong> file.  Couldn't some of this have been automated?  If you want to modify Django's built-in admin interface template you have to copy the desired file into your templates directory, manually.  Perhaps this just takes some getting used to.  Fair enough.</p>
<p>One issue the official Django tutorial didn't touch upon is setting up your projects "home" view (accessing / ).  It's simple, your <em>project</em> can define it's own views that can be added to your <strong>urls.py</strong> file.</p>
<pre class="brush: python;">
urlpatterns = patterns('',
    (r'^$', 'myproject.views.index'),
    (r'^admin/(.*)', admin.site.root),
)
</pre>
<p>And in your <em>project's</em> <strong>views.py</strong> file:</p>
<pre class="brush: python;">
from django.http import HttpResponse

def index(request):
        return HttpResponse('Hello, World!')
</pre>
<p>It also occurred to me that if apps are meant to be decoupled and packageable, and there is only one template directory (all apps template files go in this directory).  What IS the process for packaging and deploying an app into another project?  MORE manual copying?</p>
<p>SHRUG</p>
<p>That's all for now, I'm sure I'll have plenty more to comment about as I experiment.  I do like what I see though and I'm sure I have TONS to learn.  Also - please, correct me if I'm mistaken about anything above.</p>


<p>Related posts:<ol><li><a href='http://blog.perplexedlabs.com/2009/03/20/django-and-python-first-impressions-part-ii/' rel='bookmark' title='Permanent Link: Django and Python First Impressions &#8211; Part II'>Django and Python First Impressions &#8211; Part II</a></li>
<li><a href='http://blog.perplexedlabs.com/2008/11/10/setup-python-25-mod_wsgi-and-django-10-on-centos-5-cpanel/' rel='bookmark' title='Permanent Link: Setup Python 2.5, mod_wsgi, and Django 1.0 on CentOS 5 (cPanel)'>Setup Python 2.5, mod_wsgi, and Django 1.0 on CentOS 5 (cPanel)</a></li>
<li><a href='http://blog.perplexedlabs.com/2009/08/13/adventures-in-django-and-python-part-iii/' rel='bookmark' title='Permanent Link: Adventures in Django and Python &#8211; Part III'>Adventures in Django and Python &#8211; Part III</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://blog.perplexedlabs.com/2009/02/08/getting-started-with-django-and-python-first-impressions/feed/</wfw:commentRss>
		<slash:comments>13</slash:comments>
		</item>
		<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>31</slash:comments>
		</item>
		<item>
		<title>Ruby On Rails and SliceHost Part 1: Initial Setup</title>
		<link>http://blog.perplexedlabs.com/2008/02/04/building-a-rails-capable-slice-from-scratch/</link>
		<comments>http://blog.perplexedlabs.com/2008/02/04/building-a-rails-capable-slice-from-scratch/#comments</comments>
		<pubDate>Mon, 04 Feb 2008 20:42:54 +0000</pubDate>
		<dc:creator>Eric</dc:creator>
				<category><![CDATA[Infrastructure]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Ruby on Rails]]></category>
		<category><![CDATA[apache]]></category>
		<category><![CDATA[centos]]></category>
		<category><![CDATA[memcached]]></category>
		<category><![CDATA[mysql]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[rails]]></category>
		<category><![CDATA[ruby]]></category>
		<category><![CDATA[slicehost]]></category>

		<guid isPermaLink="false">http://perplexedlabs.com/2008/02/04/building-a-rails-capable-slice-from-scratch/</guid>
		<description><![CDATA[I recently purchased a VPS from SliceHost.com. After ruling out a shared host and deciding on a VPS setup, SliceHost seemed to offer the most for my money. My initial setup is the 256slice, which offers 256mb RAM, 10GB of storage, and 100GB of bandwidth for $20 a month. Being able to build my own [...]


Related posts:<ol><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>
<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/2010/02/08/deployment-using-capistrano-and-webistrano-via-rails-and-phusion-passenger/' rel='bookmark' title='Permanent Link: Deployment Using Capistrano / Webistrano via Rails / Phusion Passenger'>Deployment Using Capistrano / Webistrano via Rails / Phusion Passenger</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p>I recently purchased a VPS from <a href="http://www.slicehost.com">SliceHost.com</a>. After ruling out a shared host and deciding on a VPS setup, SliceHost seemed to offer the most for my money.   My initial setup is the 256slice, which offers 256mb RAM, 10GB of storage, and 100GB of bandwidth for $20 a month.  Being able to build my own stack from scratch is very appealing, especially as most of my side projects are written in <a href="http://www.rubyonrails.org/">Rails</a>.  My goal was to have <a href="http://httpd.apache.org/">Apache 2.2</a> as a front-end server, proxying requests to <a href="http://mongrel.rubyforge.org/">mongrel</a> or a <a href="http://mongrel.rubyforge.org/docs/mongrel_cluster.html">cluster of mongrels</a>, with <a href="http://dev.mysql.com/downloads/mysql/5.0.html">MySQL 5.0</a> as the database.  Of course I also wanted to have <a href="http://www.ruby-lang.org/en/downloads/">Ruby 1.8.6</a> and Rails 2.0.2.  Another useful, though optional, tool is <a href="http://www.phpmyadmin.net/home_page/index.php">phpMyAdmin</a>.  I am also using <a href="http://www.centos.org/">CentOS 5.0</a>, first because of my familiarity with it and second because it's well documented and supported.  The following is the first of a multipart tutorial about how I set this all up.  In future installments I will detail how to secure and optimize each installation as well as enable Apache proxying and mongrel clustering.</p>
<p><strong>Change the default root password</strong></p>
<blockquote><p>&gt;passwd</p></blockquote>
<p><strong>Update all yum packages</strong></p>
<blockquote><p>&gt;yum update</p></blockquote>
<p><strong>Bring in some standard packages</strong></p>
<blockquote><p>&gt;yum install wget openssl-devel lynx zlib zlib-devel vixie-cron curl lynx subversion make gcc automake</p></blockquote>
<p><strong>Install Apache</strong></p>
<blockquote><p>&gt;yum install httpd</p></blockquote>
<p><strong>Setup your domain records</strong><br />
<a href="http://articles.slicehost.com/2007/10/24/creating-dns-records"> http://articles.slicehost.com/2007/10/24/creating-dns-records</a></p>
<p><strong>Create your VirtualHosts in Apache's httpd.conf</strong><br />
<a href="http://httpd.apache.org/docs/2.2/vhosts"> http://httpd.apache.org/docs/2.2/vhosts</a><br />
Note: Apache's conf directory will be /etc/httpd/conf.  Don't forget to restart Apache after setting up each new vhost:</p>
<blockquote><p>&gt;service httpd restart</p></blockquote>
<p>See <a href="http://mongrel.rubyforge.org/docs/apache.html">http://mongrel.rubyforge.org/docs/apache.html</a> for details on how to get Apache and mongrel to play with each other.</p>
<p><strong>Start Apache</strong></p>
<blockquote><p>&gt;httpd service start</p></blockquote>
<p><strong>Install MySQL</strong></p>
<blockquote><p>&gt;yum install mysql mysql-server</p></blockquote>
<p>See <a href="http://dev.mysql.com/doc/">http://dev.mysql.com/doc/</a> for post-installation instructions (setting up initial accounts, etc.)</p>
<p><strong>Install Ruby (1.8.6)</strong></p>
<blockquote><p>&gt;wget ftp://ftp.ruby-lang.org/pub/ruby/1.8/ruby-1.8.6-p111.tar.gz<br />
&gt;gzip -d ruby-1.8.6-p111.tar.gz<br />
&gt;tar xvf ruby-1.8.6-p111.tar.gz<br />
&gt;cd ruby-1.8.6-p111.tar.gz<br />
&gt;./configure<br />
&gt;make<br />
&gt;make install</p></blockquote>
<p><strong>Install Ruby Gems (1.0.1)</strong></p>
<blockquote><p>&gt;wget http://rubyforge.org/frs/download.php/29548/rubygems-1.0.1.tgz<br />
&gt;tar xvf rubygems-1.0.1.tgz<br />
&gt;cd rubygems-1.0.1.tgz<br />
&gt;ruby setup.rb</p></blockquote>
<p><strong>Install Rails (2.0.2)</strong></p>
<blockquote><p>&gt;gem install rails --include-dependencies</p></blockquote>
<p><strong>Install Mongrel</strong></p>
<blockquote><p>&gt;gem install mongrel</p></blockquote>
<p><strong>Optional for phpMyAdmin<br />
Install php</strong></p>
<blockquote><p>&gt;yum install php</p></blockquote>
<p><strong>Install php extensions necessary for phpMyAdmin</strong></p>
<blockquote><p>&gt;yum install php-mcrypt<br />
&gt;yum install php-mbstring</p></blockquote>
<p><strong>I</strong><strong>nstall phpmyadmin</strong><br />
<a href="http://www.phpmyadmin.net/documentation/#setup">http://www.phpmyadmin.net/documentation/#setup</a></p>
<p>Any comments or feedback is appreciated.</p>


<p>Related posts:<ol><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>
<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/2010/02/08/deployment-using-capistrano-and-webistrano-via-rails-and-phusion-passenger/' rel='bookmark' title='Permanent Link: Deployment Using Capistrano / Webistrano via Rails / Phusion Passenger'>Deployment Using Capistrano / Webistrano via Rails / Phusion Passenger</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://blog.perplexedlabs.com/2008/02/04/building-a-rails-capable-slice-from-scratch/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>
