<?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>SOASI &#187; mod_rails</title>
	<atom:link href="http://www.soasi.com/tag/mod_rails/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.soasi.com</link>
	<description>Sviluppo Software e Sistemi Open Source a Forlì</description>
	<lastBuildDate>Wed, 25 Jan 2012 15:06:25 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=</generator>
<xhtml:meta xmlns:xhtml="http://www.w3.org/1999/xhtml" name="robots" content="noindex" />
		<item>
		<title>Django 1.0 on Dreamhost with passenger (mod_rails)</title>
		<link>http://www.soasi.com/2008/09/django-10-on-dreamhost-with-passenger-mod_rails/</link>
		<comments>http://www.soasi.com/2008/09/django-10-on-dreamhost-with-passenger-mod_rails/#comments</comments>
		<pubDate>Wed, 10 Sep 2008 19:59:29 +0000</pubDate>
		<dc:creator>SOASI</dc:creator>
				<category><![CDATA[django]]></category>
		<category><![CDATA[dreamhost]]></category>
		<category><![CDATA[mod_rails]]></category>
		<category><![CDATA[passenger]]></category>

		<guid isPermaLink="false">http://www.soasi.com/?p=250</guid>
		<description><![CDATA[In this article I will describe how to set up a Django 1.0 configuration on Dreamhost and other shared web hosting supporting passenger (also called mod_rails). There are many reason to create a such configuration: passenger is faster than fcgi and it brings less 500 errors when the server is busy. It&#8217;s also simpler to [...]]]></description>
			<content:encoded><![CDATA[<p>In this article I will describe how to set up a <strong>Django 1.0</strong> configuration on <strong>Dreamhost</strong> and other shared web hosting supporting passenger (also called mod_rails). There are many reason to create a such configuration: <strong>passenger</strong> is faster than fcgi and it brings less 500 errors when the server is busy. It&#8217;s  also simpler to set up, and It&#8217;s easier to get out without any problems.<span id="more-250"></span></p>
<p>In Dreamhost panel -&gt; Domains -&gt; Manage Domains click on the domain you want to put your app on (in the example we will set domain.com), and activate  <em>&#8220;Ruby on Rails Passenger (mod_rails)&#8221; </em>option. <strong>Pay attention</strong>: it change the way it serves files on that domains, so be sure to set this option only on the domain or subdomain you want to use with django.</p>
<p>On the server side, enter on /home/user/domain.com and create a &#8220;public&#8221; subdir:</p>
<p><code>cd /home/user/domain.com &amp;&amp; mkdir public</code></p>
<p>Everything inside this dir will be served on the root web URL, after checking if there&#8217;s any django url matching it.</p>
<p>So, if you add a robots.txt inside /home/user/domain.com/public/ the url will be www.domain.com/robots.txt if there&#8217;s no &#8216;^robots.txt$&#8217; or similar match in your urls.py django file.</p>
<p>Download django source code and unzip the django dir inside on /home/user/domain.com/django. To make sure you have done correctly check if you have /home/user/domain.com/django/core directory.</p>
<p>If you need some other python libraries, put them into  /home/user/domain.com/libraries/. We will put this dir on the PYTHONPATH to collect them in a separate directory outside django and your project.</p>
<p>Upload your project on <em>/home/user/domain.com/myproject</em>. If you don&#8217;t have already one, you can create it calling</p>
<p><code>cd /home/user/domain.com/<br />
/home/user/domain.com/django/bin/django-admin.py startproject myproject</code></p>
<p>You don&#8217;t need any htaccess file, because passenger knows already where to find things.</p>
<p>Create a file called passenger_wsgi.py inside /home/user/domain.com/:</p>
<p><code>vim /home/user/domain.com/passenger_wsgi.py</code></p>
<p>With this content:</p>
<p><code><br />
import sys,os<br />
INTERP = "/usr/bin/python2.4"<br />
if sys.executable != INTERP: os.execl(INTERP, INTERP, *sys.argv)<br />
sys.path.append("/home/user/domain.com/")<br />
sys.path.append("/home/user/domain.com/libraries")<br />
os.environ['DJANGO_SETTINGS_MODULE'] = 'myproject.settings'<br />
import django.core.handlers.wsgi<br />
application = django.core.handlers.wsgi.WSGIHandler()<br />
</code></p>
<p>On  /home/user/domain.com/myproject/settings.py file check  settings:<br />
<code>MEDIA_ROOT = '/home/user/domain.com/public/media/'<br />
MEDIA_URL = 'http://www.domain.com/media/'<br />
ADMIN_MEDIA_PREFIX = '/admin_media/'<br />
</code></p>
<p>As you can see, &#8220;<strong>public</strong>&#8221; is <strong>eaten</strong> by passenger, so it&#8217;s useful to create a subdir to be sure the URL of files will not conflict with urls.py settings.</p>
<p>Create a symbolic link for admin_media:<br />
<code>cd /home/user/domain.com/public/<br />
ln -s home/user/domain.com/django/contrib/admin/media/ admin_media </code></p>
<p>That&#8217;s all. It&#8217;s simpler than it seems. To reload a modify setting or python file, simply do</p>
<p><code>pkill python</code></p>
<p>Read also:<br />
<a rel="nofollow" href="http://wiki.dreamhost.com/Passenger_WSGI">Passenger WSGI</a><br />
<a rel="nofollow" href="http://wiki.dreamhost.com/Passenger">Dreamhost Passenger</a><br />
<a rel="nofollow" href="http://wiki.dreamhost.com/Django">Django on Dreamhost with FCGI</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.soasi.com/2008/09/django-10-on-dreamhost-with-passenger-mod_rails/feed/</wfw:commentRss>
		<slash:comments>12</slash:comments>
		</item>
	</channel>
</rss>

