<?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>Django foo &#187; apache</title>
	<atom:link href="http://www.djangofoo.com/tag/apache/feed" rel="self" type="application/rss+xml" />
	<link>http://www.djangofoo.com</link>
	<description>Django Tips and Tweaks</description>
	<lastBuildDate>Wed, 18 Aug 2010 09:38:20 +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>Django and mod_wsgi deploy example</title>
		<link>http://www.djangofoo.com/17/django-mod_wsgi-deploy-exampl</link>
		<comments>http://www.djangofoo.com/17/django-mod_wsgi-deploy-exampl#comments</comments>
		<pubDate>Wed, 13 Jan 2010 14:22:39 +0000</pubDate>
		<dc:creator>Davo</dc:creator>
				<category><![CDATA[Django]]></category>
		<category><![CDATA[apache]]></category>
		<category><![CDATA[httpd]]></category>
		<category><![CDATA[mod_wsgi]]></category>
		<category><![CDATA[wsgi]]></category>

		<guid isPermaLink="false">http://www.djangofoo.com/?p=17</guid>
		<description><![CDATA[So what do we do next when we finished to develop(debug, debug&#8230; debug&#8230;!) our application? We go and deploy it of course! Well, a common choice of deploying Django application is to use Apache httpd and mod_wsgi. Let&#8217;s suppose the following scenario: our application name is marina our application is placed inside /home/ directory our [...]]]></description>
			<content:encoded><![CDATA[<p>So what do we do next when we finished to develop(debug, debug&#8230; debug&#8230;!) our application? We go and deploy it of course!<br />
Well, a common choice of deploying Django application is to use <a href="http://httpd.apache.org/" target="_new" title="Apache Http Server">Apache httpd</a> and <a href="http://code.google.com/p/modwsgi/"  target="_new" title="Mod wsgi for Apache">mod_wsgi</a>.</p>
<p>Let&#8217;s suppose the following scenario:</p>
<ul>
<li>our application name is <strong>marina</strong></li>
<li>our application is placed inside <strong>/home/ </strong>directory</li>
<li>our static files (javascript, images, css etc&#8230;) are inside <strong>/home/marina/media/</strong></li>
</ul>
<p>The first step is to create the WSGI file and place it inside <strong>/home/marina/</strong><br />
With the following content:</p>
<pre class="brush: python">#!/usr/local/bin/python
import os, sys
sys.path.append('/home/')
sys.path.append('/home/marina/')
os.environ['DJANGO_SETTINGS_MODULE'] = 'settings'  # this is your settings.py file
os.environ['PYTHON_EGG_CACHE'] = '/tmp'

import django.core.handlers.wsgi

application = django.core.handlers.wsgi.WSGIHandler()
</pre>
<p>The second step is to edit your <strong>httpd.conf</strong> and add the following lines.</p>
<pre class="brush: python">

&lt;Directory "/home/marina/media"&gt;
   Order deny,allow
   Allow from all
&lt;/Directory&gt;

&lt;Directory "/home/marina"&gt;
    AllowOverride All
    Order deny,allow
    Allow from all
&lt;/Directory&gt;

Alias /media/ /home/marina/media/
ServerAdmin admin@djangofoo.com
ErrorLog "logs/marina.com-error_log"
CustomLog "logs/marina.com-access_log" common
# mod_wsgi configuration is here
# we are running as user/group 'deamon', if you don't have those you need to change or create.
WSGIDaemonProcess marina user=daemon group=daemon processes=2 threads=25
WSGIProcessGroup marina
# this is our WSGI file.
WSGIScriptAlias / /home/marina/marina.wsgi
</pre>
<p>We need to be sure that our folder is readable by the &#8216;<strong>daemon</strong>&#8216; user</p>
<pre class="brush: python">chown -R daemon /home/marina
</pre>
<p>NOTE: if you are using <strong>/media/</strong> to store all the static files be sure you have this inside your settings.py</p>
<pre class="brush: python">ADMIN_MEDIA_PREFIX = '/admin_media/' # by default this is /media/ which conflicts with our /media/ !!
</pre>
<p>And finally don&#8217;t forget to <strong>restart your apache</strong>.</p>
<p>If you still have issues to run a Django application its worth checking the <strong>error logs</strong>.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.djangofoo.com/17/django-mod_wsgi-deploy-exampl/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

