<?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; passenger</title>
	<atom:link href="http://www.soasi.com/tag/passenger/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>Installare Django su Dreamhost utilizzando passenger (mod_rails)</title>
		<link>http://www.soasi.com/2008/09/installare-django-su-dreamhost-utilizzando-passenger-mod_rails/</link>
		<comments>http://www.soasi.com/2008/09/installare-django-su-dreamhost-utilizzando-passenger-mod_rails/#comments</comments>
		<pubDate>Thu, 11 Sep 2008 00:01:15 +0000</pubDate>
		<dc:creator>SOASI</dc:creator>
				<category><![CDATA[django]]></category>
		<category><![CDATA[dreamhost]]></category>
		<category><![CDATA[passenger]]></category>
		<category><![CDATA[python]]></category>
		<category><![CDATA[sviluppo]]></category>
		<category><![CDATA[web]]></category>

		<guid isPermaLink="false">http://www.soasi.com/?p=253</guid>
		<description><![CDATA[In questo articolo spieghiamo come installare Django (nelle prove è stata utilizzata la versione 1.0) su Dreamhost attraverso il supporto a passenger (chiamato anche mod_rails). Le ragioni di una configurazione simile sono diverse, ma le principali sono la maggiore velocità di passenger ed un uso meno intensivo delle risorse di sistema, che portano meno errori [...]]]></description>
			<content:encoded><![CDATA[<p>In questo articolo spieghiamo come installare Django (nelle prove è stata utilizzata la versione 1.0) su <strong>Dreamhost</strong> attraverso il supporto a passenger (chiamato anche mod_rails).<br />
Le ragioni di una configurazione simile sono diverse, ma le principali sono la maggiore velocità di passenger ed un uso meno intensivo delle risorse di sistema, che portano meno errori 500 causati dalla mancata produzione delle pagine entro il timeout. Inoltre questa configurazione è più semplice e più lineare (tutto risiede in una unica cartella) e quindi procura meno problemi nel deploy delle applicazioni django.<span id="more-253"></span></p>
<p>Nel pannello di Dreamhost  -&gt; Domains -&gt; Manage Domains dovete cliccare sul dominio che volete utilizzare per la vostra applicazione django (nell&#8217;esempio sarà domain.com), ed attivare l&#8217;opzione <em>&#8220;Ruby on Rails Passenger (mod_rails)&#8221; </em> <strong>NB</strong>: questa impostazione cambia la modalità con la quale Apache pubblica le pagine ed i file, quindi dovete assicurarvi di settare questa opzione solo per il dominio o il sottodominio nel quale installerete il progetto Django.</p>
<p>SUl server entrate nella directory /home/user/domain.com e create la sottodirectory &#8220;public&#8221;:</p>
<p><code>cd /home/user/domain.com &amp;&amp; mkdir public</code></p>
<p>Tutto quello che risiede in questa directory verrà pubblicato da Apache direttamente, a meno che lo stesso URL non venga intercettato dalle impostazioni degli URL del progetto django .</p>
<p>Ad esempio, se aggiungiamo un file robots.txt dentro /home/user/domain.com/public/ la sua URL sarà www.domain.com/robots.txt, e verrà visualizzato a meno che non sia presente una espressione regolare simile a &#8216;^robots.txt$&#8217; nel file urls.py di django.</p>
<p>Scaricate il sorgente di django source e decomprimete la cartella django al suo interno nella directory /home/user/domain.com/django. Per assicurarvi di aver scelto correttamente le directory, controllate di avere la sottodirectory /home/user/domain.com/django/core .</p>
<p>Se avete bisogno di alcune librerie python esterne a django ed al vostro progetto, inseritele in  /home/user/domain.com/libraries/. Metteremo questa directory nel PYTHONPATH per fare in modo che siano correttamente separate dal resto, rendendo più facili gli aggiornamenti.</p>
<p>Caricate il progetto su <em>/home/user/domain.com/myproject</em>. Se non ne avete ancora uno, potete creare lo scheletro con il comando</p>
<p><code>cd /home/user/domain.com/<br />
/home/user/domain.com/django/bin/django-admin.py startproject myproject</code></p>
<p>Non avrete bisogno di nessun file .htaccess, perché la confugurazione di passenger funzionerà anche senza, trovando file e url dinamiche senza il nostro intervento.</p>
<p>A questo punto creato un file chiamato passenger_wsgi.py dentro /home/user/domain.com/:</p>
<p><code>vim /home/user/domain.com/passenger_wsgi.py</code></p>
<p>Con questo contenuto:</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>Dentro  /home/user/domain.com/myproject/settings.py controllate le seguenti impostazioni:<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>Come potete vedere, la stringa/directory, &#8220;<strong>public</strong>&#8221; viene  <strong>mangiata</strong> da passenger, quindi è consigliabile creare una sottodirectory &#8220;media&#8221; per assicurarci che gli URL dei file statici non vengano oscurati dalle impostazioni del vostro urls.py</p>
<p>Se utilizzate l&#8217;admin create un link simbolico per i file css e js contenuti in 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>E&#8217; tutto, ed è molto più semplice di quanto sembri. Una volta creato il progetto sarà molto facile aggiornarlo ed apportarvi modifiche, grazie alla corretta separazione nel deploy dell&#8217;applicazione dei file statici, di django, del progetto e delle librerie python.</p>
<p>Dopo ogni modifica al codice, se volete controllarlo potete eseguire un<br />
<code>pkill python</code><br />
che obbligherà il server a ricopilare e ricaricare i file python (con un piccolo prezzo in termini di tempo, necessario al primo avvio).</p>
<p>Potete approfondire questo tema su:<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/installare-django-su-dreamhost-utilizzando-passenger-mod_rails/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<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>

