<?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; shared hosting</title>
	<atom:link href="http://joemaller.com/tag/shared-hosting/feed/" rel="self" type="application/rss+xml" />
	<link>http://joemaller.com</link>
	<description>.com</description>
	<lastBuildDate>Tue, 15 May 2012 03:40:33 +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>Building Python on Shared Hosting</title>
		<link>http://joemaller.com/1717/building-python-on-shared-hosting/</link>
		<comments>http://joemaller.com/1717/building-python-on-shared-hosting/#comments</comments>
		<pubDate>Wed, 24 Mar 2010 19:29:02 +0000</pubDate>
		<dc:creator>Joe</dc:creator>
				<category><![CDATA[misc.]]></category>
		<category><![CDATA[Python]]></category>
		<category><![CDATA[shared hosting]]></category>

		<guid isPermaLink="false">http://joemaller.com/?p=1717</guid>
		<description><![CDATA[Why are there so few Google results for &#8220;Build Python on Shared Hosting?&#8221; Because it&#8217;s so ridiculously easy that it took me longer to write this post than it did to download, configure and compile Python 2.7 on two different shared hosting accounts. These are the steps: $ mkdir -p ~/opt/python-2.7 $ mkdir ~/src $ [...]]]></description>
			<content:encoded><![CDATA[<p>Why are there so few Google results for &#8220;Build Python on Shared Hosting?&#8221; Because it&#8217;s so ridiculously easy that it took me longer to write this post than it did to download, configure and compile Python 2.7 on two different shared hosting accounts. </p>
<p>These are the steps:</p>
<pre><code>$ mkdir -p ~/opt/python-2.7
$ mkdir ~/src
$ cd ~/src
$ curl -LO http://www.python.org/ftp/python/2.7/Python-2.7.tgz
$ tar -xzvf Python-2.7.tgz
$ cd Python-2.7
$ ./configure --prefix=$HOME/opt/python2.7
$ make
$ make install</code></pre>
<p>Next, create ~/opt/bin if it doesn&#8217;t exist already and symlink the new Python binary:</p>
<pre><code>$ mkdir -p ~/opt/bin
$ ln -s ~/opt/python-2.7/bin/python2.7 ~/opt/bin/python</code></pre>
<p>Finally, be sure your $SHELL&#8217;s $PATH is configured to look for binaries in <strong>~/opt/bin</strong>. I use Bash, so I added the following line to ~/.bashrc:</p>
<pre><code>export PATH=$HOME/opt/bin:$PATH</code></pre>
<h3>Ok, so why bother? </h3>
<p>I&#8217;m lazy. I wanted to save myself a bunch of calls to <code>file.close()</code> by using the <a href="http://docs.python.org/library/stdtypes.html#file.close">more modern <code>with open</code> syntax</a>. Most shared hosts seem to consider Python unimportant, the two I use have Python 2.4.3 installed which is six years old. I couldn&#8217;t even import __future__ because __future__ hadn&#8217;t been written yet. </p>
<p>Waylan Limberg&#8217;s post about <a href="http://achinghead.com/archive/83/installing-multiple-versions-python/">installing multiple versions of Python</a> was helpful.</p>
]]></content:encoded>
			<wfw:commentRss>http://joemaller.com/1717/building-python-on-shared-hosting/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<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>How to install Subversion on a shared host</title>
		<link>http://joemaller.com/881/how-to-install-subversion-on-a-shared-host/</link>
		<comments>http://joemaller.com/881/how-to-install-subversion-on-a-shared-host/#comments</comments>
		<pubDate>Wed, 30 Jan 2008 04:04:43 +0000</pubDate>
		<dc:creator>Joe</dc:creator>
				<category><![CDATA[Web Development]]></category>
		<category><![CDATA[64 bit]]></category>
		<category><![CDATA[curl]]></category>
		<category><![CDATA[liquidweb]]></category>
		<category><![CDATA[shared hosting]]></category>
		<category><![CDATA[subversion]]></category>
		<category><![CDATA[Unix]]></category>
		<category><![CDATA[wget]]></category>

		<guid isPermaLink="false">http://joemaller.com/2008/01/29/how-to-install-subversion-on-a-shared-host/</guid>
		<description><![CDATA[I&#8217;ve hosted this site and several others LiquidWeb&#8217;s shared servers for probably eight years. They are without question, the most dependable host I&#8217;ve ever used. [see update] But LiquidWeb doesn&#8217;t offer Subversion. And I will no longer do web work without it. For some time I&#8217;d been considering leaving LiquidWeb because the lack of svn [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve hosted this site and several others <a href="http://www.liquidweb.com/">LiquidWeb&#8217;s shared servers</a> for probably eight years. They are without question, the most dependable host I&#8217;ve ever used. <em>[<a href="http://joemaller.com/881/how-to-install-subversion-on-a-shared-host/#lwupdate">see update</a>]</em></p>
<p>But LiquidWeb doesn&#8217;t offer <a href="http://subversion.tigris.org/">Subversion</a>. And I will no longer do web work without it.</p>
<p>For some time I&#8217;d been considering leaving LiquidWeb because the lack of svn was now hindering work on my own sites. For the same reason, I&#8217;ve had to pass them over several times when clients asked for hosting recommendations. Then the other night, I stumbled across a discussion about installing Subversion on a shared host. Why didn&#8217;t I  try that years ago? </p>
<p><span id="more-881"></span></p>
<h3>Installation Instructions</h3>
<p>These instructions assume basic proficiency with the Unix command line. Note that the goal is to install the SVN client, plan on hosting your repositories somewhere else.</p>
<p>Connect to  your account with ssh and create a working directory, mine&#8217;s called _src:</p>
<pre><code>cd
mkdir _src
cd _src</code></pre>
<p>Next, use <a href="http://linux.die.net/man/1/wget">wget</a> to pull down the subversion sources. You could also use curl, but wget does the same with less typing. Choose a version from this <a href="http://subversion.tigris.org/servlets/ProjectDocumentList?folderID=260&#038;expandFolder=74">list of Subversion sources</a>. The parallel &#8220;subversion-deps&#8221; download includes all dependent sources required to build Subversion.</p>
<pre><code>wget http://subversion.tigris.org/downloads/subversion-1.4.6.tar.gz
wget http://subversion.tigris.org/downloads/subversion-deps-1.4.6.tar.gz</code></pre>
<p>Next, untar the sources and dive into the directory:</p>
<pre><code>tar -xzvf subversion-1.4.6.tar.gz
tar -xzvf subversion-deps-1.4.6.tar.gz
cd subversion-1.4.6</code></pre>
<h3>One step, maybe (32-bit?)</h3>
<p>At this point, depending on your server configuration, you might be able to install with the following two commands:</p>
<pre><code>./configure --prefix=$HOME --without-berkeley-db \
     --with-ssl --with-editor=/usr/bin/vim \
     --without-apxs --without-apache
make &amp;&amp; make install</code></pre>
<p>That worked on some servers but not others, I spent many hours clumsily trying to figure out why. I found that the build process was linking to external libraries instead of the ones in subversion-deps, despite the configure directives.</p>
<p>On the 64-bit server (x86_64) this was a big problem, even though everything worked normally on two 32-bit (i686/i386) servers.  Check server architecture with either <code>arch</code>, <code>uname -a</code> or <code>cat /proc/cpuinfo</code>. The solution for 64-bit machines is to build the three main components beforehand and then tell Subversion where to find them.</p>
<h3>Build them, use them  (64-bit?)</h3>
<p>The following commands systematically build each of the three shared libraries from the Subversion-deps sources. This should guarantee that the files Subversion links to will be compatible. In each step, we explicitly enable compilation of shared libraries and prefix the files into our home directory. This looks worse than it is.</p>
<p>Build <a href="http://apr.apache.org/">apr</a>, apr-util and <a href="http://www.webdav.org/neon/">neon</a>, in that order:</p>
<pre><code>cd apr
./configure --enable-shared --prefix=$HOME
make &amp;&amp; make install

cd ../apr-util
./configure --enable-shared --prefix=$HOME \
     --with-expat=builtin --with-apr=$HOME \
     --without-berkeley-db
make &amp;&amp; make install

cd ../neon
./configure --enable-shared --prefix=$HOME \
     --with-libs=$HOME --with-ssl
make &amp;&amp; make install</code></pre>
<p>With those out of the way, we can now configure and build Subversion. According to the notes in Subversion&#8217;s configure file, the <code>--with-ssl</code> flag is not necessary since it&#8217;s just passed to neon and we already built neon.  <code>--without-apxs</code> and <code>--without-apache</code> prevent Subversion from trying to install its Apache modules. Remember to point to the libraries we just built (in $HOME): (note: you may need to add the <code>--without-serf</code> flag as well, <a href="#comment-50835">see this comment</a>)</p>
<pre><code>cd ../
./configure --prefix=$HOME --without-berkeley-db \
     --with-editor=/usr/bin/vim --with-apr=$HOME \
     --with-apr-util=$HOME --with-neon=$HOME \
     --without-apxs --without-apache
make &amp;&amp; make install</code></pre>
<p>Subversion should now be installed! It&#8217;s likely you already have <code>:~/bin</code> in your user $PATH, if so, you can try it out right away:</p>
<pre><code>svn --version

   svn, version 1.4.6 (r28521)
      compiled Jan 29 2008, 11:05:47</code></pre>
<p>So far, I&#8217;ve run this against two LiquidWeb shared accounts, one LiquidWeb CPanel container on a VPS and a <a href="http://www.hostmatters.com/">HostingMatters</a> shared account running JailShell. After some limited testing accessing different repositories with https and svn+ssh, everything seems to be working.</p>
<p>Now I just need to figure out where to put my repositories, here are some free Subversion hosts I&#8217;ve used or are considering:</p>
<ul>
<li><a href="http://www.beanstalkapp.com/pricing.html">Beanstalk</a> 20 MB free</li>
<li><a href="http://www.assembla.com">Assembla</a> 500 MB free?! really?</li>
<li><a href='http://unfuddle.com/home'>Unfuddle</a> 15 MB free</li>
<li><a href="http://code.google.com/hosting/">Google Code</a> 100 MB free, must be open source</li>
</ul>
<p>Two other sites which aren&#8217;t free, but I&#8217;m keeping in mind for the future: <a href="http://wush.net/">Wush</a> and  <a href="http://www.projectlocker.com/scenario/startup">Project Locker</a>.</p>
<h3>The getting there was the hardest part</h3>
<p>While I was finally able to streamline this down to a fairly simple process, it was not easy to get there.  I don&#8217;t do much compiling from source, so I&#8217;m very clumsy about troubleshooting. If any of these steps can be simplified, please leave a note.</p>
<pre><code>Here are some of the errors I saw along the way:
/usr/lib/libexpat.so: could not read symbols: File in wrong format
/usr/lib/libexpat.so: could not read symbols: Invalid operation
/home/joe/_src/subversion-1.4.6/neon/src/.libs/libneon.a: could not read symbols: Bad value </code></pre>
<p>The first two errors indicate that the build had grabbed the 32-bit libexpat from /usr/lib instead of the 64-bit version from /usr/lib64. However, redirecting to the 64-bit libraries introduced other problems such as the libneon.a bad value error. As mentioned above, what I needed to do was pull libraries from the subverson-deps code. To use those, I needed to compile each one first. </p>
<h3>Resources:</h3>
<ul>
<li><a href="http://svn.collab.net/repos/svn/trunk/INSTALL">Subversion&#8217;s INSTALL file</a></li>
<li>./configure -help</li>
<li><a href="http://pastie.caboo.se/99618">These commands</a>, from <a href="http://forum.activereload.net/forums/8/topics/241#post_934">this original post</a> almost worked.</li>
<li><a href='http://www.apdz.com/phpbb/viewtopic.php?t=369&#038;;sid=cbd15a9447f96cf9eb5000c4efb1b167'>Installing Mephisto and Subversion on a Shared Host</a>, first inkling this was possible</li>
<li>similar problem with with <a href="http://svn.haxx.se/users/archive-2005-05/0284.shtml">/usr/lib instead of /usr/lib64.</a></li>
<li><a href="http://www.linuxquestions.org/questions/showthread.php?t=563541">GATTAGA&#8217;s post</a> was the first clue about working around the libexpat problem.</li>
<li><a href="http://www.svnforum.org/2017/viewtopic.php?t=1940&#038;;sid=1d48a79776ec72bfbb719b91beb274ba">SVNforum: libneon.a: could not read symbols: Bad value</a> This was the post that gave me the final bit of information I needed</li>
</ul>
<p><strong>Related:</strong> <a href="http://joemaller.com/2008/08/13/how-to-install-git-on-a-shared-host/">How to install Git on a shared host</a></p>
<p><strong id="lwupdate">Update, November 2010:</strong> Sometime this year Liquid Web disallowed compiler access.  I now host my sites at <a href="http://www.webfaction.com/signup?affiliate=joemaller">WebFaction</a> and <a href="http://www.a2hosting.com/1482.html">A2 Hosting</a>. </p>
]]></content:encoded>
			<wfw:commentRss>http://joemaller.com/881/how-to-install-subversion-on-a-shared-host/feed/</wfw:commentRss>
		<slash:comments>58</slash:comments>
		</item>
	</channel>
</rss>

<!-- Performance optimized by W3 Total Cache. Learn more: http://www.w3-edge.com/wordpress-plugins/

Page Caching using disk: enhanced
Database Caching 3/9 queries in 0.004 seconds using disk: basic
Object Caching 324/333 objects using disk: basic

Served from: joemaller.com @ 2012-05-24 02:48:59 -->
