<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/css" href="/stylesheets/rss.css"?>
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/">
  <channel>
    <title>Straight Ornamental: Category Apache</title>
    <link>http://grahamstratton.org/blog/public/articles/category/apache</link>
    <language>en-us</language>
    <ttl>40</ttl>
    <description>Ramblings from a rambler</description>
    <item>
      <title>mod_python grief</title>
      <description>&lt;p&gt;I decided that I wanted to put a Pylons application behind Apache. After the grief I had with Rails, I wasn&amp;#8217;t keen to use fcgi.  So I decided to try the mod_python approach, which is generally significantly faster anyway.&lt;/p&gt;


	&lt;p&gt;Since a Pylons app is a &lt;span class="caps"&gt;WSGI&lt;/span&gt; app, this should be trivial. The first thing to do was to install mod_python, a standard download, configure, compile and install.  Then the &lt;span class="caps"&gt;WSGI&lt;/span&gt; app must be made suitable for deployment via mod_python. There is a project to create a &lt;a href="http://projects.amor.org/misc/wiki/ModPythonGateway"&gt;mod_python gateway&lt;/a&gt;, but for some reason this wasn&amp;#8217;t included in the latest version of mod_python. So I downloaded it, and saved it as mod_python/wsgi.py.&lt;/p&gt;


	&lt;p&gt;Then I created a two-liner python program startup.py:&lt;/p&gt;


&lt;pre&gt;
from paste.deploy import loadapp
app = loadapp("config:/home/graham/flightsearch/deployment.ini")
&lt;/pre&gt;

	&lt;p&gt;Then I had to configure apache.&lt;/p&gt;


&lt;pre&gt;
&amp;lt;Location /flightsearch&amp;gt;
  SetHandler mod_python
  PythonHandler mod_python.wsgi
  PythonPath "['/home/graham/flightsearch'] + sys.path" 
  PythonOption wsgi.application startup::app
&amp;lt;/Location&amp;gt;
&lt;/pre&gt;

	&lt;p&gt;I did all this and, erm, it didn&amp;#8217;t work.  In fact, I had segmentation faults in my Apache error log.  A lot of Googling suggested a lot of possible reasons. It turned out to be that Apache uses the version of libexpat installed on the system, whereas python 2.4 ships with its own (later) version.  This could just be an issue because the system is old (Fedora Core 1).  Anyway, for some reason replacing the libraries on the system with the same version as python was using, and sym-linking them appropriately was enough to get things working.&lt;/p&gt;


	&lt;p&gt;Finally, Apache needs to be given access to some data and lock files associated with the application.&lt;/p&gt;</description>
      <pubDate>Thu, 10 Aug 2006 00:27:11 +0000</pubDate>
      <guid isPermaLink="false">urn:uuid:93565364-5577-4244-a7ce-ee52a09aa159</guid>
      <author>Graham Stratton</author>
      <link>http://grahamstratton.org/blog/public/articles/2006/08/10/mod_python-grief</link>
      <category>Python</category>
      <category>Apache</category>
      <category>Pylons</category>
    </item>
  </channel>
</rss>
