<?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>be present now &#187; django</title>
	<atom:link href="http://durdn.com/blog/category/python/django-python/feed/" rel="self" type="application/rss+xml" />
	<link>http://durdn.com/blog</link>
	<description>modern alchemy for joyful living.</description>
	<lastBuildDate>Sun, 01 Nov 2009 20:24:47 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<item>
		<title>how to setup pinax with nginx</title>
		<link>http://durdn.com/blog/2009/10/07/how-to-setup-pinax-with-nginx/</link>
		<comments>http://durdn.com/blog/2009/10/07/how-to-setup-pinax-with-nginx/#comments</comments>
		<pubDate>Wed, 07 Oct 2009 00:38:44 +0000</pubDate>
		<dc:creator>nick</dc:creator>
				<category><![CDATA[django]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[pinax]]></category>
		<category><![CDATA[python]]></category>
		<category><![CDATA[deployment]]></category>
		<category><![CDATA[flup]]></category>
		<category><![CDATA[nginx]]></category>

		<guid isPermaLink="false">http://durdn.com/blog/?p=66</guid>
		<description><![CDATA[Tonight I spent sometime getting Pinax &#8211; Django swiss army knife &#8211; to work on nginx via fastcgi on my Ubuntu 9.10 box. Here is a step by step guide. First of course we need to install nginx, pretty easy with Ubuntu: sudo apt-get install nginx Create a new file called &#60;appname&#62; in /etc/nginx/sites-available/ like [...]]]></description>
			<content:encoded><![CDATA[<p>Tonight I spent sometime getting <a href="http://pinaxproject.com">Pinax</a> &#8211; <a href="http://www.djangoproject.com/">Django</a> swiss army knife &#8211; to work on <a href="http://wiki.nginx.org/Main">nginx</a> via fastcgi on my <a href="http://www.ubuntu.com/testing/karmic/beta">Ubuntu 9.10</a> box. Here is a step by step guide.</p>
<p>First of course we need to install nginx, pretty easy with Ubuntu:</p>
<p><code>sudo apt-get install nginx</code></p>
<p>Create a new file called &lt;appname&gt; in /etc/nginx/sites-available/ like the following:</p>
<pre>
upstream djangoserv {
    server 127.0.0.1:8801;
}

server {
    listen   80;
    server_name  alkemic;

    access_log  /var/log/nginx/appname.access.log;

    location ^~ /site_media/  {
        alias /home/nick/dev/projects/pinax07/appname/site_media/;
        autoindex on;
    }
    location ~* ^.+\.(jpg|jpeg|gif|png|ico|css|zip|tgz|gz|rar|bz2|doc|xls|exe|pdf|ppt|txt|tar|mid|midi|wav|bmp|rtf|js|mov)   {
        #access_log   off;
        expires      30d;
    }

    location / {
        # host and port to fastcgi server
        fastcgi_pass 127.0.0.1:8801;
        fastcgi_param PATH_INFO $fastcgi_script_name;
        fastcgi_param REQUEST_METHOD $request_method;
        fastcgi_param QUERY_STRING $query_string;
        fastcgi_param SERVER_NAME $server_name;
        fastcgi_param SERVER_PORT $server_port;
        fastcgi_param SERVER_PROTOCOL $server_protocol;
        fastcgi_param CONTENT_TYPE $content_type;
        fastcgi_param CONTENT_LENGTH $content_length;
        fastcgi_pass_header Authorization;
        fastcgi_intercept_errors off;
    }
}
</pre>
<p>Link it to sites-enabled so that we know it&#8217;s going to be started up (meanwhile you want to remove the default one):</p>
<p><code>sudo ln -s /etc/nginx/sites-available/appname /etc/nginx/sites-enabled/</code></p>
<p>Startup nginx with:</p>
<p><code>sudo /etc/init.d/nginx start</code></p>
<p>Activate your pinax installation (change the path to where you have installed your Pinax virtual environment):</p>
<p><code>source /home/nick/dev/projects/pinax07/bin/activate</code></p>
<p>Install <a href="http://trac.saddi.com/flup">flup</a> (required to have manage.py run as fastcgi) in your virtual env:</p>
<p><code>pip install flup</code></p>
<p>Symlink all the static assets into the site_media folder:</p>
<p><code> css -&gt; /home/nick/dev/projects/pinax07/appname/media/css/<br />
img -&gt; /home/nick/dev/projects/pinax07/appname/media/img<br />
js -&gt; /home/nick/dev/projects/pinax07/appname/media/js<br />
pinax -&gt; ../../lib/python2.6/site-packages/pinax/media/default/pinax/<br />
snd -&gt; /home/nick/dev/projects/pinax07/appname/media/snd<br />
swf -&gt; /home/nick/dev/projects/pinax07/appname/media/swf<br />
</code></p>
<p>Launch the python fastcgi process:</p>
<p><code> python ./manage.py runfcgi method=threaded host=127.0.0.1 port=8801<br />
</code><br />
Or:</p>
<p><code>python ./manage.py runfcgi method=prefork host=127.0.0.1 port=8801</code></p>
<p>Note that you might need to move your development environment to use a proper db like MySQL because otherwise the app will have problems finding your sqlite db file.</p>
<p>You should have now your app running on the blazing fast nginx.</p>
<script type="text/javascript">
  addthis_url    = 'http%3A%2F%2Fdurdn.com%2Fblog%2F2009%2F10%2F07%2Fhow-to-setup-pinax-with-nginx%2F';
  addthis_title  = 'how+to+setup+pinax+with+nginx';
  addthis_pub    = 'durdn';
</script><script type="text/javascript" src="http://s7.addthis.com/js/addthis_widget.php?v=12" ></script>
]]></content:encoded>
			<wfw:commentRss>http://durdn.com/blog/2009/10/07/how-to-setup-pinax-with-nginx/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
	</channel>
</rss>

<!-- Dynamic Page Served (once) in 0.218 seconds -->
