<?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>Fighting Rabbits &#187; webfaction</title>
	<atom:link href="http://fightingrabbits.com/archives/category/webfaction/feed" rel="self" type="application/rss+xml" />
	<link>http://fightingrabbits.com</link>
	<description>and herding cats...</description>
	<lastBuildDate>Wed, 23 Jun 2010 12:28:04 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=abc</generator>
		<item>
		<title>Mounting Supervisor on a WebFaction subdomain</title>
		<link>http://fightingrabbits.com/archives/258</link>
		<comments>http://fightingrabbits.com/archives/258#comments</comments>
		<pubDate>Tue, 29 Sep 2009 19:03:18 +0000</pubDate>
		<dc:creator>Richard Cooper</dc:creator>
				<category><![CDATA[Setup]]></category>
		<category><![CDATA[webfaction]]></category>
		<category><![CDATA[django]]></category>
		<category><![CDATA[hosting]]></category>
		<category><![CDATA[nginx]]></category>
		<category><![CDATA[tools]]></category>

		<guid isPermaLink="false">http://fightingrabbits.com/?p=258</guid>
		<description><![CDATA[In a previous post I mentioned that you could mount your supervisor process on a sub domain so that you could view and manage your Django and Nginx processes from a web browser. In this post I&#8217;m going to show you how to do this. First of all I&#8217;m going to assume that you have [...]]]></description>
			<content:encoded><![CDATA[<p>In a previous post I mentioned that you could mount your supervisor process on a sub domain so that you could view and manage your Django and Nginx processes from a web browser. In this post I&#8217;m going to show you how to do this.<br />
<span id="more-258"></span><br />
First of all I&#8217;m going to assume that you have a domain called mydomain.com setup on webfaction, and that your supervisor process is listening on an app called supervisor.</p>
<p>To access your supervisor status via a web browser you need to take the following steps:<br />
1) Make sure you have a suitable sub-domain setup &#8211; you do this from the domain menu on the webfaction control panel (I usually use status.mydomain.com) :<br />
<div id="attachment_261" class="wp-caption aligncenter" style="width: 310px"><a href="http://fightingrabbits.com/wp-content/uploads/2009/09/sub-domain1.PNG"><img src="http://fightingrabbits.com/wp-content/uploads/2009/09/sub-domain1-300x198.PNG" alt="Check your Domain" title="Check your Domain" width="300" height="198" class="size-medium wp-image-261" /></a><p class="wp-caption-text">Check your Domain</p></div><br />
2) Create a new website which links the status subdomain and your supervisor app :<br />
<div id="attachment_262" class="wp-caption aligncenter" style="width: 310px"><a href="http://fightingrabbits.com/wp-content/uploads/2009/09/sub-domain2.PNG"><img src="http://fightingrabbits.com/wp-content/uploads/2009/09/sub-domain2-300x225.PNG" alt="Create a new Website" title="Create a new Website" width="300" height="225" class="size-medium wp-image-262" /></a><p class="wp-caption-text">Create a new Website</p></div><br />
3) browse to http://status.mydomain.com/ and enter the password and username we set-up in the supervisor configuration &#8211; you did remember to do that didn&#8217;t you?  ;)</p>
]]></content:encoded>
			<wfw:commentRss>http://fightingrabbits.com/archives/258/feed</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Nginx &amp; Django on Webfaction (Part&#160;1b) – Configuring</title>
		<link>http://fightingrabbits.com/archives/160</link>
		<comments>http://fightingrabbits.com/archives/160#comments</comments>
		<pubDate>Mon, 07 Sep 2009 12:18:46 +0000</pubDate>
		<dc:creator>Richard Cooper</dc:creator>
				<category><![CDATA[Coding]]></category>
		<category><![CDATA[Random]]></category>
		<category><![CDATA[Setup]]></category>
		<category><![CDATA[webfaction]]></category>
		<category><![CDATA[django]]></category>
		<category><![CDATA[installation]]></category>
		<category><![CDATA[nginx]]></category>

		<guid isPermaLink="false">http://fightingrabbits.com/?p=160</guid>
		<description><![CDATA[In Part 1a of this series we compiled Nginx and Installed Django in this next part we are going to configure nginx and Django and get our welcome page displaying. First lets configure nginx, the default conf file looks like this: #user nobody; worker_processes 1; &#160; #error_log logs/error.log; #error_log logs/error.log notice; #error_log logs/error.log info; &#160; [...]]]></description>
			<content:encoded><![CDATA[<p>In Part 1a of this series we compiled Nginx and Installed Django in this next part we are going to configure nginx and Django and get our welcome page displaying.</p>
<p>First lets configure nginx, the default conf file looks like this:</p>
<p><span id="more-160"></span></p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">#user  nobody;</span>
worker_processes  <span style="color: #000000;">1</span>;
&nbsp;
<span style="color: #666666; font-style: italic;">#error_log  logs/error.log;</span>
<span style="color: #666666; font-style: italic;">#error_log  logs/error.log  notice;</span>
<span style="color: #666666; font-style: italic;">#error_log  logs/error.log  info;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">#pid        logs/nginx.pid;</span>
&nbsp;
&nbsp;
events <span style="color: #7a0874; font-weight: bold;">&#123;</span>
    worker_connections  <span style="color: #000000;">1024</span>;
<span style="color: #7a0874; font-weight: bold;">&#125;</span>
&nbsp;
&nbsp;
http <span style="color: #7a0874; font-weight: bold;">&#123;</span>
    include       mime.types;
    default_type  application<span style="color: #000000; font-weight: bold;">/</span>octet-stream;
&nbsp;
    <span style="color: #666666; font-style: italic;">#log_format  main  '$remote_addr - $remote_user [$time_local] &quot;$request&quot; '</span>
    <span style="color: #666666; font-style: italic;">#                  '$status $body_bytes_sent &quot;$http_referer&quot; '</span>
    <span style="color: #666666; font-style: italic;">#                  '&quot;$http_user_agent&quot; &quot;$http_x_forwarded_for&quot;';</span>
&nbsp;
    <span style="color: #666666; font-style: italic;">#access_log  logs/access.log  main;</span>
&nbsp;
    sendfile        on;
    <span style="color: #666666; font-style: italic;">#tcp_nopush     on;</span>
&nbsp;
    <span style="color: #666666; font-style: italic;">#keepalive_timeout  0;</span>
    keepalive_timeout  <span style="color: #000000;">65</span>;
&nbsp;
    <span style="color: #666666; font-style: italic;">#gzip  on;</span>
&nbsp;
    server <span style="color: #7a0874; font-weight: bold;">&#123;</span>
        listen       <span style="color: #000000;">80</span>;
        server_name  localhost;
&nbsp;
        <span style="color: #666666; font-style: italic;">#charset koi8-r;</span>
&nbsp;
        <span style="color: #666666; font-style: italic;">#access_log  logs/host.access.log  main;</span>
&nbsp;
        location <span style="color: #000000; font-weight: bold;">/</span> <span style="color: #7a0874; font-weight: bold;">&#123;</span>
            root   html;
            index  index.html index.htm;
        <span style="color: #7a0874; font-weight: bold;">&#125;</span>
&nbsp;
        <span style="color: #666666; font-style: italic;">#error_page  404              /404.html;</span>
&nbsp;
        <span style="color: #666666; font-style: italic;"># redirect server error pages to the static page /50x.html</span>
        <span style="color: #666666; font-style: italic;">#</span>
        error_page   <span style="color: #000000;">500</span> <span style="color: #000000;">502</span> <span style="color: #000000;">503</span> <span style="color: #000000;">504</span>  <span style="color: #000000; font-weight: bold;">/</span>50x.html;
        location = <span style="color: #000000; font-weight: bold;">/</span>50x.html <span style="color: #7a0874; font-weight: bold;">&#123;</span>
            root   html;
        <span style="color: #7a0874; font-weight: bold;">&#125;</span>
&nbsp;
        <span style="color: #666666; font-style: italic;"># proxy the PHP scripts to Apache listening on 127.0.0.1:80</span>
        <span style="color: #666666; font-style: italic;">#</span>
        <span style="color: #666666; font-style: italic;">#location ~ \.php$ {</span>
        <span style="color: #666666; font-style: italic;">#    proxy_pass   http://127.0.0.1;</span>
        <span style="color: #666666; font-style: italic;">#}</span>
&nbsp;
        <span style="color: #666666; font-style: italic;"># pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000</span>
        <span style="color: #666666; font-style: italic;">#</span>
        <span style="color: #666666; font-style: italic;">#location ~ \.php$ {</span>
        <span style="color: #666666; font-style: italic;">#    root           html;</span>
        <span style="color: #666666; font-style: italic;">#    fastcgi_pass   127.0.0.1:9000;</span>
        <span style="color: #666666; font-style: italic;">#    fastcgi_index  index.php;</span>
        <span style="color: #666666; font-style: italic;">#    fastcgi_param  SCRIPT_FILENAME  /scripts$fastcgi_script_name;</span>
        <span style="color: #666666; font-style: italic;">#    include        fastcgi_params;</span>
        <span style="color: #666666; font-style: italic;">#}</span>
&nbsp;
        <span style="color: #666666; font-style: italic;"># deny access to .htaccess files, if Apache's document root</span>
        <span style="color: #666666; font-style: italic;"># concurs with nginx's one</span>
        <span style="color: #666666; font-style: italic;">#</span>
        <span style="color: #666666; font-style: italic;">#location ~ /\.ht {</span>
        <span style="color: #666666; font-style: italic;">#    deny  all;</span>
        <span style="color: #666666; font-style: italic;">#}</span>
    <span style="color: #7a0874; font-weight: bold;">&#125;</span>
&nbsp;
&nbsp;
    <span style="color: #666666; font-style: italic;"># another virtual host using mix of IP-, name-, and port-based configuration</span>
    <span style="color: #666666; font-style: italic;">#</span>
    <span style="color: #666666; font-style: italic;">#server {</span>
    <span style="color: #666666; font-style: italic;">#    listen       8000;</span>
    <span style="color: #666666; font-style: italic;">#    listen       somename:8080;</span>
    <span style="color: #666666; font-style: italic;">#    server_name  somename  alias  another.alias;</span>
&nbsp;
    <span style="color: #666666; font-style: italic;">#    location / {</span>
    <span style="color: #666666; font-style: italic;">#        root   html;</span>
    <span style="color: #666666; font-style: italic;">#        index  index.html index.htm;</span>
    <span style="color: #666666; font-style: italic;">#    }</span>
    <span style="color: #666666; font-style: italic;">#}</span>
&nbsp;
&nbsp;
    <span style="color: #666666; font-style: italic;"># HTTPS server</span>
    <span style="color: #666666; font-style: italic;">#</span>
    <span style="color: #666666; font-style: italic;">#server {</span>
    <span style="color: #666666; font-style: italic;">#    listen       443;</span>
    <span style="color: #666666; font-style: italic;">#    server_name  localhost;</span>
&nbsp;
    <span style="color: #666666; font-style: italic;">#    ssl                  on;</span>
    <span style="color: #666666; font-style: italic;">#    ssl_certificate      cert.pem;</span>
    <span style="color: #666666; font-style: italic;">#    ssl_certificate_key  cert.key;</span>
&nbsp;
    <span style="color: #666666; font-style: italic;">#    ssl_session_timeout  5m;</span>
&nbsp;
    <span style="color: #666666; font-style: italic;">#    ssl_protocols  SSLv2 SSLv3 TLSv1;</span>
    <span style="color: #666666; font-style: italic;">#    ssl_ciphers  ALL:!ADH:!EXPORT56:RC4+RSA:+HIGH:+MEDIUM:+LOW:+SSLv2:+EXP;</span>
    <span style="color: #666666; font-style: italic;">#    ssl_prefer_server_ciphers   on;</span>
&nbsp;
    <span style="color: #666666; font-style: italic;">#    location / {</span>
    <span style="color: #666666; font-style: italic;">#        root   html;</span>
    <span style="color: #666666; font-style: italic;">#        index  index.html index.htm;</span>
    <span style="color: #666666; font-style: italic;">#    }</span>
    <span style="color: #666666; font-style: italic;">#}</span>
&nbsp;
<span style="color: #7a0874; font-weight: bold;">&#125;</span></pre></div></div>

<p>Now that we have seen the default file let&#8217;s back it up and start from scratch :)</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #7a0874; font-weight: bold;">cd</span> ~<span style="color: #000000; font-weight: bold;">/</span>webapps<span style="color: #000000; font-weight: bold;">/&lt;</span>myapp<span style="color: #000000; font-weight: bold;">&gt;/</span>conf
<span style="color: #c20cb9; font-weight: bold;">mv</span> nginx.conf nginx.conf.bak
<span style="color: #c20cb9; font-weight: bold;">nano</span> nginx.conf</pre></div></div>

<p>First we need to set our basic Nginx properties:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">#2 workers x 1024 connections gives us some resiliance and should be enough for most sites.</span>
worker_processes <span style="color: #000000;">2</span>;
&nbsp;
events <span style="color: #7a0874; font-weight: bold;">&#123;</span>
    worker_connections <span style="color: #000000;">1024</span>;
<span style="color: #7a0874; font-weight: bold;">&#125;</span>
&nbsp;
http <span style="color: #7a0874; font-weight: bold;">&#123;</span>
    include             mime.types;
    default_type        application<span style="color: #000000; font-weight: bold;">/</span>octet-stream;	
&nbsp;
    server <span style="color: #7a0874; font-weight: bold;">&#123;</span>
        listen  myport;
        server_name mydomain;
        <span style="color: #666666; font-style: italic;">#You will need to change the next line to something bigger if you want to accept uploads over 5Mb</span>
        client_max_body_size 5m;
    <span style="color: #7a0874; font-weight: bold;">&#125;</span>
<span style="color: #7a0874; font-weight: bold;">&#125;</span></pre></div></div>

<p>Remember to replace myport and mydomain with your actual values from Part 1a!</p>
<p>Next let&#8217;s setup our http server config to serve our static media (You could setup a static only app to serve your media from the main Apache Instance, but let&#8217;s do it this way as a learning exercise.) We are going to add one location for all our static media, and one location just to serve the favicon. Edit the http section to look like this:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">http <span style="color: #7a0874; font-weight: bold;">&#123;</span>
&nbsp;
    include             mime.types;
    default_type        application<span style="color: #000000; font-weight: bold;">/</span>octet-stream;	
&nbsp;
    server <span style="color: #7a0874; font-weight: bold;">&#123;</span>
        listen  myport;
        server_name mydomain;
        client_max_body_size 5m;
&nbsp;
        location <span style="color: #000000; font-weight: bold;">/</span>media<span style="color: #000000; font-weight: bold;">/</span> <span style="color: #7a0874; font-weight: bold;">&#123;</span>
            <span style="color: #7a0874; font-weight: bold;">alias</span> <span style="color: #000000; font-weight: bold;">/</span>home<span style="color: #000000; font-weight: bold;">/&lt;</span>myusername<span style="color: #000000; font-weight: bold;">&gt;/</span>webapps<span style="color: #000000; font-weight: bold;">/&lt;</span>myapp<span style="color: #000000; font-weight: bold;">&gt;/&lt;</span>myproject<span style="color: #000000; font-weight: bold;">&gt;/</span>media<span style="color: #000000; font-weight: bold;">/</span>;
        <span style="color: #7a0874; font-weight: bold;">&#125;</span>
&nbsp;
        location ~<span style="color: #000000; font-weight: bold;">*</span> <span style="color: #000000; font-weight: bold;">/</span>favicon.ico <span style="color: #7a0874; font-weight: bold;">&#123;</span>
            root <span style="color: #000000; font-weight: bold;">/</span>home<span style="color: #000000; font-weight: bold;">/&lt;</span>myusername<span style="color: #000000; font-weight: bold;">&gt;/</span>webapps<span style="color: #000000; font-weight: bold;">/&lt;</span>myapp<span style="color: #000000; font-weight: bold;">&gt;/&lt;</span>myproject<span style="color: #000000; font-weight: bold;">&gt;/</span>media<span style="color: #000000; font-weight: bold;">/</span>img<span style="color: #000000; font-weight: bold;">/</span>;
            <span style="color: #666666; font-style: italic;">#Let's not waste time logging this access...</span>
            access_log off;
        <span style="color: #7a0874; font-weight: bold;">&#125;</span>
    <span style="color: #7a0874; font-weight: bold;">&#125;</span>
<span style="color: #7a0874; font-weight: bold;">&#125;</span></pre></div></div>

<p>Again remember to replace <myusername>, <myapp> and <myproject> with your actual values.</p>
<p>Right now let&#8217;s setup nginx to talk to our fastcgi django process add this section into the configuration file after the favicon.ico location:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">location <span style="color: #000000; font-weight: bold;">/</span> <span style="color: #7a0874; font-weight: bold;">&#123;</span>
    proxy_set_header  	         X-Real-IP  <span style="color: #007800;">$remote_addr</span>;
    proxy_set_header             X-Forwarded-For <span style="color: #007800;">$proxy_add_x_forwarded_for</span>;
    fastcgi_pass                unix:<span style="color: #000000; font-weight: bold;">/</span>home<span style="color: #000000; font-weight: bold;">/&lt;</span>myusername<span style="color: #000000; font-weight: bold;">&gt;/</span>webapps<span style="color: #000000; font-weight: bold;">/&lt;</span>myapp<span style="color: #000000; font-weight: bold;">&gt;/&lt;</span>myproject<span style="color: #000000; font-weight: bold;">&gt;/</span>django.sock;
    fastcgi_pass_header          Authorization;          
    fastcgi_hide_header          X-Accel-Redirect;
    fastcgi_hide_header          X-Sendfile;
    fastcgi_intercept_errors     off;
    include                        fastcgi_params;
<span style="color: #7a0874; font-weight: bold;">&#125;</span></pre></div></div>

<p>Our nginx.conf should now look like this:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">#2 workers x 1024 connections gives us some resiliance and should be enough for most sites.</span>
worker_processes <span style="color: #000000;">2</span>;
&nbsp;
events <span style="color: #7a0874; font-weight: bold;">&#123;</span>
    worker_connections <span style="color: #000000;">1024</span>;
<span style="color: #7a0874; font-weight: bold;">&#125;</span>
&nbsp;
http <span style="color: #7a0874; font-weight: bold;">&#123;</span>
    include             mime.types;
    default_type        application<span style="color: #000000; font-weight: bold;">/</span>octet-stream;	
&nbsp;
    server <span style="color: #7a0874; font-weight: bold;">&#123;</span>
        listen  myport;
        server_name mydomain;
        client_max_body_size 5m;
&nbsp;
        location <span style="color: #000000; font-weight: bold;">/</span>media<span style="color: #000000; font-weight: bold;">/</span> <span style="color: #7a0874; font-weight: bold;">&#123;</span>
           <span style="color: #7a0874; font-weight: bold;">alias</span> <span style="color: #000000; font-weight: bold;">/</span>home<span style="color: #000000; font-weight: bold;">/&lt;</span>myusername<span style="color: #000000; font-weight: bold;">&gt;/</span>webapps<span style="color: #000000; font-weight: bold;">/&lt;</span>myapp<span style="color: #000000; font-weight: bold;">&gt;/&lt;</span>myproject<span style="color: #000000; font-weight: bold;">&gt;/</span>media<span style="color: #000000; font-weight: bold;">/</span>;
        <span style="color: #7a0874; font-weight: bold;">&#125;</span>
&nbsp;
        location ~<span style="color: #000000; font-weight: bold;">*</span> <span style="color: #000000; font-weight: bold;">/</span>favicon.ico <span style="color: #7a0874; font-weight: bold;">&#123;</span>
           root <span style="color: #000000; font-weight: bold;">/</span>home<span style="color: #000000; font-weight: bold;">/&lt;</span>myusername<span style="color: #000000; font-weight: bold;">&gt;/</span>webapps<span style="color: #000000; font-weight: bold;">/&lt;</span>myapp<span style="color: #000000; font-weight: bold;">&gt;/&lt;</span>myproject<span style="color: #000000; font-weight: bold;">&gt;/</span>media<span style="color: #000000; font-weight: bold;">/</span>img<span style="color: #000000; font-weight: bold;">/</span>;
           <span style="color: #666666; font-style: italic;">#Let's not waste time logging this access...</span>
           access_log off;
        <span style="color: #7a0874; font-weight: bold;">&#125;</span>
&nbsp;
        location <span style="color: #000000; font-weight: bold;">/</span> <span style="color: #7a0874; font-weight: bold;">&#123;</span>
            proxy_set_header  	        X-Real-IP  <span style="color: #007800;">$remote_addr</span>;
            proxy_set_header            X-Forwarded-For <span style="color: #007800;">$proxy_add_x_forwarded_for</span>;
            fastcgi_pass                unix:<span style="color: #000000; font-weight: bold;">/</span>home<span style="color: #000000; font-weight: bold;">/&lt;</span>myusername<span style="color: #000000; font-weight: bold;">&gt;/</span>webapps<span style="color: #000000; font-weight: bold;">/&lt;</span>myapp<span style="color: #000000; font-weight: bold;">&gt;/&lt;</span>myproject<span style="color: #000000; font-weight: bold;">&gt;/</span>django.sock;
            fastcgi_pass_header         Authorization;          
            fastcgi_hide_header         X-Accel-Redirect;
            fastcgi_hide_header         X-Sendfile;
            fastcgi_intercept_errors    off;
            include                     fastcgi_params;
        <span style="color: #7a0874; font-weight: bold;">&#125;</span>
    <span style="color: #7a0874; font-weight: bold;">&#125;</span>
<span style="color: #7a0874; font-weight: bold;">&#125;</span></pre></div></div>

<p>We need to make a slight change to the fastcgi_params file that is being included so that it works correctly with Django. Comment out the following line by placing a # in front of it:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">fastcgi_param  SCRIPT_NAME		 <span style="color: #007800;">$fastcgi_script_name</span>;</pre></div></div>

<p>and add this just above it:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">fastcgi_param  PATH_INFO          <span style="color: #007800;">$fastcgi_script_name</span>;</pre></div></div>

<p>You can download the complete sample files here <a href='http://fightingrabbits.com/wp-content/uploads/2009/09/configfiles.zip'>zip</a> / <a href='http://fightingrabbits.com/wp-content/uploads/2009/09/configfiles.tar.gz'>gz</a></p>
<p>Django configuration is pretty simple as we can use the default settings file for now:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;"># Django settings for myproject project.</span>
&nbsp;
DEBUG = True
TEMPLATE_DEBUG = DEBUG
&nbsp;
ADMINS = <span style="color: #7a0874; font-weight: bold;">&#40;</span>
    <span style="color: #666666; font-style: italic;"># ('Your Name', 'your_email@domain.com'),</span>
<span style="color: #7a0874; font-weight: bold;">&#41;</span>
&nbsp;
MANAGERS = ADMINS
&nbsp;
DATABASE_ENGINE = <span style="color: #ff0000;">''</span>           <span style="color: #666666; font-style: italic;"># 'postgresql_psycopg2', 'postgresql', 'mysql', 'sqlite3' or 'oracle'.</span>
DATABASE_NAME = <span style="color: #ff0000;">''</span>             <span style="color: #666666; font-style: italic;"># Or path to database file if using sqlite3.</span>
DATABASE_USER = <span style="color: #ff0000;">''</span>             <span style="color: #666666; font-style: italic;"># Not used with sqlite3.</span>
DATABASE_PASSWORD = <span style="color: #ff0000;">''</span>         <span style="color: #666666; font-style: italic;"># Not used with sqlite3.</span>
DATABASE_HOST = <span style="color: #ff0000;">''</span>             <span style="color: #666666; font-style: italic;"># Set to empty string for localhost. Not used with sqlite3.</span>
DATABASE_PORT = <span style="color: #ff0000;">''</span>             <span style="color: #666666; font-style: italic;"># Set to empty string for default. Not used with sqlite3.</span>
&nbsp;
<span style="color: #666666; font-style: italic;"># Local time zone for this installation. Choices can be found here:</span>
<span style="color: #666666; font-style: italic;"># http://en.wikipedia.org/wiki/List_of_tz_zones_by_name</span>
<span style="color: #666666; font-style: italic;"># although not all choices may be available on all operating systems.</span>
<span style="color: #666666; font-style: italic;"># If running in a Windows environment this must be set to the same as your</span>
<span style="color: #666666; font-style: italic;"># system time zone.</span>
TIME_ZONE = <span style="color: #ff0000;">'America/Chicago'</span>
&nbsp;
<span style="color: #666666; font-style: italic;"># Language code for this installation. All choices can be found here:</span>
<span style="color: #666666; font-style: italic;"># http://www.i18nguy.com/unicode/language-identifiers.html</span>
LANGUAGE_CODE = <span style="color: #ff0000;">'en-us'</span>
&nbsp;
SITE_ID = <span style="color: #000000;">1</span>
&nbsp;
<span style="color: #666666; font-style: italic;"># If you set this to False, Django will make some optimizations so as not</span>
<span style="color: #666666; font-style: italic;"># to load the internationalization machinery.</span>
USE_I18N = True
&nbsp;
<span style="color: #666666; font-style: italic;"># Absolute path to the directory that holds media.</span>
<span style="color: #666666; font-style: italic;"># Example: &quot;/home/media/media.lawrence.com/&quot;</span>
MEDIA_ROOT = <span style="color: #ff0000;">''</span>
&nbsp;
<span style="color: #666666; font-style: italic;"># URL that handles the media served from MEDIA_ROOT. Make sure to use a</span>
<span style="color: #666666; font-style: italic;"># trailing slash if there is a path component (optional in other cases).</span>
<span style="color: #666666; font-style: italic;"># Examples: &quot;http://media.lawrence.com&quot;, &quot;http://example.com/media/&quot;</span>
MEDIA_URL = <span style="color: #ff0000;">''</span>
&nbsp;
<span style="color: #666666; font-style: italic;"># URL prefix for admin media -- CSS, JavaScript and images. Make sure to use a</span>
<span style="color: #666666; font-style: italic;"># trailing slash.</span>
<span style="color: #666666; font-style: italic;"># Examples: &quot;http://foo.com/media/&quot;, &quot;/media/&quot;.</span>
ADMIN_MEDIA_PREFIX = <span style="color: #ff0000;">'/media/'</span>
&nbsp;
<span style="color: #666666; font-style: italic;"># Make this unique, and don't share it with anybody.</span>
SECRET_KEY = <span style="color: #ff0000;">'4#(%&amp;p)^37k2ihr-q-k73qau44ec&amp;8k==gyxb)1+$pck@4+qp='</span>
&nbsp;
<span style="color: #666666; font-style: italic;"># List of callables that know how to import templates from various sources.</span>
TEMPLATE_LOADERS = <span style="color: #7a0874; font-weight: bold;">&#40;</span>
    <span style="color: #ff0000;">'django.template.loaders.filesystem.load_template_source'</span>,
    <span style="color: #ff0000;">'django.template.loaders.app_directories.load_template_source'</span>,
<span style="color: #666666; font-style: italic;">#     'django.template.loaders.eggs.load_template_source',</span>
<span style="color: #7a0874; font-weight: bold;">&#41;</span>
&nbsp;
MIDDLEWARE_CLASSES = <span style="color: #7a0874; font-weight: bold;">&#40;</span>
    <span style="color: #ff0000;">'django.middleware.common.CommonMiddleware'</span>,
    <span style="color: #ff0000;">'django.contrib.sessions.middleware.SessionMiddleware'</span>,
    <span style="color: #ff0000;">'django.contrib.auth.middleware.AuthenticationMiddleware'</span>,
<span style="color: #7a0874; font-weight: bold;">&#41;</span>
&nbsp;
ROOT_URLCONF = <span style="color: #ff0000;">'myproject.urls'</span>
&nbsp;
TEMPLATE_DIRS = <span style="color: #7a0874; font-weight: bold;">&#40;</span>
    <span style="color: #666666; font-style: italic;"># Put strings here, like &quot;/home/html/django_templates&quot; or &quot;C:/www/django/templates&quot;.</span>
    <span style="color: #666666; font-style: italic;"># Always use forward slashes, even on Windows.</span>
    <span style="color: #666666; font-style: italic;"># Don't forget to use absolute paths, not relative paths.</span>
<span style="color: #7a0874; font-weight: bold;">&#41;</span>
&nbsp;
INSTALLED_APPS = <span style="color: #7a0874; font-weight: bold;">&#40;</span>
    <span style="color: #ff0000;">'django.contrib.auth'</span>,
    <span style="color: #ff0000;">'django.contrib.contenttypes'</span>,
    <span style="color: #ff0000;">'django.contrib.sessions'</span>,
    <span style="color: #ff0000;">'django.contrib.sites'</span>,
<span style="color: #7a0874; font-weight: bold;">&#41;</span></pre></div></div>

<p>Finally we need to start our servers:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #7a0874; font-weight: bold;">cd</span> ~<span style="color: #000000; font-weight: bold;">/</span>webapps<span style="color: #000000; font-weight: bold;">/&lt;</span>myapp<span style="color: #000000; font-weight: bold;">&gt;/</span>
.<span style="color: #000000; font-weight: bold;">/</span>sbin<span style="color: #000000; font-weight: bold;">/</span>nginx
<span style="color: #7a0874; font-weight: bold;">cd</span> <span style="color: #000000; font-weight: bold;">&lt;</span>myproject<span style="color: #000000; font-weight: bold;">&gt;</span>
python2.5 manage.py runfcgi <span style="color: #007800;">maxchildren</span>=<span style="color: #000000;">1</span> <span style="color: #007800;">maxspare</span>=<span style="color: #000000;">1</span> <span style="color: #007800;">method</span>=prefork <span style="color: #007800;">socket</span>=<span style="color: #007800;">$PWD</span><span style="color: #000000; font-weight: bold;">/</span>django.sock <span style="color: #007800;">pidfile</span>=<span style="color: #007800;">$PWD</span><span style="color: #000000; font-weight: bold;">/</span>django.pid <span style="color: #000000; font-weight: bold;">&gt;</span> <span style="color: #000000; font-weight: bold;">/</span>dev<span style="color: #000000; font-weight: bold;">/</span>null <span style="color: #000000;">2</span><span style="color: #000000; font-weight: bold;">&gt;&amp;</span><span style="color: #000000;">1</span> $</pre></div></div>

<p>If you haven&#8217;t done it already mount your app in a domain from the webfaction control panel and then browse to the correct url and you should see the following:</p>
<div id="attachment_162" class="wp-caption aligncenter" style="width: 310px"><a href="http://fightingrabbits.com/wp-content/uploads/2009/08/django-app.png"><img src="http://fightingrabbits.com/wp-content/uploads/2009/08/django-app-300x107.png" alt="Django Welcome Screen" title="Django Welcome Screen" width="300" height="107" class="size-medium wp-image-162" /></a><p class="wp-caption-text">Django Welcome Screen</p></div>
<p>So there you have it &#8211; we have installed and configured Nginx + Django however we still have a few thing&#8217;s to do&#8230; In Part 2 I&#8217;ll show you a couple of ways to make sure that our site isn&#8217;t down for long if the web-server is rebooted or Django crashes.</p>
<p>In Part 3 I&#8217;ll show you how to hand off file uploads to Nginx and get a fancy upload progress bar into the bargin :D</p>
<p>This post was brought to you by the letters L and A and the following websites.</p>
<p><a href="http://forum.webfaction.com/viewtopic.php?id=1981">http://forum.webfaction.com/viewtopic.php?id=1981</a></p>
<p><a href="https://calomel.org/nginx.html">https://calomel.org/nginx.html</a></p>
]]></content:encoded>
			<wfw:commentRss>http://fightingrabbits.com/archives/160/feed</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
	</channel>
</rss>
