<?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>Ivan Kuznetsov &#187; redmine</title>
	<atom:link href="http://www.ivankuznetsov.com/tag/redmine/feed" rel="self" type="application/rss+xml" />
	<link>http://www.ivankuznetsov.com</link>
	<description>Entrepreneur, Ruby on Rails and Ubuntu fanatic, consultant</description>
	<lastBuildDate>Tue, 18 May 2010 18:39:50 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<item>
		<title>Setting up Ruby, Rails, Git and Redmine on Dreamhost</title>
		<link>http://www.ivankuznetsov.com/2009/07/setting-up-ruby-rails-git-and-redmine-on-dreamhost.html</link>
		<comments>http://www.ivankuznetsov.com/2009/07/setting-up-ruby-rails-git-and-redmine-on-dreamhost.html#comments</comments>
		<pubDate>Thu, 30 Jul 2009 14:58:27 +0000</pubDate>
		<dc:creator>Ivan Kuznetsov</dc:creator>
				<category><![CDATA[Dreamhost]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[Ruby on Rails]]></category>
		<category><![CDATA[Web/Tech]]></category>
		<category><![CDATA[git]]></category>
		<category><![CDATA[rails]]></category>
		<category><![CDATA[redmine]]></category>
		<category><![CDATA[ruby]]></category>

		<guid isPermaLink="false">http://www.ivankuznetsov.com/?p=195</guid>
		<description><![CDATA[The task is to have: - Redmine installation on redmine.mydomain.com - Several Git repositories on git.mydomain.com with different access rights to each one This proved to be a non-trivial task. There is a number of tutorials on the net, but none of them described the full solution. So after getting it all to work, I [...]]]></description>
			<content:encoded><![CDATA[<p><img class="alignleft size-full wp-image-196" title="Git, RedMine, Ruby, Rails on Dreamhost" src="http://www.ivankuznetsov.com/wp-content/uploads/git.png" alt="Git, RedMine, Ruby, Rails on Dreamhost" width="200" height="150" />The task is to have:<br />
- Redmine installation on redmine.mydomain.com<br />
- Several Git repositories on git.mydomain.com with different access rights to each one</p>
<p>This proved to be a non-trivial task. There is a number of tutorials on the net, but none of them described the full solution. So after getting it all to work, I decided to share all the tips and tricks. Feel free to comment, if you will find problems with the following set of instructions.<br />
<span id="more-195"></span>SSH to redmine.mydomain.com as a user that will be running Redmine (in the following examples it will be &#8216;redmine_user&#8217;).<br />
First, you need to compile openssl &#8211; it will be required for curl, git and redmine.</p>
<pre>mkdir ~/tmp
cd ~/tmp
wget http://www.openssl.org/source/openssl-0.9.8k.tar.gz
tar xzvf openssl-0.9.8k.tar.gz
cd openssl-0.9.8k
./config shared zlib --prefix=$HOME/.packages
make
make install</pre>
<p>Let&#8217;s tell the world that we keep binaries and libraries also in the local directory. Edit ~/.bashrc (it is used by all non-login shells):</p>
<pre>export TZ='Europe/Helsinki'
export PATH="$HOME/.packages/bin:$PATH"
export LD_LIBRARY_PATH="$HOME/.packages/lib"
export GEM_HOME="$HOME/.gems"
export GEM_PATH="$GEM_HOME:/usr/lib/ruby/gems/1.8"
export PATH="$HOME/.packages/bin:$HOME/.gems/bin:$PATH"
export RUBYLIB="$HOME/.packages/lib:$RUBYLIB"
export LD_LIBRARY_PATH="$HOME/.packages/lib"

# this ensures our gem install processes don't get killed by the DreamHost police
alias gem="nice -n19 ~/.packages/bin/gem"</pre>
<p>(You can skip TZ &#8211; it is just usefule to have correct time set for your environment. Use tzselect to find out correct TZ string for your region)</p>
<p>And edit ~/.bash_profile (it is used by login shells):</p>
<pre>umask 002
PS1='[\h:$PWD]$ '
alias ll="ls -l"
EDITOR="/usr/bin/vim"
. .bashrc</pre>
<p>Now let&#8217;s apply the changes in active shell:</p>
<pre>cd ~ : . .bash_profile</pre>
<p>Then you need to compile curl, to be able to compile git with curl and execute clone commands on your server.</p>
<pre>cd ~/tmp
wget http://curl.haxx.se/download/curl-7.19.5.tar.gz
tar xzvf curl-7.19.5.tar.gz
cd curl-7.19.5
./configure --prefix=$HOME/.packages --with-ssl=$HOME/.packages
make
make install</pre>
<p>Now get and compile Git. If you are not using Dreamhost PS, you might want to compile it with NO_MMPAP=1, to reduce<br />
probability of git process getting killed by Dreamhost police robots due to extensive memory</p>
<pre>cd ~/tmp
wget http://www.kernel.org/pub/software/scm/git/git-1.6.4.tar.gz
tar xzvf git-1.6.4.tar.gz
cd git-1.6.4
./configure --prefix=$HOME/.packages --with-curl=$HOME/.packages
make
make install</pre>
<p>Let&#8217;s start with ruby and rails related stuff. First readline library is needed, for script/console to work.</p>
<pre>cd ~/tmp
wget http://ftp.gnu.org/gnu/readline/readline-5.2.tar.gz
tar xzvf readline-5.2.tar.gz
cd readline-5.2
./configure --prefix=$HOME/.packages
make
make install</pre>
<p>Install ruby:</p>
<pre>cd ~/tmp
wget ftp://ftp.ruby-lang.org/pub/ruby/1.8/ruby-1.8.7-p72.tar.gz
tar zxvf ruby-1.8.7-p72.tar.gz
cd ruby-1.8.7-p72
./configure --prefix=$HOME/.packages --with-openssl-dir=$HOME/.packages --with-readline-dir=$HOME/.packages
make
make install</pre>
<p>Install rubygems:</p>
<pre>cd ~/tmp
wget http://rubyforge.org/frs/download.php/60718/rubygems-1.3.5.tgz
tar zxvf rubygems-1.3.5.tgz
cd rubygems-1.3.5
ruby setup.rb config --prefix=$HOME/.packages
ruby setup.rb setup
ruby setup.rb install</pre>
<p>Now you can install all required gems and freeze them if necessary.</p>
<p><strong>Installing RedMine</strong></p>
<p>Refer to <a href="http://wiki.dreamhost.com/Redmine" target="_blank">http://wiki.dreamhost.com/Redmine</a> for details.</p>
<p>But there&#8217;s one trick &#8211; if you want RedMine to use just compiled version of Git &#8211; edit in lib/redmine/scm/adapters/git_adapter.rb:</p>
<pre># Git executable name
GIT_BIN = "/home/username/.packages/bin/git"</pre>
<p>If this is not done, default Dreamhost git will be used (which is too old at the moment 1.4.4.4) and Git repository browsing will not work in RedMine<br />
(see <a href="http://groups.google.com/group/phusion-passenger/browse_thread/thread/5080d7c7cfbcf20e" target="_blank">http://groups.google.com/group/phusion-passenger/browse_thread/thread/5080d7c7cfbcf20e</a>).</p>
<p><strong>Setting up Git repository</strong></p>
<p>Refer to <a href="http://wiki.dreamhost.com/Git" target="_blank">http://wiki.dreamhost.com/Git</a> for details.</p>
<p>Couple of tricks here. There are bugs in WebDAV functionality in Ubuntu &#8211; so if you&#8217;re using it &#8211; launch Nautilus, use &#8220;File-&gt;Connect to server&#8230;&#8221; menu from there (not from the system menu), don&#8217;t enter user name in the dialog &#8211; leave it empty and enter it when you&#8217;re requested username and password in the next dialog.</p>
<p>When setting up WebDAV access rights, give access to user &#8220;redmine&#8221;.</p>
<p><strong>Setting Git repository copy for Redmine</strong></p>
<p>Create ~/.netrc for your redmine user on Dreamhost</p>
<p>Insert the following line in that file</p>
<pre>machine git.mydomain.com login redmine password [redmine_password]</pre>
<p>where redmine_password is the password you gave to user redmine in the previous step.<br />
.netrc will ensure that password is not asked when git is accessing the repository.<br />
You don&#8217;t need to bother about creating .netrc if you have a public repository (or at least available for cloning without password).</p>
<p><strong>Create a local copy of the repository</strong></p>
<p>For RedMine to be able to display Git repository, it needs to have a local clone of the repository.</p>
<pre>mkdir ~/git_project_clones
cd git_project_clones
git clone http://git.mydomain.com/repository_name</pre>
<p>Now you should have a local copy that can be used from RedMine.<br />
All you have left to do is to set up regular pulls from the master repository to this local copy. Use command</p>
<pre>crontab -e</pre>
<p>Add the following line to pull latest change into local copy every 5 minutes:</p>
<pre>*/5 * * * * cd /home/redmine_user/git_project_clones/repository_name &amp;&amp; /home/redmine_user/.packages/bin/git pull</pre>
<p>Make sure that you specify full path to git &#8211; otherwise it will execute Dreamhost default git 1.4.4.4 and command will fail with &#8220;refusing to create funny ref &#8216;remotes/origin/*&#8217; locally&#8221; error.</p>
<p>Save and exit cron editor.</p>
<p>(You might also want to check Redmine own wiki: <a href="http://www.redmine.org/wiki/redmine/HowTo_keep_in_sync_your_git_repository_for_redmine" target="_blank">http://www.redmine.org/wiki/redmine/HowTo_keep_in_sync_your_git_repository_for_redmine</a>)</p>
<p>Set repository in the settings of your project in RedMine: /home/redmine_user/git_project_clones/repository_name/.git</p>
<p>Now you need to manually update Git repository changesets in RedMine:</p>
<pre>cd ~/mydomain.com
script/runner "Repository.fetch_changesets" -e production</pre>
<p>And set a hook to your repository to do this every time repository is updated &#8211; edit ~/git_project_clones/repository_name/.git/hooks/post-update file and add the following command ther:</p>
<pre>cd /home/redmine_user/mydomain.com &amp;&amp; script/runner "Repository.fetch_changesets" -e production</pre>
<p>When writing this blogpost I found a lot of useful information on Dreamhost own wiki as well on these blog posts:<br />
<a href="http://www.wavethenavel.com/2008/09/08/bootstrapping-a-dreamhost-account-for-rails-and-git/" target="_blank"> http://www.wavethenavel.com/2008/09/08/bootstrapping-a-dreamhost-account-for-rails-and-git/</a><br />
<a href="http://juliobiason.net/2008/05/19/git-repositories-on-dreamhost-via-ssh/" target="_blank"> http://juliobiason.net/2008/05/19/git-repositories-on-dreamhost-via-ssh/</a><br />
<a href="http://www.simonecarletti.com/blog/2009/07/configuring-git-repository-with-redmine/" target="_blank"> http://www.simonecarletti.com/blog/2009/07/configuring-git-repository-with-redmine/</a></p>
<a class="a2a_dd addtoany_share_save" href="http://www.addtoany.com/share_save?linkurl=http%3A%2F%2Fwww.ivankuznetsov.com%2F2009%2F07%2Fsetting-up-ruby-rails-git-and-redmine-on-dreamhost.html&amp;linkname=Setting%20up%20Ruby%2C%20Rails%2C%20Git%20and%20Redmine%20on%20Dreamhost"><img src="http://www.ivankuznetsov.com/wp-content/plugins/add-to-any/share_save_171_16.png" width="171" height="16" alt="Share/Bookmark"/></a>]]></content:encoded>
			<wfw:commentRss>http://www.ivankuznetsov.com/2009/07/setting-up-ruby-rails-git-and-redmine-on-dreamhost.html/feed</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
	</channel>
</rss>
