<?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>Mike / Michael Fogel &#187; dreamhost</title>
	<atom:link href="http://www.fogel.ca/tag/dreamhost/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.fogel.ca</link>
	<description>soapbox and search engine spam</description>
	<lastBuildDate>Wed, 31 Mar 2010 03:43:34 +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>The New Site</title>
		<link>http://www.fogel.ca/2010/03/30/the-new-site/</link>
		<comments>http://www.fogel.ca/2010/03/30/the-new-site/#comments</comments>
		<pubDate>Wed, 31 Mar 2010 03:42:55 +0000</pubDate>
		<dc:creator>Mike Fogel</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[dreamhost]]></category>
		<category><![CDATA[linode]]></category>
		<category><![CDATA[wordpress]]></category>

		<guid isPermaLink="false">http://www.fogel.ca/?p=913</guid>
		<description><![CDATA[Only a short two years into its budding existence, blog.fogel.ca has been consumed by www.fogel.ca.
Don&#8217;t worry, not much is going to change.  All blog.fogel.ca permalinks should still work &#8211; seamlessly and correctly redirecting to www.fogel.ca.  You&#8217;ll still get the same ramblings about transit, travel and tech here that you used to get from [...]]]></description>
			<content:encoded><![CDATA[<p>Only a short two years into its budding existence, <em>blog.fogel.ca</em> has been consumed by <em>www.fogel.ca</em>.</p>
<p>Don&#8217;t worry, not much is going to change.  All <em>blog.fogel.ca</em> permalinks should still work &#8211; seamlessly and correctly redirecting to <em>www.fogel.ca</em>.  You&#8217;ll still get the same ramblings about <a href="http://www.fogel.ca/tag/transit/">transit</a>, <a href="http://www.fogel.ca/tag/travel/">travel</a> and <a href="http://www.fogel.ca/tag/tech/">tech</a> here that you used to get from <em>blog.fogel.ca</em>.</p>
<p>I also used the move as an opportunity to switch up my hosting from a shared <a href="http://www.dreamhost.com/r.cgi?314813">Dreamhost</a> machine to a full VPS with <a href="http://www.linode.com/?r=4f3153e4f47f13a7e788f246d9e1809ef07c0979">Linode</a>.  (BTW, Linode is the third VPS provider I&#8217;ve been with &#8211; and they&#8217;re the best I&#8217;ve found.  Definitely recommended.)  And I moved some of my image hosting to my <a href="http://www.flickr.com/photos/mfogel">Flickr</a> account&#8230; which was working great until I discovered their active-image limit of 204 images.  Doh!  Wish I had known that 204 images ago.</p>
<p>I&#8217;m still using Wordpress, and I&#8217;m using the <a href="http://wordpress.org/extend/themes/constructor">constructor</a> theme, with some custom mods.  Hope you like orange!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.fogel.ca/2010/03/30/the-new-site/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Ruby on Rails on DreamHost Installation</title>
		<link>http://www.fogel.ca/2009/02/10/ruby-on-rails-on-dreamhost-installation/</link>
		<comments>http://www.fogel.ca/2009/02/10/ruby-on-rails-on-dreamhost-installation/#comments</comments>
		<pubDate>Wed, 11 Feb 2009 02:44:07 +0000</pubDate>
		<dc:creator>Mike Fogel</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[dreamhost]]></category>
		<category><![CDATA[howto]]></category>
		<category><![CDATA[rubyonrails]]></category>
		<category><![CDATA[tech]]></category>

		<guid isPermaLink="false">http://blog.fogel.ca/?p=409</guid>
		<description><![CDATA[I&#8217;m no Rails expert, nor a Ruby expert, and this is only my second installation of Rails in 4 years, and my first on DreamHost.  So no promises.  But here are the steps I went through to get Rails working on DreamHost with MySQL.


Set up a domain and directory. This where your Rails installation will [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;m no <a href="http://rubyonrails.org/">Rails</a> expert, nor a <a href="http://ruby-lang.org/">Ruby</a> expert, and this is only my second installation of Rails in 4 years, and my first on <a href="http://www.dreamhost.com/r.cgi?314813">DreamHost</a>.  So no promises.  But here are the steps I went through to get Rails working on DreamHost with MySQL.</p>
<ol>
<li>
<p><em>Set up a domain and directory.</em> This where your Rails installation will live.   <a href="http://wiki.dreamhost.com/Rails">DreamHost&#8217;s preferred method of running Rails</a> is now officially with <a href="http://www.modrails.com/">Passenger</a> (aka mod_rails) which they have on all their Apache 2 servers.  You can use the DreamHost admin panel to set this up: go Domains-&gt;Manage Domains-&gt;Add New Domain/Sub-Domain and make sure to check off on &#8220;Ruby on Rails Passenger (mod_rails)&#8221;.  If you plan on making ~/path/to/rails/root your root directory for your Rails installation, then you need set the web root directory to ~/path/to/rails/root/public when you add this domain using the DreamHost admin panel.</p>
</li>
<li>
<p><em>Set up a database.</em> You can do this through DreamHost&#8217;s admin panel as well.  Goodies-&gt;Manage MySQL-&gt;Create a new MySQL database.</p>
</li>
<li>
<p><em>Set up Rails.</em> Go to the directory you&#8217;re going to run your Rails installation out of (~/path/to/rails/root from step 1) and run:</p>
<pre>
rails . -d mysql
</pre>
<p>(Note the dot for &#8216;current directory&#8217;.)  This will create all the Rails directory structure and default starter files.</p>
</li>
<li>
<p><em>Set the permissions.</em> I&#8217;m not sure what the exact minimum possible permissions are to run Rails on DreamHost, but this created an acceptable situation for me for now: (note that I ran step 3 with a umask of 0027)</p>
<pre>
find ./ -type d -exec chmod o+x {} \;
find ./ -type f -exec chmod o+r {} \;
chmod o-r config/database.yml
</pre>
<p>You would absolutely want to lock these permissions down further if your application involved any sensitive data or services whatsoever.  Leaving all your scripts world-readable allows any other DreamHost user to potentially scan your code and look for vulnerabilities.</p>
</li>
<li>
<p><em>Do an intermediate test.</em> At this point you should be able to navigate to your domain and see the <a href="http://www.ridaalbarazi.com/blog/wp-content/uploads/2006/06/testapp.png">Rails welcome page</a>.  Note that the &#8220;About your application&#8217;s environment&#8221; link will not work in &#8216;production&#8217; mode, DreamHost&#8217;s default.  If things aren&#8217;t working, your friends are the logs in ~/logs/your.rails.domain.com/http and ~/path/to/rails/root/log.</p>
</li>
<li>
<p><em>Set up the database connection.</em> This involves editing the file config/database.yml.  DreamHost has its Virtual Hosts set up to default your Rails installation to run as &#8216;production&#8217;, but you can change this by setting ENV['RAILS_ENV'] in config/environment.rb.  Here&#8217;s <a href="http://craigjolicoeur.com/blog/2008/11/set-rails_env-for-phusion-passenger-on-dreamhost/">a good way</a> to do this automagically once you have development/staging/production sites all set up.  After editing any of your Rails config files, you need to do:</p>
<pre>
touch tmp/restart.txt
</pre>
<p>to make sure Apache reloads the Rails config files on the next HTTP request.</p>
</li>
<li>
<p><em>Test it.</em> My test was to get the &#8217;skeleton&#8217; version of <a href="http://crypto.stanford.edu/cs142/projects/6/project6.html">this project</a> up and running by copying a few files into the Rails directory structure in the appropriate places.</p>
</li>
</ol>
<p>Probability I find something wrong with these instructions in the next week or so?  ~80%.  I&#8217;ll update this post when I do.</p>
<p><strong>Update:</strong></p>
<p>Fyi, if you run the Webrick server in script/server, a DreamHost bot will auto email you telling you to please stop it:</p>
<blockquote><p>
<strong>From:</strong> DreamHost Policy Bot &lt;support@dreamhost.com&gt;<br />
<strong>To:</strong> Michael Fogel 	&lt;******@gmail.com&gt;<br />
Our automated system has come across the following activity under your account that is in violation of our Terms of Service.<br />
We request that you take any necessary action to cease the activity as quickly as possible or we will be forced to take further action.  If you were not aware of any such activity, please feel free to contact support and we can look into the issue further.</p>
<p>User **** running &#8220;ruby ./script/server&#8221;.  This process is against our policies.</p>
<p>Please run ruby via cgi, not the built-in Webrick web server
</p></blockquote>
<p>They should add to this email a thinger about mod_rails being their preferred way to run Rails.</p>
<p><strong>Update 2:</strong></p>
<p>Ug, you <a href="http://code.google.com/p/phusion-passenger/issues/detail?id=94">can&#8217;t use HTTP Basic Auth with mod_rails</a> (as of version 2.0.6).  Note this is what DreamHost will set up for you if you use their web panel to set up authentication.  Here&#8217;s a <a href="http://frane.offbyte.com/2009/01/30/basic-authentication-problems-with-phusion-passanger-mod_rails/">relatively simple if not elegant solution</a> to the problem while we wait for mod_rails 2.1 to be released.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.fogel.ca/2009/02/10/ruby-on-rails-on-dreamhost-installation/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>AutoTracOnDreamHost v1.1.0</title>
		<link>http://www.fogel.ca/2008/11/14/autotracondreamhost-v1-1-0/</link>
		<comments>http://www.fogel.ca/2008/11/14/autotracondreamhost-v1-1-0/#comments</comments>
		<pubDate>Fri, 14 Nov 2008 22:26:13 +0000</pubDate>
		<dc:creator>Mike Fogel</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[dreamhost]]></category>
		<category><![CDATA[releases]]></category>
		<category><![CDATA[tech]]></category>
		<category><![CDATA[trac]]></category>

		<guid isPermaLink="false">http://blog.fogel.ca/?p=294</guid>
		<description><![CDATA[I&#8217;ve made a few updates to the original AutoTracOnDreamHost.  They are:

Bumped up to Trac 0.11.2, just released last weekend.
The python version you use is now a config option in configure.inc &#8211; though Trac 0.11.2 proper requires python2.4, this is expected to be fixed in Trac 0.11.2.1.
If DH has installed setuptools on your machine, now AutoTracOnDreamHost [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve made a few updates to the <a href="http://blog.fogel.ca/2008/09/30/trac-011-auto-install-on-dreamhost/">original AutoTracOnDreamHost</a>.  They are:</p>
<ul>
<li>Bumped up to <a href="http://trac.edgewall.org/wiki/TracDownload">Trac 0.11.2</a>, just released last weekend.</li>
<li>The python version you use is now a config option in configure.inc &#8211; though Trac 0.11.2 proper requires python2.4, this is <a href="http://trac.edgewall.org/ticket/7801">expected to be fixed in Trac 0.11.2.1</a>.</li>
<li>If DH has installed setuptools on your machine, now AutoTracOnDreamHost doesn&#8217;t use it, as it may be too far out of date to install the latest and greatest mysqldb, genshi, or pygments.</li>
<li>Minor edits to the README.</li>
</ul>
<p>Questions?  Bugs?  Please use the comments.  Enjoy!</p>
<p><strong>README:</strong></p>
<pre>
AutoTracOnDreamHost: README

#################### LICENSE #####################

AutoTracOnDreamHost is free software: you can redistribute
it and/or modify it under the terms of the GNU General Public
License as published by the Free Software Foundation, either
version 3 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

http://www.gnu.org/licenses/gpl-3.0.html

#################### HowTo #######################

Preliminaries:

  1. Assuming you're going to use this with SVN, you need to already
     have an SVN repository setup and running.  The webserver needs
     to have at least read permissions to the repository.

  2. You need to have a complete domain/subdomain set up to use
     with trac or a subdirectory of an existing domain.

  3. A MySQL database ready to use with trac.  This doesn't have to
     be it's own database, but AFAIK, there is no good reason not
     to give each trac site it's own database.

  4. Trac 0.11.2.0 requires python 2.4, not 2.3.  Trac 0.11.2.1 (not
     out as of this writing) should fix this
     (http://trac.edgewall.org/ticket/7801).

  5. To avoid permission failings by apache, it's best to install this
     using the same user as you have apache doing it's cgi stuff under (If
     you didn't change anything from the dreamhost default - then you have
     only one user and you can ignore this step.)

Do once:

  1. Edit the configure.inc:

     - you probably want the latest and greatest of Trac, Genshi,
       MySQLDB, and Pygments.  Minor version releases of these
       shouldn't break this script.
     - alter the trac directory structure to your liking, or just
       run with my setup.

  2. Run the backend.sh.  This will set up all the parts of trac that
     are shared between all your trac sites (even if you have only one).

Do once per trac site:

  1. Run the site.sh.  This script will query you for details about
     the configuration of your database, your directory structure,
     svn repository, an admin trac user etc.

  2. Test it! Go to your new trac url and log in, browse the svn
     repository, create a dummy ticket etc.

#################### Help Me! ####################

I'll post about any major updates or known bugs on my blog.
http://blog.fogel.ca  In event of enough interest in these
scripts, I'll set up a public repository for it so we can
all contribute.

If you find any major bugs or want to submit a patch, you can
email me which is my first name (mike) at my domain (fogel.ca).
Requests for personalized help will be answered in the limit
of infinite free time, which I don't have, so no promises.

Elsewise, the best conglomeration of information about Trac
on DreamHost AFAIK is currently at on the DreamHost wiki.
http://wiki.dreamhost.com/Trac

##################################################
</pre>
<p><strong>configure.inc:</strong></p>
<pre>
# AutoTracOnDreamHost: configure.inc
# Released under GLPv3. http://www.gnu.org/licenses/gpl-3.0.html
# Copyright 2008 Michael Fogel. http://fogel.ca

# Abort on any errors
set -e

PYTHON_VERS=2.4
TRAC_VERS=0.11.2
GENSHI_VERS=0.5.1
MYSQLDB_VERS=1.2.2
PYGMENTS_VERS=0.11.1

# trac dir structure
TRAC_ROOT="${HOME}/trac"
PKG=${TRAC_ROOT}/packages
EGG=${TRAC_ROOT}/egg_cache
INSTALL=${TRAC_ROOT}/install
SITES=${TRAC_ROOT}/sites
SVN=${HOME}/svn
TRAC_SITE_PACKAGES=${PKG}/lib/python${PYTHON_VERS}/site-packages
TRAC_HTDOCS=${TRAC_SITE_PACKAGES}/Trac-${TRAC_VERS}-py${PYTHON_VERS}.egg/trac/htdocs

EXP_CMD1="export PYTHONPATH=$TRAC_SITE_PACKAGES"
EXP_CMD2="export PYTHON_EGG_CACHE=$EGG"
EXP_CMD3="export LD_LIBRARY_PATH=$PKG/lib"
EXP_CMD4="export PATH=$PKG/bin:\$PATH"

cat &lt;&lt;OutputDreamTracInstallReminder

==== Put the following in your ~/.bash_profile ====
Where trac/packages=PKG
$EXP_CMD1
$EXP_CMD2
$EXP_CMD3
$EXP_CMD4
===================================================

OutputDreamTracInstallReminder

# modify those env vars for the duration of this script too.
$EXP_CMD1
$EXP_CMD2
$EXP_CMD3
if [[ "$PATH" != *"$PKG/bin"* ]]; then export PATH=$PKG/bin:$PATH; fi

# Update version information here and DIRs below.

TRAC=http://ftp.edgewall.com/pub/trac/Trac-${TRAC_VERS}.tar.gz
GENSHI=http://ftp.edgewall.com/pub/genshi/Genshi-${GENSHI_VERS}.tar.gz
SETUPTOOLS=http://peak.telecommunity.com/dist/ez_setup.py
MYSQLDB=http://switch.dl.sourceforge.net/sourceforge/mysql-python/MySQL-python-${MYSQLDB_VERS}.tar.gz
PYGMENTS=http://pypi.python.org/packages/source/P/Pygments/Pygments-${PYGMENTS_VERS}.tar.gz

TRACDIR=Trac-${TRAC_VERS}
GENSHIDIR=Genshi-${GENSHI_VERS}
MYSQLDBDIR=MySQL-python-${MYSQLDB_VERS}
PYGMENTSDIR=Pygments-${PYGMENTS_VERS}

#### function getInupt - used primarily in site.sh #####
# arg 1: message
# arg 2: initial value
function getInput {
  MES="$1"
  eval "VAL=\$$2"
  echo ""
  echo "Press enter to accept the current value, or input a new value."
  TMP="$VAL"
  while [[ -n "$TMP" ]]; do
    VAL="$TMP"
    echo "$MES: $VAL"
    read TMP
  done
  echo "Using $MES: $VAL"
  eval "$2=\"$VAL\""
}
</pre>
<p><strong>backend.sh:</strong></p>
<pre>
# AutoTracOnDreamHost: backend.sh
# Released under GLPv3. http://www.gnu.org/licenses/gpl-3.0.html
# Copyright 2008 Michael Fogel. http://fogel.ca

source ./configure.inc

echo -e "\n==== Creating need dir structure ===="
[ ! -d ${PKG} ] &amp;&amp; mkdir -p ${PKG}
# the egg_cache dir must be writable by your apache cgi/python user
[ ! -d ${EGG} ] &amp;&amp; mkdir -p ${EGG} &amp;&amp; chmod 770 ${EGG}
[ ! -d ${INSTALL} ] &amp;&amp; mkdir -p ${INSTALL}
[ ! -d ${SITES} ] &amp;&amp; mkdir -p ${SITES}

echo -e "\n==== Retrieving installation files ===="
cd ${INSTALL}
[ ! -f ${TRACDIR}.tar.gz ] &amp;&amp; wget ${TRAC}
[ ! -f ${GENSHIDIR}.tar.gz ] &amp;&amp; wget ${GENSHI}
[ ! -f ${MYSQLDBDIR}.tar.gz ] &amp;&amp; wget ${MYSQLDB}
[ ! -f ${PYGMENTSDIR}.tar.gz ] &amp;&amp; wget ${PYGMENTS}
[ ! -f ez_setup.py ] &amp;&amp; wget ${SETUPTOOLS}

echo -e "\n==== Installing Setup Tools ===="
#Create site-packages directory. Script will fail without it.
mkdir -p ${TRAC_SITE_PACKAGES}
cd ${INSTALL} &amp;&amp; python ez_setup.py --prefix=${PKG}

echo -e "\n==== Installing Pygments ===="
cd ${INSTALL} &amp;&amp; tar xzf ${PYGMENTSDIR}.tar.gz
cd ${PYGMENTSDIR} &amp;&amp; python setup.py install --prefix=${PKG}

echo -e "\n==== Installing MYSQLdb ===="
cd ${INSTALL} &amp;&amp; tar xzf ${MYSQLDBDIR}.tar.gz
cd ${MYSQLDBDIR} &amp;&amp; python setup.py install --prefix=${PKG}

echo -e "\n==== Installing Genshi ===="
cd ${INSTALL} &amp;&amp; tar xzf ${GENSHIDIR}.tar.gz
cd ${GENSHIDIR} &amp;&amp; python setup.py install --prefix=${PKG}

echo -e "\n==== Installing Trac ===="
cd ${INSTALL} &amp;&amp; tar xzf ${TRACDIR}.tar.gz
cd ${TRACDIR} &amp;&amp; python setup.py install --prefix=${PKG}
mkdir -p ${PKG}/share/trac
cp -fr ${INSTALL}/${TRACDIR}/cgi-bin ${PKG}/share/trac

echo -e "\n==== Setting permissions for Trac htdocs ===="
DIR=${TRAC_HTDOCS}
while [ "$DIR" != "$HOME" ]; do
  chmod o+x $DIR
  DIR=`dirname $DIR`
done
find ${TRAC_HTDOCS} -type d -exec chmod 751 {} \;
find ${TRAC_HTDOCS} -type f -exec chmod 644 {} \;

echo -e "\n==== Backend install complete ===="
</pre>
<p><strong>site.sh:</strong></p>
<pre>
# AutoTracOnDreamHost: site.sh
# Released under GLPv3. http://www.gnu.org/licenses/gpl-3.0.html
# Copyright 2008 Michael Fogel. http://fogel.ca

source ./configure.inc

# Prompt for project parameters, with defaults
PROJECT=somesvnproject;         getInput "Subversion Project ID"  PROJECT
DOMAIN=trac.somedomain.com;     getInput "Domain for Trac"        DOMAIN
DOMAINDIR=${HOME}/http/$DOMAIN; getInput "Path for domain root"   DOMAINDIR
TRACPATH=/trac;                 getInput "Relative Path for Trac" TRACPATH
MYSQLHOST=mysql.$DOMAIN;        getInput "MySQL hostname"         MYSQLHOST
MYSQLUSER=trac_username;        getInput "MySQL username"         MYSQLUSER
MYSQLPASSWD=trac_password;      getInput "MySQL password"         MYSQLPASSWD
MYSQLDBNAME=trac_$PROJECT;      getInput "MySQL DB name"          MYSQLDBNAME
TRAC_USER=admin;                getInput "Trac Admin username"    TRAC_USER
TRAC_PASSWORD=password;         getInput "Trac Admin password"    TRAC_PASSWORD

# confirm those values
echo "Please confirm the values you entered:"
echo "PROJECT:${PROJECT}"
echo "DOMAIN:${DOMAIN}"
echo "DOMAINDIR:${DOMAINDIR}"
echo "TRACPATH:${TRACPATH}"
echo "MYSQLHOST:${MYSQLHOST}"
echo "MYSQLUSER:${MYSQLUSER}"
echo "MYSQLPASSWD:${MYSQLPASSWD}"
echo "MYSQLDBNAME:${MYSQLDBNAME}"
echo "TRAC_USER:${TRAC_USER}"
echo "TRAC_PASSWORD:${TRAC_PASSWORD}"
echo "Look good?"
lookingGood=Yes;
getInput "Looking good? 'Yes' to continue, all else to quit." lookingGood
[ "$lookingGood" != "Yes" ] &amp;&amp; exit 1;

# Vars for this site
WEBDIR=${DOMAINDIR}/${TRACPATH}
INDEX_CGI=${WEBDIR}/index.cgi
TRACINI=${SITES}/${PROJECT}/conf/trac.ini
HTACCESS=${WEBDIR}/.htaccess
HTPASSWD=${WEBDIR}/.htpasswd
NAME="Trac: ${DOMAIN}${TRACPATH}/"

echo "Setup site"
if [ ! -d ${SITES}/${PROJECT} ]; then

  #Setup Trac Environment for MySQL
  ${PKG}/bin/trac-admin ${SITES}/${PROJECT} \
    initenv ${PROJECT} \
    "mysql://${MYSQLUSER}:${MYSQLPASSWD}@${MYSQLHOST}/${MYSQLDBNAME}" \
    svn \
    ${SVN}/${PROJECT};

  # set admin user to premissions
  ${PKG}/bin/trac-admin ${SITES}/${PROJECT} \
  permission add $TRAC_USER TRAC_ADMIN
fi

echo "Make Trac Web Accessible"
# Make Trac Web Accessible
mkdir -p ${WEBDIR}
chmod 751 ${WEBDIR}

if [ -f "${INDEX_CGI}" ]; then
  rm ${INDEX_CGI}
fi
echo "#!/bin/bash" &gt;&gt; ${INDEX_CGI}
echo "export HOME=\"/home/${USER}\"" &gt;&gt; ${INDEX_CGI}
echo "export TRAC_ENV=\"$SITES/${PROJECT}\"" &gt;&gt; ${INDEX_CGI}
echo "$EXP_CMD1" &gt;&gt; ${INDEX_CGI}
echo "$EXP_CMD2" &gt;&gt; ${INDEX_CGI}
echo "$EXP_CMD3" &gt;&gt; ${INDEX_CGI}
echo "$EXP_CMD4" &gt;&gt; ${INDEX_CGI}
echo "exec $PKG/share/trac/cgi-bin/trac.cgi" &gt;&gt; ${INDEX_CGI}
chmod 755 ${INDEX_CGI}

# logo in trac.ini
sed -i "s/^alt = .*$/alt = trac_banner.png/" ${TRACINI}
# some fancy sed to escape forward slashes... simplier patches are welcome.
TRACPATH_S=`echo ${TRACPATH} | sed -e "s/\/$//" -e "s/\//\\\\\\ \//g" -e "s/ \//\//g"`
sed -i "s/^src = .*$/src = ${TRACPATH_S}\/chrome\/common\/trac_banner.png/"${TRACINI}

#Pretty URLs
mkdir -p ${WEBDIR}/chrome
chmod 751 ${WEBDIR}/chrome
ln -sf ${TRAC_HTDOCS} ${WEBDIR}/chrome/common

# .htaccess fun
if [ -f ${HTACCESS} ]; then
  rm ${HTACCESS}
fi

touch ${HTACCESS}
chmod 644 ${HTACCESS}

echo "AuthType Basic" &gt;&gt; ${HTACCESS}
echo "AuthUserFile ${HTPASSWD}" &gt;&gt; ${HTACCESS}
echo "AuthName '${NAME}'" &gt;&gt; ${HTACCESS}
echo "require valid-user" &gt;&gt; ${HTACCESS}
echo "" &gt;&gt; ${HTACCESS}
echo "DirectoryIndex index.cgi" &gt;&gt; ${HTACCESS}
echo "Options ExecCGI FollowSymLinks" &gt;&gt; ${HTACCESS}
echo "" &gt;&gt; ${HTACCESS}
echo "" &gt;&gt; ${HTACCESS}
echo "RewriteEngine On" &gt;&gt; ${HTACCESS}
echo "RewriteCond %{REQUEST_FILENAME} !-f" &gt;&gt; ${HTACCESS}
echo "RewriteCond %{REQUEST_FILENAME} !-d" &gt;&gt; ${HTACCESS}
echo "RewriteRule ^(.*)\$ ${TRACPATH}/index.cgi/\$1 [L]" &gt;&gt; ${HTACCESS}
echo "" &gt;&gt; ${HTACCESS}

#Create .htpasswd file for trac admin with password
htpasswd -bc ${HTPASSWD} $TRAC_USER "$TRAC_PASSWORD"

# Note: on DreamHost you avoid a world-readable htpasswd file by
# setting one up via panel.dreamhost.com-&gt;Goodies-&gt;Htaccess/WebDAV.
# This will make htpasswd and htaccess files (overwriting anything
# that's there) that has group dhapache, is group readable, and
# the apache user is in the dhapache group.  Baring this, you need
# to make your htpasswd file word-readable (or email support for
# some chgrp action as root)
chmod 644 ${HTPASSWD}

echo ---------- SITE INSTALL COMPLETE! ----------
</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.fogel.ca/2008/11/14/autotracondreamhost-v1-1-0/feed/</wfw:commentRss>
		<slash:comments>10</slash:comments>
		</item>
		<item>
		<title>Trac 0.11 Auto-Install on DreamHost</title>
		<link>http://www.fogel.ca/2008/09/30/trac-011-auto-install-on-dreamhost/</link>
		<comments>http://www.fogel.ca/2008/09/30/trac-011-auto-install-on-dreamhost/#comments</comments>
		<pubDate>Wed, 01 Oct 2008 00:29:42 +0000</pubDate>
		<dc:creator>Mike Fogel</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[dreamhost]]></category>
		<category><![CDATA[howto]]></category>
		<category><![CDATA[releases]]></category>
		<category><![CDATA[tech]]></category>
		<category><![CDATA[trac]]></category>

		<guid isPermaLink="false">http://blog.fogel.ca/?p=55</guid>
		<description><![CDATA[Update: I&#8217;ve released an updated version of AutoTracOnDreamHost.
Trac 0.11 is out.  And it&#8217;s awesome &#8211; both the usability in enhancements in 0.11 and Trac in general.  Trac is one of those tools in my toolbox I use to up my productivity a few notches.  For small projects, it&#8217;s a nice convenient time [...]]]></description>
			<content:encoded><![CDATA[<p><strong>Update:</strong> I&#8217;ve released an updated version of <a href="http://blog.fogel.ca/2008/11/14/autotracondreamhost-v1-1-0/">AutoTracOnDreamHost</a>.</p>
<p><a href="http://trac.edgewall.org/wiki/TracDownload">Trac 0.11</a> is out.  And it&#8217;s awesome &#8211; both the usability in enhancements in 0.11 and Trac in general.  Trac is one of those tools in my toolbox I use to up my productivity a few notches.  For small projects, it&#8217;s a nice convenient time saver.  For large projects, having the project management tools trac provides makes an astonishing difference in group productivity and allows for a significantly higher quality final product.</p>
<p>On my web host, <a href="http://www.dreamhost.com/">DreamHost</a>, Trac is <a href="http://wiki.dreamhost.com/Trac_Install">non-trivial</a> to install&#8230; until now!  I&#8217;ve written a set of scripts that make it semi-trivial to set Trac 0.11 up on DreamHost.  Original inspiration came from the &#8216;<a href="http://wiki.dreamhost.com/DreamTracInstall">auto-install</a>&#8216; on the DreamHost wiki, which is great that it&#8217;s there, but it was awkward for my configuration and, IMHO, suffers from backward compatibility and feature bloat issues.  So, I wrote up some scripts that work well with my configuration.  The README explains how to use them.</p>
<p>You may also want to check out the <a href="http://code.google.com/p/dreamy-trac/">dreamy-trac</a> project.  Both that code and these scripts were originally based off the same code on the DreamHost wiki, so you&#8217;ll see similarities.  They both get you to a similar end result.  I know in these scripts I&#8217;ve emphasized simplicity as much as possible at the expense of installing any extra plugins, or customization, or whatnot.</p>
<p>If there&#8217;s a fair amount of traffic coming here and it looks like people are using these, I&#8217;ll set them up on a public repository for easier access and collaboration.  In the meantime, keeping it simple&#8230; here they are.</p>
<p><strong>README</strong>:</p>
<pre>
# AutoTracOnDreamHost: README
# Released under GLPv3. http://www.gnu.org/licenses/gpl-3.0.html
# Copyright 2008 Michael Fogel. http://fogel.ca

#################### LICENSE #####################

AutoTracOnDreamHost is free software: you can redistribute
it and/or modify it under the terms of the GNU General Public
License as published by the Free Software Foundation, either
version 3 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

http://www.gnu.org/licenses/gpl-3.0.html

#################### HowTo #######################

Preliminaries:

  1. Assuming you're going to use this with SVN, you need to already
     have an SVN repository setup and running.  The webserver needs
     to have at least read permissions to the repository.

  2. You need to have a complete domain/subdomain set up to use
     with trac or a subdirectory of an existing domain.

  3. A MySQL database ready to use with trac.  This doesn't have to
     be it's own database, but AFAIK, there is no good reason not
     to give each trac site it's own database.

Do once: 

  1. Edit the configure.inc:

     - you probably want the latest and greatest of Trac, Genshi,
       MySQLDB, and Pygments.  Minor version releases of these
       shouldn't break this script.

     - alter the trac directory structure to your liking, or just
       run with my setup.

  2. Run the backend.sh.  This will set up all the parts of trac that
     are shared between all your trac sites (even if you have only one).

Do once per trac site:

  1. Run the site.sh.  This script will query you for details about
     the configuration of your database, your directory structure,
     svn repository, an admin trac user etc.

  2. Test it! Go to your new trac url and log in, browse the svn
     repository, create a dummy ticket etc.

#################### Help Me! ####################

I'll post about any major updates or known bugs on my blog.
http://blog.fogel.ca  In event of enough interest in these
scripts, I'll set up a public repository for it so we can
all contribute.

If you find any major bugs or want to submit a patch, you can
email me which is my first name (mike) at my domain (fogel.ca).
Requests for personalized help will be answered in the limit
of infinite free time, which I don't have, so no promises.

Elsewise, the best conglomeration of information about Trac
on DreamHost AFAIK is currently at on the DreamHost wiki.
http://wiki.dreamhost.com/Trac

##################################################
</pre>
<p><strong>configure.inc:</strong></p>
<pre>
# AutoTracOnDreamHost: configure.inc
# Released under GLPv3. http://www.gnu.org/licenses/gpl-3.0.html
# Copyright 2008 Michael Fogel. http://fogel.ca

# Abort on any errors
set -e

TRAC_VERS=0.11.1
GENSHI_VERS=0.5.1
MYSQLDB_VERS=1.2.2
PYGMENTS_VERS=0.11.1

# trac dir structure
TRAC_ROOT="${HOME}/trac"
PKG=${TRAC_ROOT}/packages
EGG=${TRAC_ROOT}/egg_cache
INSTALL=${TRAC_ROOT}/install
SITES=${TRAC_ROOT}/sites
SVN=${HOME}/svn
TRAC_SITE_PACKAGES=${PKG}/lib/python2.3/site-packages
TRAC_HTDOCS=${TRAC_SITE_PACKAGES}/Trac-${TRAC_VERS}-py2.3.egg/trac/htdocs

EXP_CMD1="export PYTHONPATH=$TRAC_SITE_PACKAGES"
EXP_CMD2="export PYTHON_EGG_CACHE=$EGG"
EXP_CMD3="export LD_LIBRARY_PATH=$PKG/lib"
EXP_CMD4="export PATH=$PKG/bin:\$PATH"

cat &lt;&lt;OutputDreamTracInstallReminder

==== Put the following in your ~/.bash_profile ====
Where trac/packages=PKG
$EXP_CMD1
$EXP_CMD2
$EXP_CMD3
$EXP_CMD4
===================================================

OutputDreamTracInstallReminder

# modify those env vars for the duration of this script too.
$EXP_CMD1
$EXP_CMD2
$EXP_CMD3
if [[ "$PATH" != *"$PKG/bin"* ]]; then export PATH=$PKG/bin:$PATH; fi

# Update version information here and DIRs below.

TRAC=http://ftp.edgewall.com/pub/trac/Trac-${TRAC_VERS}.tar.gz
GENSHI=http://ftp.edgewall.com/pub/genshi/Genshi-${GENSHI_VERS}.tar.gz
SETUPTOOLS=http://peak.telecommunity.com/dist/ez_setup.py
MYSQLDB=http://switch.dl.sourceforge.net/sourceforge/mysql-python/MySQL-python-${MYSQLDB_VERS}.tar.gz
PYGMENTS=http://pypi.python.org/packages/source/P/Pygments/Pygments-${PYGMENTS_VERS}.tar.gz

TRACDIR=Trac-${TRAC_VERS}
GENSHIDIR=Genshi-${GENSHI_VERS}
MYSQLDBDIR=MySQL-python-${MYSQLDB_VERS}
PYGMENTSDIR=Pygments-${PYGMENTS_VERS}

#### function getInupt - used primarily in site.sh #####
# arg 1: message
# arg 2: initial value
function getInput {
	MES="$1"
	eval "VAL=\$$2"
	echo ""
	echo "Press enter to accept the current value, or input a new value."
	TMP="$VAL"
	while [[ -n "$TMP" ]]; do
		VAL="$TMP"
		echo "$MES: $VAL"
		read TMP
	done
	echo "Using $MES: $VAL"
	eval "$2=\"$VAL\""
}
</pre>
<p><strong>backend.sh:</strong></p>
<pre>
# AutoTracOnDreamHost: backend.sh
# Released under GLPv3. http://www.gnu.org/licenses/gpl-3.0.html
# Copyright 2008 Michael Fogel. http://fogel.ca

source ./configure.inc

echo -e "\n==== Creating need dir structure ===="
[ ! -d ${PKG} ] &#038;&#038; mkdir -p ${PKG}
# the egg_cache dir must be writable by your apache cgi/python user
[ ! -d ${EGG} ] &#038;&#038; mkdir -p ${EGG} &#038;&#038; chmod 770 ${EGG}
[ ! -d ${INSTALL} ] &#038;&#038; mkdir -p ${INSTALL}
[ ! -d ${SITES} ] &#038;&#038; mkdir -p ${SITES}

echo -e "\n==== Retrieving installation files ===="
cd ${INSTALL}
[ ! -f ${TRACDIR}.tar.gz ] &#038;&#038; wget ${TRAC}
[ ! -f ${GENSHIDIR}.tar.gz ] &#038;&#038; wget ${GENSHI}
[ ! -f ${MYSQLDBDIR}.tar.gz ] &#038;&#038; wget ${MYSQLDB}
[ ! -f ${PYGMENTSDIR}.tar.gz ] &#038;&#038; wget ${PYGMENTS}
[ ! -f ez_setup.py ] &#038;&#038; wget ${SETUPTOOLS}

echo -e "\n==== Installing Setup Tools ===="
#Create site-packages directory. Script will fail without it.
mkdir -p ${TRAC_SITE_PACKAGES}
[ -z `which easy_install` ] &#038;&#038; cd ${INSTALL} &#038;&#038; python ez_setup.py --prefix=${PKG}

echo -e "\n==== Installing Pygments ===="
cd ${INSTALL} &#038;&#038; tar xzf ${PYGMENTSDIR}.tar.gz
cd ${PYGMENTSDIR} &#038;&#038; python setup.py install --prefix=${PKG}

echo -e "\n==== Installing MYSQLdb ===="
cd ${INSTALL} &#038;&#038; tar xzf ${MYSQLDBDIR}.tar.gz
cd ${MYSQLDBDIR} &#038;&#038; python setup.py install --prefix=${PKG}

echo -e "\n==== Installing Genshi ===="
cd ${INSTALL} &#038;&#038; tar xzf ${GENSHIDIR}.tar.gz
cd ${GENSHIDIR} &#038;&#038; python setup.py install --prefix=${PKG}

echo -e "\n==== Installing Trac ===="
cd ${INSTALL} &#038;&#038; tar xzf ${TRACDIR}.tar.gz
cd ${TRACDIR} &#038;&#038; python setup.py install --prefix=${PKG}
mkdir -p ${PKG}/share/trac
cp -fr ${INSTALL}/${TRACDIR}/cgi-bin ${PKG}/share/trac

echo -e "\n==== Setting permissions for Trac htdocs ===="
DIR=${TRAC_HTDOCS}
while [ "$DIR" != "$HOME" ]; do
	chmod o+x $DIR
	DIR=`dirname $DIR`
done
find ${TRAC_HTDOCS} -type d -exec chmod 751 {} \;
find ${TRAC_HTDOCS} -type f -exec chmod 644 {} \;

echo -e "\n==== Backend install complete ===="
</pre>
<p><strong>site.sh:</strong></p>
<pre>
# AutoTracOnDreamHost: site.sh
# Released under GLPv3. http://www.gnu.org/licenses/gpl-3.0.html
# Copyright 2008 Michael Fogel. http://fogel.ca

source ./configure.inc

# Defaults
PROJECT=somesvnproject
DOMAIN=trac.somedomain.com
DOMAINDIR=${HOME}/http/$DOMAIN  # default refreshed after sampling DOMAIN
TRACPATH=/trac
MYSQLHOST=mysql.$DOMAIN         # default refreshed after sampling DOMAIN
MYSQLUSER=trac_username
MYSQLPASSWD=trac_password
MYSQLDBNAME=trac_$PROJECT       # default refreshed after sampling PROJECT
TRAC_USER=admin
TRAC_PASSWORD=password

# Prompt on those defaults
getInput "Subversion Project ID"                 PROJECT
getInput "Domain for Trac"                       DOMAIN
DOMAINDIR=${HOME}/http/$DOMAIN
MYSQLHOST=mysql.$DOMAIN
getInput "Path for domain root"                  DOMAINDIR
getInput "Path for Trac relative to domain root" TRACPATH
getInput "MySQL hostname"                        MYSQLHOST
getInput "MySQL username"                        MYSQLUSER
getInput "MySQL password"                        MYSQLPASSWD
MYSQLDBNAME=trac_$PROJECT
getInput "MySQL DB name"                         MYSQLDBNAME
getInput "Trac Admin username"                   TRAC_USER
getInput "Trac Admin password"                   TRAC_PASSWORD

# using these values
echo "PROJECT:${PROJECT}"
echo "DOMAIN:${DOMAIN}"
echo "DOMAINDIR:${DOMAINDIR}"
echo "TRACPATH:${TRACPATH}"
echo "MYSQLHOST:${MYSQLHOST}"
echo "MYSQLUSER:${MYSQLUSER}"
echo "MYSQLPASSWD:${MYSQLPASSWD}"
echo "MYSQLDBNAME:${MYSQLDBNAME}"
echo "TRAC_USER:${TRAC_USER}"
echo "TRAC_PASSWORD:${TRAC_PASSWORD}"

# Vars for this site
WEBDIR=${DOMAINDIR}/${TRACPATH}
INDEX_CGI=${WEBDIR}/index.cgi
TRACINI=${SITES}/${PROJECT}/conf/trac.ini
HTACCESS=${WEBDIR}/.htaccess
HTPASSWD=${WEBDIR}/.htpasswd
NAME="Trac: ${DOMAIN}${TRACPATH}/"

echo "Setup site"
if [ ! -d ${SITES}/${PROJECT} ]; then

	#Setup Trac Environment for MySQL
	${PKG}/bin/trac-admin ${SITES}/${PROJECT} \
		initenv ${PROJECT} \
		"mysql://${MYSQLUSER}:${MYSQLPASSWD}@${MYSQLHOST}/${MYSQLDBNAME}" \
		svn \
		${SVN}/${PROJECT};

	# set admin user to premissions
	${PKG}/bin/trac-admin ${SITES}/${PROJECT} \
	permission add $TRAC_USER TRAC_ADMIN
fi

echo "Make Trac Web Accessible"
# Make Trac Web Accessible
mkdir -p ${WEBDIR}
chmod 751 ${WEBDIR}

if [ -f "${INDEX_CGI}" ]; then
	rm ${INDEX_CGI}
fi
echo "#!/bin/bash" >> ${INDEX_CGI}
echo "export HOME=\"/home/${USER}\"" >> ${INDEX_CGI}
echo "export TRAC_ENV=\"$SITES/${PROJECT}\"" >> ${INDEX_CGI}
echo "$EXP_CMD1" >> ${INDEX_CGI}
echo "$EXP_CMD2" >> ${INDEX_CGI}
echo "$EXP_CMD3" >> ${INDEX_CGI}
echo "$EXP_CMD4" >> ${INDEX_CGI}
echo "exec $PKG/share/trac/cgi-bin/trac.cgi" >> ${INDEX_CGI}
chmod 755 ${INDEX_CGI}

# logo in trac.ini
sed -i "s/^alt = .*$/alt = trac_banner.png/" ${TRACINI}
# some fancy sed to escape forward slashes... simplier patches are welcome.
TRACPATH_S=`echo ${TRACPATH} | sed -e "s/\/$//" -e "s/\//\\\\\\ \//g" -e "s/ \//\//g"`
sed -i "s/^src = .*$/src = ${TRACPATH_S}\/chrome\/common\/trac_banner.png/" ${TRACINI}

#Pretty URLs
mkdir -p ${WEBDIR}/chrome
chmod 751 ${WEBDIR}/chrome
ln -sf ${TRAC_HTDOCS} ${WEBDIR}/chrome/common

# .htaccess fun
if [ -f ${HTACCESS} ]; then
	rm ${HTACCESS}
fi

touch ${HTACCESS}
chmod 644 ${HTACCESS}

echo "AuthType Basic" >> ${HTACCESS}
echo "AuthUserFile ${HTPASSWD}" >> ${HTACCESS}
echo "AuthName '${NAME}'" >> ${HTACCESS}
echo "require valid-user" >> ${HTACCESS}
echo "" >> ${HTACCESS}
echo "DirectoryIndex index.cgi" >> ${HTACCESS}
echo "Options ExecCGI FollowSymLinks" >> ${HTACCESS}
echo "" >> ${HTACCESS}
echo "<IfModule mod_rewrite.c>" >> ${HTACCESS}
echo "RewriteEngine On" >> ${HTACCESS}
echo "RewriteCond %{REQUEST_FILENAME} !-f" >> ${HTACCESS}
echo "RewriteCond %{REQUEST_FILENAME} !-d" >> ${HTACCESS}
echo "RewriteRule ^(.*)\$ ${TRACPATH}/index.cgi/\$1 [L]" >> ${HTACCESS}
echo "</IfModule>" >> ${HTACCESS}

#Create .htpasswd file for trac admin with password
htpasswd -bc ${HTPASSWD} $TRAC_USER "$TRAC_PASSWORD"

# Note: on DreamHost you avoid a world-readable htpasswd file by
# setting one up via panel.dreamhost.com->Goodies->Htaccess/WebDAV.
# This will make htpasswd and htaccess files (overwriting anything
# that's there) that has group dhapache, is group readable, and
# the apache user is in the dhapache group.  Baring this, you need
# to make your htpasswd file word-readable (or email support for
# some chgrp action as root)
chmod 644 ${HTPASSWD}

echo ---------- SITE INSTALL COMPLETE! ----------
</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.fogel.ca/2008/09/30/trac-011-auto-install-on-dreamhost/feed/</wfw:commentRss>
		<slash:comments>13</slash:comments>
		</item>
	</channel>
</rss>
