<?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>Ryan Kanno: The diary of an Enginerd in Hawaii &#187; Dreamhost</title>
	<atom:link href="http://blog.localkinegrinds.com/category/technology/dreamhost/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.localkinegrinds.com</link>
	<description>Everything you&#039;ve ever thought, but never had the balls to say.</description>
	<lastBuildDate>Thu, 17 Dec 2009 01:32:57 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Backing up your Subversion (SVN) repository on Dreamhost with cron</title>
		<link>http://blog.localkinegrinds.com/2008/02/10/backing-up-your-subversion-svn-repository-on-dreamhost-with-cron/</link>
		<comments>http://blog.localkinegrinds.com/2008/02/10/backing-up-your-subversion-svn-repository-on-dreamhost-with-cron/#comments</comments>
		<pubDate>Sun, 10 Feb 2008 22:02:56 +0000</pubDate>
		<dc:creator>ryankanno</dc:creator>
				<category><![CDATA[Dreamhost]]></category>
		<category><![CDATA[HowTo]]></category>
		<category><![CDATA[Python]]></category>
		<category><![CDATA[Subversion]]></category>
		<category><![CDATA[Technology]]></category>
		<category><![CDATA[back-up]]></category>
		<category><![CDATA[backup]]></category>
		<category><![CDATA[cron]]></category>
		<category><![CDATA[crontabs]]></category>
		<category><![CDATA[hotcopy]]></category>
		<category><![CDATA[scheduler]]></category>
		<category><![CDATA[svn]]></category>

		<guid isPermaLink="false">http://blog.localkinegrinds.com/2008/02/10/backing-up-your-subversion-svn-repository-on-dreamhost-with-cron/</guid>
		<description><![CDATA[Two events spurred me to write this blog.
First, my 2 year old &#8220;Subversion + Dreamhost + Post-Commit&#8221; blog still gets quite a number of hits.  Second, after the latest Dreamhost outage move, I&#8217;m beginning to feel a little more vigilant about backing up my data.  
As a standard disclaimer, if you&#8217;re not familiar [...]]]></description>
			<content:encoded><![CDATA[<h3>Two events spurred me to write this blog.</h3>
<p>First, my <a href="http://blog.localkinegrinds.com/2006/12/15/dreamhost-subversion-post-commit-tutorial/">2 year old &#8220;Subversion + Dreamhost + Post-Commit&#8221; blog</a> still gets quite a number of hits.  Second, after the latest <a href="http://www.dreamhoststatus.com/2008/02/08/randy-move-going-ahead/">Dreamhost <strike>outage</strike> move</a>, I&#8217;m beginning to feel a little more vigilant about backing up my data.  </p>
<div class="disclaimer">As a standard disclaimer, if you&#8217;re not familiar with the Unix shell, I <strong>highly suggest</strong> you not try this unless under the supervision of someone who reads Perl books for fun.  By accessing your Dreamhost shell, you can seriously f-up your account and I will not fix it for you.  You have been warned. <img src='http://blog.localkinegrinds.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' />  (Don&#8217;t you just love smileys?)</div>
<h3>Setup</h3>
<p>There are a few prerequisites to being able to back up your <a href="http://subversion.tigris.org/">SVN</a> repository.</p>
<ol>
<li>First and foremost, you must have already installed a SVN repository into your Dreamhost account via the <a href="https://panel.dreamhost.com/index.cgi?tree=goodies.svn&#038;">control panel</a>.</li>
<li>Second, you must know how to <a href="http://wiki.dreamhost.com/Ssh">SSH into your Dreamhost account</a>.  As a FYI, you sorta-kinda-need to know what that means in order to follow this tutorial.</li>
</ol>
<h3>Grabbing the backup script</h3>
<p>Wait, you didn&#8217;t think I was writing my own right?  In any case, if you actually installed/compiled Subversion on your own, it would&#8217;ve contained this file, <a href="http://svn.collab.net/repos/svn/trunk/tools/backup/hot-backup.py.in">hotbackup.py</a>.  Fortunately for us, Dreamhost has this file conveniently available at: <strong>/usr/bin/svn-hot-backup</strong>, but it&#8217;s an older version of the backup script.  There are some subtle differences like being unable to pass in the number of backups you want the script to manage.  Personally, I like to be on the edge, so let&#8217;s get the latest version.  Execute the following commands from your home directory.</p>
<pre class="console">
$ cd ~
$ mkdir scripts
$ cd scripts
$ wget http://svn.collab.net/repos/svn/trunk/tools/backup/hot-backup.py.in
$ mv hot-backup.py.in svn-hot-backup.py
</pre>
<p>The commands issued above created a directory called scripts in your home directory, switched into the directory, downloaded the latest hot-backup.py file from <a href="http://www.collab.net">CollabNet</a>, and renamed it to svn-hot-backup.py.  Now that you have the file, you&#8217;ll need to make a few edits.  Personally, I&#8217;m accustomed to vi, but pick your poison (pico, nano, text editor of your choice) and find these two values (they should be close to the top of the file in consecutive lines).</p>
<pre class="script">
# Path to svnlook utility
svnlook = r"@SVN_BINDIR@/svnlook"

# Path to svnadmin utility
svnadmin = r"@SVN_BINDIR@/svnadmin"
</pre>
<p>and change them to the following:</p>
<pre class="script">
# Path to svnlook utility
svnlook = r"/usr/bin/svnlook"

# Path to svnadmin utility
svnadmin = r"/usr/bin/svnadmin"
</pre>
<p>(If you&#8217;re wondering, if and when you compile/install Subversion yourself, these two variables would have been automagically filled in for you.)</p>
<p>The python script we downloaded not only performs a <a href="http://svnbook.red-bean.com/en/1.0/re33.html">hotcopy</a> of your svn directory, but also can archive it and manage a set number of copies.  <strong>Pretty neat right?</strong></p>
<h3>Preparing for the backups</h3>
<p>Before you can actually back up your SVN repository, you&#8217;ll want to create a directory structure to manage your backups.  Execute the following commands from your home directory.</p>
<pre class="console">
$ cd ~
$ mkdir backup
$ cd backup
$ mkdir svn
$ cd ~/scripts
</pre>
<p>The commands issued above created a directory called <strong>backup</strong> in your home directory, switched into the directory, and created another directory called <strong>svn</strong> within the backup directory.  We&#8217;ll be using this directory to store all your backups.  Finally, we switched back into the scripts directory created in the previous steps.  Now that we have the backup script and directory structure to manage the back ups, let&#8217;s test it out!</p>
<p>Before you can back up your repository, you&#8217;ll have to know the name of the Subversion repository you&#8217;re trying to back up.  To find the name of your repository, you can either look in the svn directory in your home directory, or you can check out the <a href="https://panel.dreamhost.com/index.cgi?tree=goodies.svn&#038;">ID value in your Subversion Goodies control panel</a>.  In any case, remember the name of your SVN repository and issue the following commands.</p>
<pre class="console">
$ cd ~/scripts/
$ python2.4 svn-hot-backup.py --archive-type=zip --num-backups=10 ~/svn/REPOSITORY_NAME_HERE/ ~/backup/svn/
</pre>
<div style="font:bold 1.1em arial; background-color:#E5F3FF; padding:1em; margin:1em 0; border:1px solid #114477; color:#33415D;">Notice, change the value of REPOSITORY_NAME_HERE to the id of the SVN repository you want backed up.</div>
<p>You should see the following in the console:</p>
<pre class="console">
Beginning hot backup of '/home/USERNAME/svn/lkg/'.
Youngest revision is REVISION_NUMBER
Backing up repository to '/home/USERNAME/backup/svn/REPOSITORY_NAME_HERE-701'...
Done.
Archiving backup to '/home/USERNAME/backup/svn/REPOSITORY_NAME_HERE-701.zip'...
Archive created, removing backup '/home/USERNAME/backup/svn/REPOSITORY_NAME_HERE-701'...
</pre>
<div style="font:bold 1.1em arial; background-color:#DDFFDD; border:1px solid #009900; padding:1em; margin:1em 0;">If you see the following, the backup was a <span style="font:bold 1.25em arial; color:#006600;">success</span>!  You can even check on the file by changing into the backup/svn directory!</div>
<h2>Voila! (But there&#8217;s more)</h2>
<h3>Automating the backups</h3>
<p>Now that you actually have the script backing up your SVN repository, let&#8217;s automate them!  To do so, we&#8217;ll use the handy <a href="http://en.wikipedia.org/wiki/Crontab">cron daemon</a>.  Cron has similarities to the Windows task scheduler in that it provides a service that enables a user to execute commands at a specified date/time or set intervals.  To tell cron the tasks you want to execute, you&#8217;ll need to load a configuration file called a crontab.  You can read more about it <a href="http://blog.dreamhosters.com/kbase/index.cgi?area=2506">here</a> and <a href="http://wiki.dreamhost.com/Cron">here</a>. In any case, here&#8217;s what my crontab configuration file looks like.</p>
<pre class="script">
MAILTO=ryankanno@CHANGE_TO_YOUR_EMAIL.com
# minute (0-59),
# |      hour (0-23),
# |      |       day of the month (1-31),
# |      |       |       month of the year (1-12),
# |      |       |       |       day of the week (0-6 with 0=Sunday).
# |      |       |       |       |       commands
  0      0       *       *       *      /usr/bin/python2.4 /home/USERNAME/scripts/svn-hot-backup.py --archive-type=zip --num-backups=10 /home/USERNAME/svn/REPOSITORY_NAME/ /home/USERNAME/backup/svn/
</pre>
<p>Create a file in your scripts directory called svn_backup_once_a_day.cron and copy the contents above into your file.  I&#8217;ve setup my crontab to backup my svn repository once a day.</p>
<div style="font:bold 1.1em arial; background-color:#E5F3FF; padding:1em; margin:1em 0; border:1px solid #114477; color:#33415D;">Notice, change the value of ryankanno@CHANGE_TO_YOUR_EMAIL.com to your email address (or comment the line out with a # if you don&#8217;t want emails sent to you), USERNAME to your Dreamhost username, and REPOSITORY_NAME to your Subversion repository.</div>
<p>Once you have this file called svn_backup_once_a_day.cron in your scripts directory, load the file into your crontab by issuing the following command:</p>
<pre class="console">
$ crontab svn_backup_once_a_day.cron
</pre>
<p>As a FYI, this will replace your old crontab.  If you have other items already running on cron, it&#8217;s a good idea to list them via the crontab -l command first.  If you want to make sure that your cron will run, you can test it out by setting the values in the crontab to the time you want it to run.  I&#8217;ll leave this as an exercise to the reader. <img src='http://blog.localkinegrinds.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<h3>Storing your backups</h3>
<p>Though out of scope of this blog, you&#8217;ll still have to store your backups somewhere.  Please just don&#8217;t leave them in your <a href="http://www.dreamhost.com">Dreamhost</a> account.  Your best bet is probably to get an <a href="http://aws.amazon.com/s3">Amazon S3 account</a> and store your backups there.  Personally, I like to run another script immediately after the hotcopy finishes that pushes the backup to my S3 account.  Other options include scp/sftp&#8217;ing the backups to your home machine.  Here&#8217;s a <a href="http://blog.dreamhosters.com/kbase/index.cgi?area=2599">link</a> to read more about that option.</p>
<h2>Voila! Enjoy!</h2>
<img src="http://blog.localkinegrinds.com/?ak_action=api_record_view&id=165&type=feed" alt="" />]]></content:encoded>
			<wfw:commentRss>http://blog.localkinegrinds.com/2008/02/10/backing-up-your-subversion-svn-repository-on-dreamhost-with-cron/feed/</wfw:commentRss>
		<slash:comments>8</slash:comments>
		</item>
		<item>
		<title>Custom Python installation for Django on Dreamhost</title>
		<link>http://blog.localkinegrinds.com/2007/08/20/custom-python-installation-for-django-on-dreamhost/</link>
		<comments>http://blog.localkinegrinds.com/2007/08/20/custom-python-installation-for-django-on-dreamhost/#comments</comments>
		<pubDate>Mon, 20 Aug 2007 07:09:39 +0000</pubDate>
		<dc:creator>ryankanno</dc:creator>
				<category><![CDATA[Django]]></category>
		<category><![CDATA[Dreamhost]]></category>
		<category><![CDATA[Life]]></category>
		<category><![CDATA[Python]]></category>
		<category><![CDATA[Technology]]></category>
		<category><![CDATA[custom]]></category>
		<category><![CDATA[mysql]]></category>
		<category><![CDATA[mysql-python]]></category>
		<category><![CDATA[upgrade]]></category>

		<guid isPermaLink="false">http://blog.localkinegrinds.com/2007/08/20/custom-python-installation-for-django-on-dreamhost/</guid>
		<description><![CDATA[Now that my MBA class is finally done for the summer, I can focus on more important things&#8230; like upgrading my Python installation on Dreamhost for my Django application.  Seeing as how Dreamhost is still behind the Python times, with Python 2.4 hidden in Dreamhost obscurity, I figured I&#8217;d blog about updating your Dreamhost [...]]]></description>
			<content:encoded><![CDATA[<p>Now that my MBA class is finally done for the summer, I can focus on more important things&#8230; like upgrading my <a href="http://www.python.org/">Python</a> installation on <a href="http://www.dreamhost.com/">Dreamhost</a> for my <a href="http://www.djangoproject.com/ ">Django</a> application.  Seeing as how Dreamhost is still behind the Python times, with <a href="http://lazutkin.com/blog/2005/oct/14/dreamhost_python_241/">Python 2.4 hidden in Dreamhost obscurity</a>, I figured I&#8217;d blog about updating your Dreamhost Python installation (and subsequent <a href="http://sourceforge.net/projects/mysql-python">MySQLdb libraries</a>) to Python 2.5.</p>
<p>The very first thing I did was search <a href="http://www.google.com">Google</a>.  You know, I really don&#8217;t know how people lived pre-Googs.  In any case, I found this <a href="http://badpopcorn.com/2006/10/29/python-eggs-and-dreamhost/">blog posting</a> describing exactly what I wanted to do.  Thanks Ben!  Since I&#8217;m not a big fan of running one large batch script people create in their blogs, I&#8217;ll break it down for the non-*nix fans out there.  </p>
<p>Before I begin, I&#8217;m assuming that you already have Django running on Dreamhost.  If you&#8217;re having a &#8220;wtf&#8221; moment, make sure to stop by <a href="http://www2.jeffcroft.com/">Jeff&#8217;s blog</a> and read &#8220;<a href="http://www2.jeffcroft.com/blog/2006/may/11/django-dreamhost/">Setting up Django on Dreamhost</a>&#8220;. (This is how I set mine up).  To follow my short tutorial, you&#8217;ll need shell access to your Dreamhost account.</p>
<p>After ssh&#8217;ing into your Dreamhost account, you should be in your home directory (/home/username).  According to the <a href="http://www.pathname.com/fhs/pub/fhs-2.3.html#OPTADDONAPPLICATIONSOFTWAREPACKAGES">Filesystem Hierarchy Standard</a>, the /opt dir &#8220;<em>is reserved for the installation of add-on application software packages</em>.&#8221;  With that said, issue the following commands:</p>
<pre class="console">
$ mkdir opt
$ mkdir downloads
$ cd downloads
$ wget http://www.python.org/ftp/python/2.5.1/Python-2.5.1.tgz
$ tar xvzf Python-2.5.1.tgz
</pre>
<p>First, create a directory named opt.  Next, create a directory named downloads for all your files.  Change into the downloads directory, then download the latest Python from <a href="http://www.python.org">http://www.python.org</a>.  Finally, unzip and untar the package into the download directory.  Everything will extract into a directory named Python-2.5.1.</p>
<pre class="console">
$ cd Python-2.5.1
$ ./configure --prefix=$HOME/opt/ --enable-unicode=ucs4
$ make
$ make install
</pre>
<p>Change into the Python-2.5.1 directory and type in the following configure command.  Basically, configure prepares your installation for compilation.  The &#8211;prefix flag will install machine-independent data files in subdirectories of the specified directory. The default is to install in /usr/local, but it&#8217;s overwritten with the opt directory created earlier.  Finally, run make and make install which will install your custom Python installation.</p>
<pre class="console">
$ cd ..
$ rm -rf Python-2.5.1
</pre>
<p>Finally, delete the Python-2.5.1 directory.  Before you can use this Python installation, you have to add the /opt/bin directory to your path.  To do this, add /opt/bin to your .bash_profile file in your home directory.  To do so, you&#8217;ll have to add the following to your .bash_profile.</p>
<pre class="script">export PATH=$HOME/opt/bin/:$PATH</pre>
<p>Basically, this allows you to type &#8216;python&#8217; in your shell and reach the custom Python 2.5.1 installation instead of the Dreamhost one.  To make sure that our Python installation is working, type the following in your home directory (cd ~):</p>
<pre class="console">
$ source .bash_profile
$ python --version
</pre>
<p>After the last command, you should see the following: Python 2.5.1.  If that displays, your upgrade was successful!  After upgrading your Python installation, you&#8217;re not done yet.  Since Dreamhost uses an old <a href="http://mysql-python.sourceforge.net/">MySQL-Python</a> installation, we&#8217;ll upgrade that as well.  Type the following in your home directory:</p>
<pre class="console">
$ cd downloads
$ wget http://internap.dl.sourceforge.net/sourceforge/mysql-python/MySQL-python-1.2.2.tar.gz
$ tar xvzf MySQL-python-1.2.2.tar.gz
$ cd MySQL-python-1.2.2
$ python setup.py install
</pre>
<p>First, change into the downloads directory and issue the wget command to download the latest MySQL-Python files from Sourceforge.  Once you&#8217;ve received the files, unzip and untar the package.  All the files will extract into a directory called MySQL-python-1.2.2.  Change into this directory and install the files by typing python setup.py install.  If you followed the custom Python installation, the files should build and extract into the ~/opt/lib/python2.5/site-packages/ directory as an egg file. </p>
<p>You now have a custom Python installation and a MySQL-Python upgrade!</p>
<h2>Voila!</h2>
<p><strong>Update</strong>:  Just so you don&#8217;t get caught up in the same mistake that I made, to be sure that your Django fcgi installation is using your custom Python installation, make sure the <strong>dispatch.fcgi</strong> file reads as such:</p>
<pre class="console">
#!/home/USERNAME_GOES_HERE/opt/bin/python
import sys

sys.path += ['WHATEVER_PATHS_YOU_NEED']

from fcgi import WSGIServer
from django.core.handlers.wsgi import WSGIHandler
import os

os.environ['DJANGO_SETTINGS_MODULE'] = 'wegoeat.settings'
WSGIServer(WSGIHandler()).run()
</pre>
<img src="http://blog.localkinegrinds.com/?ak_action=api_record_view&id=114&type=feed" alt="" />]]></content:encoded>
			<wfw:commentRss>http://blog.localkinegrinds.com/2007/08/20/custom-python-installation-for-django-on-dreamhost/feed/</wfw:commentRss>
		<slash:comments>14</slash:comments>
		</item>
		<item>
		<title>My Dreamhost + Django + Subversion Setup</title>
		<link>http://blog.localkinegrinds.com/2007/03/29/my-dreamhost-django-subversion-setup/</link>
		<comments>http://blog.localkinegrinds.com/2007/03/29/my-dreamhost-django-subversion-setup/#comments</comments>
		<pubDate>Thu, 29 Mar 2007 12:13:22 +0000</pubDate>
		<dc:creator>ryankanno</dc:creator>
				<category><![CDATA[Django]]></category>
		<category><![CDATA[Dreamhost]]></category>
		<category><![CDATA[HowTo]]></category>
		<category><![CDATA[Projects]]></category>
		<category><![CDATA[Python]]></category>
		<category><![CDATA[Subversion]]></category>
		<category><![CDATA[Technology]]></category>
		<category><![CDATA[development-setup]]></category>
		<category><![CDATA[fastcgi]]></category>
		<category><![CDATA[http://www.wegoeat.com]]></category>
		<category><![CDATA[post-commit-hook]]></category>
		<category><![CDATA[restaurants]]></category>
		<category><![CDATA[svn]]></category>
		<category><![CDATA[tutorial]]></category>
		<category><![CDATA[wegoeat]]></category>

		<guid isPermaLink="false">http://blog.localkinegrinds.com/2007/03/29/my-dreamhost-django-subversion-setup/</guid>
		<description><![CDATA[Since I haven&#8217;t put out a technical article in a while, this blog will explain how I&#8217;ve setup Dreamhost + Django + Subversion to play nicely together in a seamless development environment via a shared hosting provider.  Hopefully &#8211; someone, somewhere can find this information useful and insightful in their own development environment.
The very [...]]]></description>
			<content:encoded><![CDATA[<p>Since I haven&#8217;t put out a technical article in a while, this blog will explain how I&#8217;ve setup <a href="http://www.dreamhost.com">Dreamhost</a> + <a href="http://www.djangoproject.com">Django</a> + <a href="http://subversion.tigris.org/">Subversion</a> to play nicely together in a seamless development environment via a shared hosting provider.  Hopefully &#8211; someone, somewhere can find this information useful and insightful in their own development environment.</p>
<p>The very first thing I did was unleash my first <a href="http://www.djangoproject.com/">Django</a> web application on <a href="http://www.dreamhost.com">Dreamhost</a>.  Thanks to an excellent tutorial from <a href="http://www2.jeffcroft.com/blog/2006/may/11/django-dreamhost/">Jeff Croft</a>, a detailed explanation about <a href="http://www.djangoproject.com/documentation/fastcgi/">FastCGI contained within the Django documentation</a>, and a few helpful pointers on the <a href="http://wiki.dreamhost.com/index.php/Django">Dreamhost wiki</a>, I was able to get my application deployed in a matter of a few hours.</p>
<h2>You can check it out <a href="http://www.wegoeat.com/">here</a>!</h2>
<p>However, after going through Jeff&#8217;s excellent tutorial, I still wasn&#8217;t completely satisfied with my Django deployment on Dreamhost.  <em>Something was missing</em>.  There wasn&#8217;t a seamless way to continue development on my home machine, deploy to a test environment, and still keep <a href="http://www.wegoeat.com">my live site</a> intact.  After all, I&#8217;m a true believer in the open source dictum of  &#8216;<em>release early, release often</em>&#8216;, and without a way to test my application on a live server, I wasn&#8217;t happy with my configuration management.</p>
<p>Ideally, I envisioned having a live web application (i.e. <a href="http://www.wegoeat.com">http://www.wegoeat.com/</a>) and another url that I could deploy my beta releases to (i.e. <a href="http://beta.wegoeat.com">http://beta.wegoeat.com/</a>).  From a configuration management standpoint, I would tag major release builds and to maintain that release over its life (via bug fixes, minor enhancements), I would create a branch of the tag.  Thus, the live site would be updated from the branches directory, while the beta url would update from the trunk in my Subversion repository.  So to summarize the &#8216;extra&#8217; steps I did to ensure a smoother deployment cycle, I&#8217;ve conjured up the following action list.</p>
<ol>
<li>The very first thing I did was follow <a href="http://www2.jeffcroft.com/blog/2006/may/11/django-dreamhost/">Jeff&#8217;s tutorial</a> &#8211; instead of creating a single directory in my django_projects directory, I created two.  One was named &#8216;project_live&#8217; and the other &#8216;project_beta&#8217;.</li>
<li>Next, I checked out the appropriate source files from the appropriate locations in my Subversion repository.  The &#8216;project_live&#8217; directory came from my branches directory and represents my &#8216;live&#8217; site.  The &#8216;project_beta&#8217; directory came from the trunk and represents my &#8216;beta&#8217; site.  Obviously, the settings.py file for the Django applications as well as the configuration files for FastCGI were different according to the directories.  Since my settings will probably be very different then your settings, I&#8217;ll leave this as an exercise to the reader.</li>
<li>Note, as far as Dreamhost goes, I created two domain entries, one @ <a href="http://www.wegoeat.com">http://www.wegoeat.com</a> that will host my live site, and another @ <a href="http://beta.wegoeat.com">http://beta.wegoeat.com</a> that will be my beta site.</li>
<li>I followed <a href="http://blog.localkinegrinds.com/2006/12/15/dreamhost-subversion-post-commit-tutorial/">my own tutorial</a> and created a post-commit hook to update the appropriate Dreamhost directories when I committed to the repository.</li>
</ol>
<h2 style="margin-top:1em;">And voila!  We&#8217;re done.</h2>
<p>Now, I can develop on my home machine where I&#8217;ve checked out the trunk of my Subversion repository.  Whenever I commit, the post-commit hook updates the project_beta directory on my Dreamhost account, and all the while, <a href="http://www.wegoeat.com">my live site</a> is still functioning.</p>
<p>Stay tuned for my next blog where I discuss how to get <a href="http://wiki.dreamhost.com/index.php/Installing_PHP5#Custom_PHP_5">Custom PHP</a> + <a href="www.mediawiki.org/">MediaWiki</a> + <a href="http://www.eaccelerator.net/">EAccelerator</a> playing nicely together on Dreamhost!</p>
<p><!--adsense--></p>
<img src="http://blog.localkinegrinds.com/?ak_action=api_record_view&id=96&type=feed" alt="" />]]></content:encoded>
			<wfw:commentRss>http://blog.localkinegrinds.com/2007/03/29/my-dreamhost-django-subversion-setup/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Dreamhost + Subversion + Post-Commit Tutorial</title>
		<link>http://blog.localkinegrinds.com/2006/12/15/dreamhost-subversion-post-commit-tutorial/</link>
		<comments>http://blog.localkinegrinds.com/2006/12/15/dreamhost-subversion-post-commit-tutorial/#comments</comments>
		<pubDate>Fri, 15 Dec 2006 09:42:10 +0000</pubDate>
		<dc:creator>ryankanno</dc:creator>
				<category><![CDATA[Dreamhost]]></category>
		<category><![CDATA[Life]]></category>
		<category><![CDATA[Projects]]></category>
		<category><![CDATA[Technology]]></category>
		<category><![CDATA[HowTo]]></category>
		<category><![CDATA[post-commit-hook]]></category>
		<category><![CDATA[Subversion]]></category>
		<category><![CDATA[svn]]></category>
		<category><![CDATA[tutorial]]></category>

		<guid isPermaLink="false">http://blog.localkinegrinds.com/2006/12/15/dreamhost-subversion-post-commit-tutorial/</guid>
		<description><![CDATA[Update
According to Jeff, Dreamhost has disabled setuid for home directories &#8211; which they probably should&#8217;ve done years ago.    As a side note, some other alternatives include the following:

Setting the directory permissions to +777 (probably not a good idea)
Setup cron to perform the same task.  If you need an introduction to cron, [...]]]></description>
			<content:encoded><![CDATA[<h3>Update</h3>
<p>According to <a href="http://jeffandstaci.us/">Jeff</a>, <a href="http://www.dreamhost.com">Dreamhost</a> has disabled setuid for home directories &#8211; which they probably should&#8217;ve done years ago. <img src='http://blog.localkinegrinds.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' />   As a side note, some other alternatives include the following:</p>
<ul>
<li>Setting the directory permissions to +777 (<span style="font-weight:bold; color:#990000;">probably not a good idea</span>)</li>
<li>Setup cron to perform the same task.  If you need an introduction to cron, check out <a href="http://blog.localkinegrinds.com/2008/02/10/backing-up-your-subversion-svn-repository-on-dreamhost-with-cron/">my blog about backing up your Subversion respository</a></li>
</ul>
<p>In any case, I&#8217;ve since moved half my sites to <a href="http://www.webfaction.com">WebFaction</a> so if you know of a solution, post it in the comments and I&#8217;ll write a new blog post about it. <img src='http://blog.localkinegrinds.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<hr />
<p>Since <a href="http://www.dreamhost.com/">Dreamhost</a> has integrated <a href="http://subversion.tigris.org/">Subversion</a> into their services, I finally decided to take the leap and move my local repository to my hosted account.  After all, I was tired of always having to remember to transfer my updated files via <a href="http://en.wikipedia.org/wiki/Secure_copy">scp</a>.  With my repository moved over to Dreamhost, I figured I would take advantage of Subversion&#8217;s post-commit hooks to automagically update my live <a href="http://beta.localkinegrinds.com">beta site</a>.  </p>
<p>After reading a myriad of solutions (like <a href="http://blog.dreamhosters.com/forum/troubleshooting/51797-Subversion-post-commit-hooks.htm">here</a> and <a href="http://www.tristanburch.com/blog/2006/04/24/using-subversion-post-commit-hooks-with-dreamhost/">here</a> ), I found the <a href="http://wiki.dreamhost.com/index.php/Subversion">Dreamhost wiki entry</a> the most helpful.  So without further adieu, here&#8217;s a small, quick and dirty tutorial on how to automagically get post-commit working with Subversion on your Dreamhost account.</p>
<h4 style="font-size:110%;"><u>The setup</u></h4>
<p>The very first thing you need to do is create a directory on your Dreamhost account to checkout the source files to (I&#8217;m assuming you&#8217;ve already created your Subversion repository, have checked files into it, and are <a href="http://en.wikipedia.org/wiki/Secure_Shell">ssh&#8217;ed</a> into your Dreamhost account.).  In my situation, I created a subdomain in Dreamhost called beta.localkinegrinds.com.  Dreamhost automatically creates a directory named beta.localkinegrinds.com within the root of the admin account.  I cd&#8217;ed into that directory and issued the following command:<br/><br />
<code style="background-color:#fafbfc; border:1px solid #ccc; color: #000; padding:.75em; margin-bottom:10px;">svn co PATH_TO_FILES_IN_REPOSITORY . --username USERNAME --password PASSWORD</code></p>
<p>Once checked out, I switched into my Subversion repository directory; it was named svn in the root of my admin account.  From there, I went into my named repository, and then into the &#8216;hooks&#8217; directory.  </p>
<p><strong>Here&#8217;s where all the fun begins!</strong></p>
<p>First, I created a script called &#8216;post-commit.script&#8217; that looked like the following:</p>
<pre style="font-size:125%; background-color:#ffffee; border:1px solid #ccc; padding:1em;">
#!/bin/sh
/usr/bin/svn up PATH_TO_DIR --username SVN_USERNAME --password PASSWORD
</pre>
<p>I exited my text editor, then issued the following command:</p>
<p><code style="background-color:#fafbfc; border:1px solid #ccc; color: #000; padding:.75em;">chmod +x post-commit.script</code></p>
<p>From reading all the forums, the main issue with the post-commit hooks is that svnserve will run the hooks as the Apache user; in Dreamhost&#8217;s case, the dhapache user.  Thus, we have the following options as described <a href="http://arstechnica.com/articles/columns/linux/linux-20050406.ars">here</a>.  We can:</p>
<ol>
<li>Run password-less sudo (<span style="font-weight:bold; color:#990000;">which we don&#8217;t have access to on Dreamhost</span>)</li>
<li>Change the group permissions (<span style="font-weight:bold; color:#990000;">which we don&#8217;t have access to on Dreamhost</span>)</li>
<li>Checkout the files as the dhapache user from a post-commit hook, then change it to update as described <a href="http://blog.dreamhosters.com/forum/troubleshooting/51797-Subversion-post-commit-hooks.htm">here</a> (<span style="font-weight:bold; color:#990000;">which I thought was a pain in the rear, not to mention having the directory be world writeable</span>)</li>
<li>Compile a small C program with its <a href="http://en.wikipedia.org/wiki/Setuid">setuid</a> bit set</li>
</ol>
<p>Being the programmer that I am, I chose the last option.  Basically, as <a href="http://en.wikipedia.org/">Wikipedia</a> describes, &#8220;<em>when a binary executable file has been given the setuid attribute, normal users on the system can execute this file and gain the privileges of the user who owns the file (commonly root) within the created process.</em>&#8221;  This means that even though the Apache user will run the post-commit hook, it&#8217;ll assume the privileges of the user who owns the file (my account) and be able to execute the post-commit.script file we just created!</p>
<p><strong>Neat!</strong></p>
<p>So&#8230; taking a look at the <a href="http://wiki.dreamhost.com/index.php/Subversion#Using_Subversion_for_Web_development">Dreamhost wiki</a>, I created the following c program named post-commit.c</p>
<pre style="font-size:125%; background-color:#ffffee; border:1px solid #ccc; padding:1em;">
#define PATH_TO_POST_COMMIT_SCRIPT "/PATH/TO/POST_COMMIT.SCRIPT"
#include &lt;sys/types.h&gt;
#include &lt;unistd.h&gt;
main( ac, av ) char **av;
{
  execv( PATH_TO_POST_COMMIT_SCRIPT, av );
}
</pre>
<p>I then issued the following command to compile the program into a binary called post-commit:</p>
<p><code style="background-color:#fafbfc; border:1px solid #ccc; color: #000; padding:.75em;">gcc -o post-commit post-commit.c</code></p>
<p>And then to set the setuid bit on the post-commit file:</p>
<p><code style="background-color:#fafbfc; border:1px solid #ccc; color: #000; padding:.75em;">chmod 4755 post-commit</code><br />
<br/><br />
<strong>Voila!</strong></p>
<p>Assuming you set all the correct paths, on a commit to your Subversion repository &#8211; your live site will be updated!  </p>
<p>As a side note, most of the sites previously mentioned didn&#8217;t have any troubleshooting tips.  Here&#8217;s a few that I ran into along the way:</p>
<ol>
<li>Always test the scripts out first, ie, execute them from the command line and make sure they are doing what you want them to.</li>
<li>Apparently, according to the <a href="http://svnbook.red-bean.com/en/1.1/svn-book.html#svn-ch-5-sect-2.1">Subversion book</a>, &#8220;<em>Subversion repository executes hook scripts with an empty environment.</em>&#8221;  This is something good to know.</li>
<li>If everything was done right, and it&#8217;s still not working, try to update your checked out Subversion directory.  Sometimes you need to <a href="http://svnbook.red-bean.com/en/1.1/svn-book.html#svn-ch-3-sect-7.1">clean up</a> before any other updates can occur.  That problem took me a whole half-an-hour to figure out. <img src='http://blog.localkinegrinds.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </li>
</ol>
<p>In any case, if done correctly, you&#8217;ll be on your way to a better development environment!</p>
<img src="http://blog.localkinegrinds.com/?ak_action=api_record_view&id=56&type=feed" alt="" />]]></content:encoded>
			<wfw:commentRss>http://blog.localkinegrinds.com/2006/12/15/dreamhost-subversion-post-commit-tutorial/feed/</wfw:commentRss>
		<slash:comments>14</slash:comments>
		</item>
	</channel>
</rss>
