<?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>Joe Maller &#187; Apache</title>
	<atom:link href="http://joemaller.com/tag/apache/feed/" rel="self" type="application/rss+xml" />
	<link>http://joemaller.com</link>
	<description>.com</description>
	<lastBuildDate>Fri, 27 Jan 2012 06:04:17 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3</generator>
		<item>
		<title>Django via CGI on shared hosting</title>
		<link>http://joemaller.com/1467/django-via-cgi-on-shared-hosting/</link>
		<comments>http://joemaller.com/1467/django-via-cgi-on-shared-hosting/#comments</comments>
		<pubDate>Mon, 07 Dec 2009 03:40:33 +0000</pubDate>
		<dc:creator>Joe</dc:creator>
				<category><![CDATA[Web Development]]></category>
		<category><![CDATA[Apache]]></category>
		<category><![CDATA[cgi]]></category>
		<category><![CDATA[django]]></category>
		<category><![CDATA[Python]]></category>
		<category><![CDATA[shared hosting]]></category>

		<guid isPermaLink="false">http://joemaller.com/?p=1467</guid>
		<description><![CDATA[Django just isn&#8217;t designed to run under CGI. It won&#8217;t run under OS/2, either.* Well ok, but running Django under CGI is not impossible. It just kind of really sucks. But anyway, to prove it&#8217;s possible if not workable, here&#8217;s how I got it running on two standard cPanel shared hosts using plain old slow [...]]]></description>
			<content:encoded><![CDATA[<blockquote><p>Django just isn&#8217;t designed to run under CGI.<br />
It won&#8217;t run under OS/2, either.<a href="http://code.djangoproject.com/ticket/2407#comment:21">*</a>
</p></blockquote>
<p>Well ok, but running Django under CGI is not <em>impossible</em>. It just kind of really sucks. But anyway, to prove it&#8217;s possible if not workable, here&#8217;s how I got it running on two standard cPanel shared hosts using plain old slow and clunky CGI.</p>
<h3> virtualenv</h3>
<p>First, install <a href="http://virtualenv.openplans.org/">virtualenv</a>. This makes locally managing modules fantastically easy by creating self-contained Python virtual environments. Installing couldn&#8217;t be simpler: Get the script, run the script, source your environment. </p>
<pre><code>$ mkdir ~/src &amp;&amp; cd ~/src
$ curl -LO http://bitbucket.org/ianb/virtualenv/get/tip.gz
$ tar -xvzf tip.gz
$ python virtualenv/virtualenv.py --distribute ~/python_virtualenv
<span class="output">New python executable in /home/joe/python_virtualenv/bin/python
Installing distribute.............................................
..................................................done.
</span>
$ source ~/python_virtualenv/bin/activate </code></pre>
<p>Now, install Django using <a href="http://pip.openplans.org/">pip</a>, which was automatically installed by virtualenv. After sourcing the virtual environment, this works from anywhere. </p>
<pre><code>$ pip install Django
<span class="output">Downloading/unpacking Django
  Downloading Django-1.1.1.tar.gz (5.6Mb): 5.6Mb downloaded
  Running setup.py egg_info for package Django
Installing collected packages: Django
  Running setup.py install for Django
    changing mode of build/scripts-2.4/django-admin.py from 664 to 775
    changing mode of /home/joe/python_virtualenv/bin/django-admin.py to 775
Successfully installed Django</span></code></pre>
<p>If your host doesn&#8217;t block GCC, use pip to be sure your MySQL interface (MySQLdb) is up to date:</p>
<pre><code>$ pip install -U MySQL-python
<span class="output">...
Successfully installed MySQL-python
</span></code></pre>
<p>Django requires MySQLdb version <a href='http://docs.djangoproject.com/en/dev/topics/install/#get-your-database-running'>1.2.1p2 or higher</a>.</p>
<p><a href="http://tools.assembla.com/yolk/">Yolk</a> prints a nice, clean list of everything installed in your Python environment, install and run:</p>
<pre><code>$ pip install yolk
$ yolk -l
<span class="output">
Django          - 1.1.1        - active
MySQL-python    - 1.2.3c1      - active
pip             - 0.6.1        - active
setuptools      - 0.6c11       - active
yolk            - 0.4.1        - active
</span></code></pre>
<p>At this point, I started a new Django project, assigned a database and filled in the necessary values in settings.py. I put the Django project files into the virtual environment to keep everything in the same place. This might not be the best practice, but it makes sense to me.</p>
<pre><code>$ cd ~/python_virtualenv/
$ django-admin.py startproject testproject</code></pre>
<p>The sane part is finished, now onto the kludgery.</p>
<h3>Django.cgi</h3>
<p>All the CGI shim solutions I found pointed back to a script Paul Sargent uploaded to ticket 2407 back in summer of 2006. It still works: <a href="http://code.djangoproject.com/attachment/ticket/2407/django.cgi">django.cgi</a></p>
<p>Three lines need editing:</p>
<p><strong>Line 1:</strong> Point the CGI&#8217;s shebang to the virtualenv Python binary.</p>
<pre><code>#!<strong>/home/joe/python_virtualenv/bin/python</strong></code></pre>
<p><strong>Line 95:</strong> Add the directory above the Django project directory to Python&#8217;s sys.path. </p>
<pre><code>sys.path.append("<strong>/home/joe/python_virtualenv</strong>")</code></pre>
<p><strong>Line 97:</strong> Add the project&#8217;s settings to os.environ.</p>
<pre><code>os.environ['DJANGO_SETTINGS_MODULE'] = '<strong>testproject.settings</strong>'</code></pre>
<h3>htaccess</h3>
<p>For Django to respond to URL requests, those urls need to be fed into the django.cgi script. For testing I routed everything from /django to the cgi script by adding the following lines to my top-level htaccess file:</p>
<pre><code>RewriteEngine on
RewriteRule ^cgi-bin/ - [L]
RewriteRule ^django/(.*)$ /cgi-bin/django.cgi/$1 [QSA,L]</code></pre>
<p>The second line isn&#8217;t necessary unless pulling Django urls from the webroot, without it, the redirects would loop.</p>
<p>At this point, the Django site should load from /django/&#8230; urls.</p>
<p>Finally, as a quick fix for admin media files, I symlinked Django&#8217;s admin media directory from my web root:</p>
<pre><code>ln -s ~/python_virtualenv/lib/python2.4/site-packages/django/contrib/admin/media ~/www/media</code></pre>
<h3>Conclusion</h3>
<p>I spent quite a few hours spread across a couple days researching and figuring out how to get the first install working. The second installation only took about 5 minutes from start until editing Django&#8217;s admin pages.</p>
<p>Running Django through CGI is possible, but it is <em>dog slow</em>. There appears to be some caching after the first request, but that first page load often takes an excruciatingly long time.</p>
<h3>Further reading, possible improvements</h3>
<ul>
<li><a href='http://docs.python.org/library/wsgiref.html'>21.4. wsgiref — WSGI Utilities and Reference Implementation — Python v2.6.4 documentation</a></li>
<li><a href='http://www.djangosnippets.org/snippets/1307/'>Django snippets: django under apache / mod_fcgid</a></li>
</ul>
<p>The servers I was working with are both running the almost six year old <a href="http://www.python.org/download/releases/2.4.3/NEWS.txt">Python 2.4.3</a>. The wsigref  module was introduced with Python 2.5. My goal was to get Django running without compiling anything since some hosts deny access to GCC.</p>
<h3>References</h3>
<p>These sites were helpful in figuring this out.
<ul>
<li><a href='http://www.saltycrane.com/blog/2009/05/notes-using-pip-and-virtualenv-django/'>Notes on using pip and virtualenv with Django « SaltyCrane Blog </a></li>
<li><a href='http://jeffcroft.com/blog/2006/may/11/django-dreamhost/'>JeffCroft.com: Setting up Django on Dreamhost</a></li>
<li><a href='http://seamusc.com/blog/2007/jun/11/how-get-django-working-digiwebie-using-djangocgi/'>seamusc.com &#8211; How to get Django working on digiweb.ie using django.cgi</a></li>
<li><a href='https://www.lithiumhosting.com/billing/knowledgebase/18/How-to-install-Django-on-a-basic-shared-hosting-plan-with-plain-CGI.html'>Lithium Hosting &#8211; Knowledgebase &#8211; How to install Django on a basic shared hosting plan with plain CGI</a></li>
<li><a href='http://www.petersmith.org/blog/archives/2007/09/some-time-ago-i-played.html'>Django revisited &#8211; PeterSmith: Blog</a></li>
</ul>
<p>The two hosts I tested on were <a href="http://www.liquidweb.com/?RID=joemaller">LiquidWeb</a> and <a href="http://www.a2hosting.com/1482.html">A2Hosting</a>. Both have been excellent, dependable hosts. Neither has any Python support to speak of on their shared plans. A2 blocks access to GCC.</p>
]]></content:encoded>
			<wfw:commentRss>http://joemaller.com/1467/django-via-cgi-on-shared-hosting/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Microsoft and Yahoo: LAMP, meet WAMP</title>
		<link>http://joemaller.com/882/microsoft-and-yahoo-lamp-meet-wamp/</link>
		<comments>http://joemaller.com/882/microsoft-and-yahoo-lamp-meet-wamp/#comments</comments>
		<pubDate>Mon, 04 Feb 2008 08:33:09 +0000</pubDate>
		<dc:creator>Joe</dc:creator>
				<category><![CDATA[misc.]]></category>
		<category><![CDATA[Apache]]></category>
		<category><![CDATA[LAMP]]></category>
		<category><![CDATA[microsoft]]></category>
		<category><![CDATA[open source]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[yahoo]]></category>

		<guid isPermaLink="false">http://joemaller.com/2008/02/04/microsoft-and-yahoo-lamp-meet-wamp/</guid>
		<description><![CDATA[After the obvious desire to takeover Yahoo&#8217;s unmatched traffic, the thing that most struck me about Microsoft&#8217;s proposed Yahoo! acquisition was what they&#8217;d do with Yahoo&#8217;s extensive foundation of Open Source Software. Historically, Microsoft has had a deep institutional phobia about OSS. But Yahoo! uses PHP extensively, and Rasmus Lerdorf, the creator of PHP, has [...]]]></description>
			<content:encoded><![CDATA[<p>After the obvious desire to takeover Yahoo&#8217;s unmatched traffic, the thing that most struck me about Microsoft&#8217;s proposed Yahoo! acquisition was what they&#8217;d do with Yahoo&#8217;s extensive foundation of Open Source Software. </p>
<p>Historically, Microsoft has had a deep institutional phobia about OSS. But <a href="http://public.yahoo.com/bfrance/radwin/talks/yahoo-phpcon2002.htm">Yahoo! uses PHP</a> extensively, and <a href="http://en.wikipedia.org/wiki/Rasmus_Lerdorf">Rasmus Lerdorf</a>, the creator of PHP, has worked at Yahoo! since 2002. </p>
<p>This seems to make no sense. Unless the OSS and PHP backend is something Microsoft wants. </p>
<p>On January 31st, <a href="http://blogs.zdnet.com/microsoft/?p=1142">Mary Jo Foley published notes</a> from an interview with Sam Ramji, Microsoft’s Director of Platform Technology Strategy. Foley rightly highlighted this quote from Ramji:</p>
<blockquote><p>&#8220;Our focus is getting OSS on top of Windows, and I’m focused on (providing) interoperability between the LAMP (Linux, Apache, MySQL, PHP) and Windows stacks.&#8221;</p></blockquote>
<p>She also posted this PowerPoint slide:<br />
<a href="http://www.flickr.com/photos/joemaller/2241622722/" title="LAMP, meet WAMP by Joe Maller, on Flickr"><img src="http://farm3.static.flickr.com/2411/2241622722_d7606cbd5e.jpg" width="425" alt="LAMP, meet WAMP" /></a></p>
<p>Boom, as they say. Microsoft wants to legitimize Windows as the foundation for a parallel WAMP stack. What better way to prove the viability of WAMP than running the biggest PHP web site in the world?</p>
<p>Microsoft may have finally realized that Open Source can be seen as a competitor, but also as free labor. Google and Apple, along with Yahoo! realized that a long time ago. Why try and compete directly when you can subvert it by becoming the dominant platform that software runs on? Instant credibility, and instant influence.</p>
<p>So far we&#8217;ve only seen the first chapter of this story, or perhaps the first act of this tragedy.  The next phase looks like it may turn out to be <a href="http://www.microsoft.com/presspass/press/2008/feb08/02-03statement.mspx">Microsoft</a>, <a href="http://googleblog.blogspot.com/2008/02/yahoo-and-future-of-internet.html">Google</a> and others fighting over Yahoo&#8217;s unfortunate carcass and tearing it to shreds. </p>
<p>Steve Ballmer has giant brass balls and Microsoft most likely anticipated that Google would do something to interfere with the acquisition. Microsoft is on the move. This should be an interesting week.</p>
<blockquote><p><strong>Disclosure:</strong> I&#8217;m currently holding Yahoo! stock and have previously owned stock in Microsoft.
</p></blockquote>
]]></content:encoded>
			<wfw:commentRss>http://joemaller.com/882/microsoft-and-yahoo-lamp-meet-wamp/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Multiple RegisterResource directives broken in Leopard</title>
		<link>http://joemaller.com/859/multiple-registerresource-directives-broken-in-leopard/</link>
		<comments>http://joemaller.com/859/multiple-registerresource-directives-broken-in-leopard/#comments</comments>
		<pubDate>Tue, 04 Dec 2007 21:49:03 +0000</pubDate>
		<dc:creator>Joe</dc:creator>
				<category><![CDATA[Apple]]></category>
		<category><![CDATA[Mac OS X]]></category>
		<category><![CDATA[Web Development]]></category>
		<category><![CDATA[10.5]]></category>
		<category><![CDATA[Apache]]></category>
		<category><![CDATA[httpd]]></category>
		<category><![CDATA[leopard]]></category>

		<guid isPermaLink="false">http://joemaller.com/2007/12/04/multiple-registerresource-directives-broken-in-leopard/</guid>
		<description><![CDATA[This is sort of a follow up on the old mod_rendezvous article I wrote for O&#8217;Reilly. While cleaning up my virtual hosts I discovered a bug in 10.5&#8242;s handling of multiple RegisterResource directives in mod_bonjour. This is expanded from a bug report I submitted to Apple (rdar://problem/5628484). I keep functional mirrors all my development sites [...]]]></description>
			<content:encoded><![CDATA[<p>This is sort of a follow up on the old <a href="http://www.macdevcenter.com/pub/a/mac/2003/04/08/mod_rendezvous.html">mod_rendezvous article I wrote for O&#8217;Reilly</a>. While cleaning up my virtual hosts I discovered a bug in 10.5&#8242;s handling of multiple RegisterResource directives in mod_bonjour. This is expanded from a bug report I submitted to Apple (rdar://problem/5628484).</p>
<p>I keep functional mirrors all my development sites in separate Apache Virtual Hosts. Each one then gets it&#8217;s own port, which allows me to check them on local networks, in Parallels and, if I want, remotely via IP address.</p>
<p>To advertise two local vhosts over bonjour, something like this in httpd.conf should work:</p>
<pre><code>&amp;lt;IfModule bonjour_module&amp;gt;
RegisterResource "Site 1" / 9001
RegisterResource "Site 2" / 9002
&amp;lt;/IfModule&amp;gt;</code></pre>
<p>After restarting Apache (<code>sudo apachectl graceful</code>), local copies of Safari should see the two sites, &#8220;Site 1&#8243; and &#8220;Site 2&#8243; in Bonjour bookmark listings. In 10.4, they show up. In 10.5, only &#8220;Site 2&#8243; shows up. No matter how many directives are included, only the last one will be visible.</p>
<p>I&#8217;d love to be wrong about this, but it seems that something broke this function in Leopard.</p>
<p>A faster way of checking Bonjour entries is to open a terminal window and run the following command:</p>
<p><code>mdns -B _http._tcp</code></p>
<p>That will show a live updating list of current multicast (Bonjour) entries. Under 10.4, I get the following after adding the above directives to httpd.conf:</p>
<pre><code>16:10:14.517  Add     0 local.     _http._tcp.     Site 1
16:10:14.667  Add     0 local.     _http._tcp.     Site 2</code></pre>
<p>However with 10.5, I get this:</p>
<pre><code>16:12:52.597  Add     1 local.     _http._tcp.     Site 2
16:12:52.598  Add     1 local.     _http._tcp.     Site 2
16:12:52.598  Add     0 local.     _http._tcp.     Site 2</code></pre>
<p>What I&#8217;d really love to do is figure out how to register and respond to multiple Bonjour names. That way I could have each vhost  be a named host and each staged site accessible at a url like site1.local and site2.local. So far I haven&#8217;t had any luck getting that working.</p>
]]></content:encoded>
			<wfw:commentRss>http://joemaller.com/859/multiple-registerresource-directives-broken-in-leopard/feed/</wfw:commentRss>
		<slash:comments>10</slash:comments>
		</item>
	</channel>
</rss>

<!-- Performance optimized by W3 Total Cache. Learn more: http://www.w3-edge.com/wordpress-plugins/

Database Caching 1/18 queries in 0.017 seconds using disk: basic
Object Caching 329/368 objects using disk: basic

Served from: joemaller.com @ 2012-02-08 12:34:48 -->

<!-- W3 Total Cache: Page cache debug info:
Engine:             disk: enhanced
Cache key:          tag/apache/feed/_index.xml_gzip
Caching:            enabled
Status:             not cached
Creation Time:      0.484s
Header info:
Set-Cookie:         bb2_screener_=1328722488+38.107.179.216+38.107.179.216; path=/
X-Pingback:         http://joemaller.com/wordpress/xmlrpc.php
Content-Type:       text/xml; charset=UTF-8
Last-Modified:      Wed, 08 Feb 2012 17:34:48 GMT
Vary:               Accept-Encoding, Cookie
Expires:            Wed, 08 Feb 2012 18:34:48 GMT
Pragma:             public
Cache-Control:      public, must-revalidate, proxy-revalidate
Etag:               bc3e4a3673fc1ff6beb13f39380a3d7a
X-Powered-By:       W3 Total Cache/0.9.2.4
Content-Encoding:   gzip
-->
