<?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>/kb &#187; apache</title>
	<atom:link href="http://grx.no/kb/tag/apache/feed/" rel="self" type="application/rss+xml" />
	<link>http://grx.no/kb</link>
	<description>personal knowledgebase</description>
	<lastBuildDate>Mon, 06 Feb 2012 17:05:03 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Chapter 7 in &#8220;Python Web Development with Django&#8221; &#8211; some notes</title>
		<link>http://grx.no/kb/2009/03/08/chapter-7-in-python-web-development-with-django-some-notes/</link>
		<comments>http://grx.no/kb/2009/03/08/chapter-7-in-python-web-development-with-django-some-notes/#comments</comments>
		<pubDate>Sun, 08 Mar 2009 18:08:07 +0000</pubDate>
		<dc:creator>Morten Wergeland Hansen</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[apache]]></category>
		<category><![CDATA[django]]></category>
		<category><![CDATA[framework]]></category>
		<category><![CDATA[python]]></category>
		<category><![CDATA[web]]></category>

		<guid isPermaLink="false">http://grx.no/kb/?p=103</guid>
		<description><![CDATA[I am currently in the process of learning Django and have just finished chapter 7 in Python Web Development with Django. Here are some notes on how I got it working (except for the index page which still isn&#8217;t completely as expected) on an ubuntu hardy installation. The photo gallery example assumes an apache2 + [...]]]></description>
			<content:encoded><![CDATA[<p>I am currently in the process of learning Django and have just finished chapter 7 in <a href="http://withdjango.com">Python Web Development with Django</a>. Here are some notes on how I got it working (except for the index page which still isn&#8217;t completely as expected) on an ubuntu hardy installation.</p>
<p>The photo gallery example assumes an <em>apache2</em> + <em>mod_python</em> setup. I didn&#8217;t really find it straightforward to get this running from the description in the appendix, so here is how I got it to work (after installation of <em>apache2</em> and <em>mod_python</em>, of course):</p>
<p>In <em>/etc/apache2/sites-available/default</em>, change lines:</p>
<pre>        &lt;Directory /var/www/&gt;
                Options Indexes FollowSymLinks MultiViews
                AllowOverride None
                Order allow,deny
                allow from all
        &lt;/Directory&gt;</pre>
<p>To:</p>
<pre>        &lt;Directory /var/www/&gt;
                Options Indexes FollowSymLinks MultiViews
                AllowOverride AuthConfig
                Order allow,deny
                allow from all

                AddHandler mod_python .py
                PythonHandler mod_python.publisher
                PythonDebug On
        &lt;/Directory&gt;</pre>
<p>Then I did the changes in <em>/etc/apache2/httpd.conf</em>, but slightly different from the book by adding a <code>PythonOption django.root</code> (didn&#8217;t work for me with the setup in the book):</p>
<pre>&lt;Location "/gallery/"&gt;
      SetHandler python-program
      PythonHandler django.core.handlers.modpython
      SetEnv DJANGO_SETTINGS_MODULE gallery.settings
      PythonOption django.root /gallery
      PythonDebug On
      PythonPath "['/path/to/django/root', '/home/user/django-stuff'] + sys.path"
&lt;/Location&gt;</pre>
<p>With an additional entry for media files:</p>
<pre>&lt;Location "/gallery/media"&gt;
      SetHandler none
&lt;/Location&gt;</pre>
<p>Now, I created a directory <em>/var/www/gallery</em> and a <em>/var/www/gallery/media</em> like explained in &#8220;Preparing for File Uploads&#8221; and edited <em>settings.py</em>:</p>
<p><code>MEDIA_ROOT = '/var/www/gallery/media/'</code><br />
<code>MEDIA_URL = 'http://localhost/gallery/media/'</code><br />
<code>ADMIN_MEDIA_PREFIX = 'http://localhost/gallery/media/admin/'</code></p>
<p>Where admin is a symbolic link (<em>/var/www/gallery/media/admin</em>) to the admin media directory in the Django installation. The two last entries where not mentioned in the book, but they made it work&#8230;</p>
<p>With the settings described above and the <code>PythonOption django.root</code> in <em>httpd.conf</em>, I didn&#8217;t need the section about DRY URLs. And it worked &#8211; as opposed to the stuff in the book.</p>
<p>With all the configuration stuff in place I typed the code outlined in the chapter and to begin with I couldn&#8217;t see any photos, except for the <code>thumb_url</code> in <em>items_list.html</em> (typo: <em>items_listing.html</em> in the last paragraph page 175). I managed to get it working by changing some lines in <em>items_detail.html</em> and <em>photos_detail.html</em> though:</p>
<pre>22                 &lt;img src="{{ photo.image.thumb_url }}" /&gt;</pre>
<p>instead of</p>
<pre>22                 &lt;img src="{{ photo.get_image_thumb_url }}" /&gt;</pre>
<p>and</p>
<pre>8 &lt;img src="{{ object.image.url }}" /&gt;</pre>
<p>instead of:</p>
<pre>8 &lt;img src="{{ object.get_image_url }}" /&gt;</pre>
<p>The alternatives that worked seems more intuitive to me.</p>
<p>I also imported <code>list_detail</code> from <code>django.views.generic</code> in <em>urls.py</em>, but am not sure if this was needed. The photo gallery seems to work fine except for the thumbnails in <em>index.html</em>. I&#8217;ve noticed that the code in <em>urls.py</em> for that template is different from the others, using <code>simple.direct_to_template</code>, but I haven&#8217;t managed getting that part to work.</p>
<p>Thanks to this thread for getting mod_python up and running: <a href="http://ubuntuforums.org/showthread.php?t=91101">Python and Apache2</a></p>
]]></content:encoded>
			<wfw:commentRss>http://grx.no/kb/2009/03/08/chapter-7-in-python-web-development-with-django-some-notes/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Restart Apache</title>
		<link>http://grx.no/kb/2008/08/12/restart-apache/</link>
		<comments>http://grx.no/kb/2008/08/12/restart-apache/#comments</comments>
		<pubDate>Mon, 11 Aug 2008 22:02:41 +0000</pubDate>
		<dc:creator>hgrimelid</dc:creator>
				<category><![CDATA[Server]]></category>
		<category><![CDATA[apache]]></category>
		<category><![CDATA[ubuntu]]></category>

		<guid isPermaLink="false">http://grx.no/kb/?p=36</guid>
		<description><![CDATA[I always forget how to stop/start/restart Apache (on Ubuntu), so here it is: sudo /etc/init.d/apache2 stop sudo /etc/init.d/apache2 start sudo /etc/init.d/apache2 restart]]></description>
			<content:encoded><![CDATA[<p>I always forget how to stop/start/restart Apache (on Ubuntu), so here it is:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">sudo</span> <span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>init.d<span style="color: #000000; font-weight: bold;">/</span>apache2 stop</pre></div></div>


<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">sudo</span> <span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>init.d<span style="color: #000000; font-weight: bold;">/</span>apache2 start</pre></div></div>


<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">sudo</span> <span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>init.d<span style="color: #000000; font-weight: bold;">/</span>apache2 restart</pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://grx.no/kb/2008/08/12/restart-apache/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>php5-imagick error in Ubuntu 8.04</title>
		<link>http://grx.no/kb/2008/07/17/php5-imagick-error-in-ubuntu-804/</link>
		<comments>http://grx.no/kb/2008/07/17/php5-imagick-error-in-ubuntu-804/#comments</comments>
		<pubDate>Thu, 17 Jul 2008 11:42:17 +0000</pubDate>
		<dc:creator>hgrimelid</dc:creator>
				<category><![CDATA[Server]]></category>
		<category><![CDATA[apache]]></category>
		<category><![CDATA[bug]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[php5]]></category>
		<category><![CDATA[ubuntu]]></category>

		<guid isPermaLink="false">http://grx.no/kb/?p=22</guid>
		<description><![CDATA[I got the following error message, caused by a bug in Ubuntu.: PHP Warning: PHP Startup: Unable to load dynamic library '/usr/lib/php5/20060613+lfs/imagick.so' - libWand.so.9: cannot open shared object file: No such file or directory in Unknown on line 0 finished. Here&#8217;s the solution.]]></description>
			<content:encoded><![CDATA[<p>I got the following error message, <a href="https://bugs.launchpad.net/ubuntu/+source/php-imagick/+bug/203023">caused by a bug in Ubuntu</a>.:</p>
<pre>PHP Warning:  PHP Startup: Unable to load dynamic library
'/usr/lib/php5/20060613+lfs/imagick.so' -
libWand.so.9: cannot open shared object file:
No such file or directory in Unknown on line 0 finished.</pre>
<p><a href="http://kevin.vanzonneveld.net/techblog/article/class_imagick_not_found/">Here&#8217;s the solution</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://grx.no/kb/2008/07/17/php5-imagick-error-in-ubuntu-804/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Allow cgi scripts globally</title>
		<link>http://grx.no/kb/2008/04/23/allow-cgi-scripts-globally/</link>
		<comments>http://grx.no/kb/2008/04/23/allow-cgi-scripts-globally/#comments</comments>
		<pubDate>Wed, 23 Apr 2008 10:41:02 +0000</pubDate>
		<dc:creator>hgrimelid</dc:creator>
				<category><![CDATA[Server]]></category>
		<category><![CDATA[apache]]></category>
		<category><![CDATA[cgi]]></category>
		<category><![CDATA[httpd.conf]]></category>

		<guid isPermaLink="false">http://k.grx.no/?p=9</guid>
		<description><![CDATA[I run Apache on my Macbook and want to be able to run my cgi scripts from everywhere. All directories I want to access are symlinked from the DocumentRoot (/Library/WebServer/Documents) and the only thing necessary is to add the following directive for this section in httpd.conf: Options ExecCGI]]></description>
			<content:encoded><![CDATA[<p>I run Apache on my Macbook and want to be able to run my cgi scripts from everywhere. All directories I want to access are symlinked from the DocumentRoot (<em>/Library/WebServer/Documents</em>) and the only thing necessary is to add the following directive for this section in <em>httpd.conf</em>:</p>
<pre language="apache">Options ExecCGI</pre>
<p></p>
]]></content:encoded>
			<wfw:commentRss>http://grx.no/kb/2008/04/23/allow-cgi-scripts-globally/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

