<?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 =&#62; :hq } &#187; Debian</title>
	<atom:link href="http://ivanhq.net/category/debian/feed/" rel="self" type="application/rss+xml" />
	<link>http://ivanhq.net</link>
	<description>Unix, tecnología y algunas cosas sobre mí</description>
	<lastBuildDate>Sat, 18 Feb 2012 01:48:33 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3</generator>
		<item>
		<title>Set up a full development server for a Ruby on Rails project</title>
		<link>http://ivanhq.net/2010/09/08/set-up-a-full-development-server-for-a-ruby-on-rails-project/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=set-up-a-full-development-server-for-a-ruby-on-rails-project</link>
		<comments>http://ivanhq.net/2010/09/08/set-up-a-full-development-server-for-a-ruby-on-rails-project/#comments</comments>
		<pubDate>Wed, 08 Sep 2010 13:19:03 +0000</pubDate>
		<dc:creator>ivan</dc:creator>
				<category><![CDATA[Debian]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[Programación]]></category>
		<category><![CDATA[Ruby on Rails]]></category>

		<guid isPermaLink="false">http://ivanhq.net/?p=474</guid>
		<description><![CDATA[Those who know me also know that one thing I&#8217;m specially concerned about is the importance of writing good documentation on everything you do. Specially for technical projects. Maybe it is not important for coders or designers, but for a sysadmin I think it should be definilety mandatory. If you get cool things working together [...]]]></description>
			<content:encoded><![CDATA[<p>Those who know me also know that one thing I&#8217;m specially concerned about is the importance of writing good documentation on everything you do. Specially for technical projects. Maybe it is not important for coders or designers, but for a sysadmin I think it should be definilety mandatory. If you get cool things working together but you don&#8217;t write any documentation, you won&#8217;t be able to play that music again.</p>
<p>Also, I am working in Ruby on Rails development since about 2 years ago. One of the things I have to do usually is to set up servers for hosting projects. And sometimes I have to set up a server for project development and tracking. These are the steps you can follow to set up a Ruby on Rails based server for development tracking.</p>
<p><b>1. Get a server</b></p>
<p>There are plenty of choices around the internet, some of them come completelly installed and prepared for deploying your app. They usually work the same way traditional LAMP hostings used to do, but using ssh key authentication instead of FTP sessions&#8230; some of them have also  web based backend panels for deploying, migrating and managing your app gems. </p>
<p>I prefer to set up an empty GNU/Linux vanilla server, so that I can host everything I need, my way, no worries if PHP, Ruby or whatever. I can set up a relay mailserver, netfilter routing, traffic shaping, services for monitoring and differential backups that I can periodically rsync to my office local server. This is the way a sysadmin thinks, something that coders not always understand.</p>
<p>If you want to set up a development server I recomment you to take a look at most basic <a href="http://linode.com">Linode VPS</a>. Their control panel will let you run and destroy any Linux distro, setup and resize partitions, add failover addresses, disk space, processor and memory. And of course you&#8217;ll have full SSH root access. So I find it very useful and flexible for my needs.</p>
<p>Some considerations:</p>
<ul>
<li>You&#8217;ll have to <b>set up a DNS name for the server IP</b>, i.e: <b>http://devel.somedomain.net</b></li>
<li>You&#8217;ll need root access on the server. I&#8217;ll suppose you are working on a local computer, remotely logged via SSH to your server</li>
<li>I usually build my servers using Debian (<i>Lenny</i> for now), but a basic knowledge of any other distro package system will let you adapt my guide to your preferred system</li>
<li>I&#8217;ll suppose you&#8217;ve set up a specific environment for running your app on the development server (I usually call it <i>beta</i>)</li>
</ul>
<p><b>2. Install screen</b></p>
<p>You may partially lose your work if for any reason your local computer hangs during the process. So it&#8217;s recommendable to install and use screen for working on a detachable console terminal. This way, if your computer shuts down, you&#8217;ll be able to boot again, ssh into your server and recover your screen session.</p>
<div class="codecolorer-container bash blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #c20cb9; font-weight: bold;">apt-get install</span> <span style="color: #c20cb9; font-weight: bold;">screen</span></div></div>
<p>You&#8217;ll maybe want to set up your screen sessions to look nicer than withe on black, and give you some additional information of the remote system. I use a copy of the screenrc configuration file from my friend <a href="http://userlinux.net">r0sk</a>, it&#8217;s simple and nice and works sweet.</p>
<div class="codecolorer-container bash blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #c20cb9; font-weight: bold;">wget</span> <span style="color: #660033;">-c</span> http:<span style="color: #000000; font-weight: bold;">//</span>ivanhq.net<span style="color: #000000; font-weight: bold;">/</span>stuff<span style="color: #000000; font-weight: bold;">/</span>_screenrc<br />
<span style="color: #c20cb9; font-weight: bold;">mv</span> _screenrc ~<span style="color: #000000; font-weight: bold;">/</span>.screenrc</div></div>
<p>Enter screen</p>
<div class="codecolorer-container bash blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #c20cb9; font-weight: bold;">screen</span></div></div>
<p><b>3. Base system</b></p>
<p>You&#8217;ll need an unprivileged user to host your web apps. I usually create a <i>web</i> user</p>
<div class="codecolorer-container bash blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #c20cb9; font-weight: bold;">mkdir</span> <span style="color: #000000; font-weight: bold;">/</span>home<span style="color: #000000; font-weight: bold;">/</span>web<br />
groupadd service<br />
useradd <span style="color: #660033;">-d</span> <span style="color: #000000; font-weight: bold;">/</span>home<span style="color: #000000; font-weight: bold;">/</span>web <span style="color: #660033;">-s</span> <span style="color: #000000; font-weight: bold;">/</span>bin<span style="color: #000000; font-weight: bold;">/</span><span style="color: #c20cb9; font-weight: bold;">bash</span> <span style="color: #660033;">-g</span> service web<br />
<span style="color: #c20cb9; font-weight: bold;">chown</span> <span style="color: #660033;">-R</span> web:service <span style="color: #000000; font-weight: bold;">/</span>home<span style="color: #000000; font-weight: bold;">/</span>web<span style="color: #000000; font-weight: bold;">/</span><br />
<span style="color: #c20cb9; font-weight: bold;">passwd</span> web &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #666666; font-style: italic;"># type your preferred password here</span></div></div>
<p>Add <i>contrib</i> and <i>non-free</i> repositories to your Apt sources file (<b>vim /etc/apt/sources.list</b>)</p>
<div class="codecolorer-container bash blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">deb http:<span style="color: #000000; font-weight: bold;">//</span>ftp.us.debian.org<span style="color: #000000; font-weight: bold;">/</span>debian lenny main contrib non-free<br />
deb-src http:<span style="color: #000000; font-weight: bold;">//</span>ftp.us.debian.org<span style="color: #000000; font-weight: bold;">/</span>debian lenny main contrib non-free</div></div>
<p>Update your sources and then your system</p>
<div class="codecolorer-container bash blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #c20cb9; font-weight: bold;">apt-get update</span><br />
<span style="color: #c20cb9; font-weight: bold;">apt-get upgrade</span></div></div>
<p>Edit your SSH server config file to disallow root login and enable SSH key authentication (<b>vim /etc/ssh/sshd_config</b>)</p>
<div class="codecolorer-container bash blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #666666; font-style: italic;"># change next line, swap &quot;yes&quot; for &quot;no&quot;</span><br />
PermitRootLogin no<br />
&nbsp;<br />
<span style="color: #666666; font-style: italic;"># uncomment next line</span><br />
AuthorizedKeysFile &nbsp; &nbsp; &nbsp;<span style="color: #000000; font-weight: bold;">%</span>h<span style="color: #000000; font-weight: bold;">/</span>.ssh<span style="color: #000000; font-weight: bold;">/</span>authorized_keys</div></div>
<p>Restart your SSH service</p>
<div class="codecolorer-container bash blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>init.d<span style="color: #000000; font-weight: bold;">/</span><span style="color: #c20cb9; font-weight: bold;">ssh</span> restart</div></div>
<p>Install build-essentials for compiling and installing the environment dependencies</p>
<div class="codecolorer-container bash blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #c20cb9; font-weight: bold;">apt-get install</span> build-essential</div></div>
<p>Install Postfix for using as MTA relay server, or MySQL Debian packages will install Exim (which I don&#8217;t really like)</p>
<div class="codecolorer-container bash blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #c20cb9; font-weight: bold;">apt-get install</span> postfix<br />
<br />
<span style="color: #666666; font-style: italic;"># select: internet site</span><br />
<span style="color: #666666; font-style: italic;"># MTA's outgoing domain name: somedomain.net</span></div></div>
<p><b>4. Backports</b></p>
<p>Because of some software versions being old and deprecated on the APT sources, and some other not being present, an alternative repository can be set up for installing newer versions. The backports repository.</p>
<div class="codecolorer-container bash blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #c20cb9; font-weight: bold;">wget</span> <span style="color: #660033;">-O</span> - http:<span style="color: #000000; font-weight: bold;">//</span>backports.org<span style="color: #000000; font-weight: bold;">/</span>debian<span style="color: #000000; font-weight: bold;">/</span>archive.key <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">apt-key add</span> -</div></div>
<p>Edit your APT sources file (<b>vim /etc/apt/sources.list</b>)</p>
<div class="codecolorer-container bash blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">deb http:<span style="color: #000000; font-weight: bold;">//</span>www.backports.org<span style="color: #000000; font-weight: bold;">/</span>debian lenny-backports main contrib non-free</div></div>
<p>Update your system again</p>
<div class="codecolorer-container bash blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #c20cb9; font-weight: bold;">apt-get update</span></div></div>
<p><b>5. MySQL</b></p>
<p>Install <b>mysql</b> service, and its ruby bindings package</p>
<div class="codecolorer-container bash blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #c20cb9; font-weight: bold;">apt-get install</span> mysql-server mysql-client libmysqlclient15-dev libmysql-ruby</div></div>
<p>Create a database for your project (<b>mysql -uroot -p</b>)</p>
<div class="codecolorer-container bash blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">mysql<span style="color: #000000; font-weight: bold;">&gt;</span> CREATE DATABASE yourapp_beta;<br />
mysql<span style="color: #000000; font-weight: bold;">&gt;</span> GRANT ALL PRIVILEGES ON yourapp_beta.<span style="color: #000000; font-weight: bold;">*</span> TO yourapp_username<span style="color: #000000; font-weight: bold;">@</span>localhost IDENTIFIED BY <span style="color: #ff0000;">'your_superhacker_password123'</span>;</div></div>
<p><b>6. Ruby, Rubygems and Rails</b></p>
<p>Install the Ruby stuff, I prefer to use backports at this point to ensure latest versions.</p>
<div class="codecolorer-container bash blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #c20cb9; font-weight: bold;">apt-get</span> <span style="color: #660033;">-t</span> lenny-backports <span style="color: #c20cb9; font-weight: bold;">install</span> ruby1.8-dev ruby1.8 ri1.8 rdoc1.8 irb1.8 libreadline-ruby1.8 libruby1.8 libopenssl-ruby</div></div>
<p>Add unversioned links for the newly created binaries</p>
<div class="codecolorer-container bash blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #c20cb9; font-weight: bold;">ln</span> <span style="color: #660033;">-s</span> <span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>bin<span style="color: #000000; font-weight: bold;">/</span>ruby1.8 <span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>local<span style="color: #000000; font-weight: bold;">/</span>bin<span style="color: #000000; font-weight: bold;">/</span>ruby<br />
<span style="color: #c20cb9; font-weight: bold;">ln</span> <span style="color: #660033;">-s</span> <span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>bin<span style="color: #000000; font-weight: bold;">/</span>ri1.8 <span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>local<span style="color: #000000; font-weight: bold;">/</span>bin<span style="color: #000000; font-weight: bold;">/</span>ri<br />
<span style="color: #c20cb9; font-weight: bold;">ln</span> <span style="color: #660033;">-s</span> <span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>bin<span style="color: #000000; font-weight: bold;">/</span>rdoc1.8 <span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>local<span style="color: #000000; font-weight: bold;">/</span>bin<span style="color: #000000; font-weight: bold;">/</span>rdoc<br />
<span style="color: #c20cb9; font-weight: bold;">ln</span> <span style="color: #660033;">-s</span> <span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>bin<span style="color: #000000; font-weight: bold;">/</span>irb1.8 <span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>local<span style="color: #000000; font-weight: bold;">/</span>bin<span style="color: #000000; font-weight: bold;">/</span>irb<br />
<span style="color: #c20cb9; font-weight: bold;">ln</span> <span style="color: #660033;">-s</span> <span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>bin<span style="color: #000000; font-weight: bold;">/</span>gem <span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>local<span style="color: #000000; font-weight: bold;">/</span>bin<span style="color: #000000; font-weight: bold;">/</span>gem</div></div>
<p>Install Rubygems from source, so you can update it directly whenever you want. Otherwise the system will update it for you, only when new packages for your distro are available.</p>
<div class="codecolorer-container bash blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #7a0874; font-weight: bold;">cd</span> <span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>local<span style="color: #000000; font-weight: bold;">/</span>src<br />
<span style="color: #c20cb9; font-weight: bold;">wget</span> <span style="color: #660033;">-c</span> http:<span style="color: #000000; font-weight: bold;">//</span>production.cf.rubygems.org<span style="color: #000000; font-weight: bold;">/</span>rubygems<span style="color: #000000; font-weight: bold;">/</span>rubygems-1.3.7.tgz<br />
<span style="color: #c20cb9; font-weight: bold;">tar</span> zxvfp rubygems-1.3.7.tgz<br />
<span style="color: #7a0874; font-weight: bold;">cd</span> rubygems-1.3.7<br />
ruby setup.rb</div></div>
<p>Link <i>gem</i> binary to an unversioned name</p>
<div class="codecolorer-container bash blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #c20cb9; font-weight: bold;">ln</span> <span style="color: #660033;">-s</span> <span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>bin<span style="color: #000000; font-weight: bold;">/</span>gem1.8 <span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>bin<span style="color: #000000; font-weight: bold;">/</span>gem</div></div>
<p>Update rubygems (not really needed, but just in case)</p>
<div class="codecolorer-container bash blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">gem update<br />
gem update <span style="color: #660033;">--system</span></div></div>
<p>Install Rails</p>
<div class="codecolorer-container bash blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">gem <span style="color: #c20cb9; font-weight: bold;">install</span> rails</div></div>
<p><b>7. Image processing</b></p>
<p>Youll surelly want a plugin for cropping and thumbnailing images, maybe <i>attachment_fu</i> or <i>paperclip</i>. They both can work with Imagemagick.</p>
<div class="codecolorer-container bash blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #c20cb9; font-weight: bold;">apt-get install</span> imagemagick</div></div>
<p><b>8. Apache</b></p>
<p>There are different web server layouts for hosting your application. Some people likes Nginx+Mongrel, some other prefer Apache+Passenger, others prefer Nginx+Passenger&#8230; I love Apache. Maybe because its syntax simplicity, its flexibility or maybe simply because as a sysadmin I&#8217;ve been working for years with it.</p>
<p>Install Apache</p>
<div class="codecolorer-container bash blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #c20cb9; font-weight: bold;">apt-get install</span> apache2.2-common apache2-mpm-prefork apache2-prefork-dev libssl-dev</div></div>
<p>Rename default virtualhost</p>
<div class="codecolorer-container bash blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">a2dissite default<br />
<span style="color: #c20cb9; font-weight: bold;">mv</span> <span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>apache2<span style="color: #000000; font-weight: bold;">/</span>sites-available<span style="color: #000000; font-weight: bold;">/</span>default <span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>apache2<span style="color: #000000; font-weight: bold;">/</span>sites-available<span style="color: #000000; font-weight: bold;">/</span>devel_somedomain_net</div></div>
<p>Edit that virtualhost (<b>vim /etc/apache2/sites-available/devel_somedomain_net</b>)and configure it with the minimum options to work. I&#8217;m adding a basic HTTP authentication so only people you give the password can see your project (it&#8217;s a development server heheh).</p>
<div class="codecolorer-container bash blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #000000; font-weight: bold;">&lt;</span>VirtualHost <span style="color: #000000; font-weight: bold;">*</span>:<span style="color: #000000;">80</span><span style="color: #000000; font-weight: bold;">&gt;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; ServerName devel.somedomain.net<br />
&nbsp; &nbsp; &nbsp; &nbsp; RailsEnv beta<br />
&nbsp; &nbsp; &nbsp; &nbsp; DocumentRoot <span style="color: #000000; font-weight: bold;">/</span>home<span style="color: #000000; font-weight: bold;">/</span>web<span style="color: #000000; font-weight: bold;">/</span>sites<span style="color: #000000; font-weight: bold;">/</span>devel.somedomain.net<span style="color: #000000; font-weight: bold;">/</span>current<span style="color: #000000; font-weight: bold;">/</span>public<br />
&nbsp;<br />
&nbsp; &nbsp; &nbsp; &nbsp; CustomLog <span style="color: #000000; font-weight: bold;">/</span>var<span style="color: #000000; font-weight: bold;">/</span>log<span style="color: #000000; font-weight: bold;">/</span>apache2<span style="color: #000000; font-weight: bold;">/</span>devel_somedomain_net<span style="color: #000000; font-weight: bold;">/</span>access.log combined<br />
&nbsp; &nbsp; &nbsp; &nbsp; ErrorLog <span style="color: #000000; font-weight: bold;">/</span>var<span style="color: #000000; font-weight: bold;">/</span>log<span style="color: #000000; font-weight: bold;">/</span>apache2<span style="color: #000000; font-weight: bold;">/</span>devel_somedomain_net<span style="color: #000000; font-weight: bold;">/</span>error.log<br />
&nbsp;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">&lt;</span>Directory <span style="color: #000000; font-weight: bold;">/</span>home<span style="color: #000000; font-weight: bold;">/</span>web<span style="color: #000000; font-weight: bold;">/</span>sites<span style="color: #000000; font-weight: bold;">/</span>devel_somedomain_net<span style="color: #000000; font-weight: bold;">&gt;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; AuthType Basic<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; AuthName <span style="color: #ff0000;">&quot;Members Only&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; AuthUserFile <span style="color: #000000; font-weight: bold;">/</span>home<span style="color: #000000; font-weight: bold;">/</span>web<span style="color: #000000; font-weight: bold;">/</span>sites<span style="color: #000000; font-weight: bold;">/</span>.htpasswd_devel_somedomain_net<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">&lt;</span>limit GET PUT POST<span style="color: #000000; font-weight: bold;">&gt;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; require valid-user<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">&lt;/</span>limit<span style="color: #000000; font-weight: bold;">&gt;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">&lt;/</span>Directory<span style="color: #000000; font-weight: bold;">&gt;</span><br />
<span style="color: #000000; font-weight: bold;">&lt;/</span>VirtualHost<span style="color: #000000; font-weight: bold;">&gt;</span></div></div>
<p>Enable your new virtualhost</p>
<div class="codecolorer-container bash blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">a2ensite devel_somedomain_net</div></div>
<p>As the unprivileged user running the service, create the application directory and the HTTP Auth passwords file</p>
<div class="codecolorer-container bash blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #c20cb9; font-weight: bold;">su</span> - web<br />
<span style="color: #c20cb9; font-weight: bold;">mkdir</span> <span style="color: #660033;">-p</span> <span style="color: #000000; font-weight: bold;">/</span>home<span style="color: #000000; font-weight: bold;">/</span>web<span style="color: #000000; font-weight: bold;">/</span>sites<span style="color: #000000; font-weight: bold;">/</span>devel.somedomain.net<br />
&nbsp;<br />
htpasswd <span style="color: #660033;">-c</span> <span style="color: #000000; font-weight: bold;">/</span>home<span style="color: #000000; font-weight: bold;">/</span>web<span style="color: #000000; font-weight: bold;">/</span>sites<span style="color: #000000; font-weight: bold;">/</span>.htpasswd_devel_somedomain_net username1<br />
htpasswd <span style="color: #000000; font-weight: bold;">/</span>home<span style="color: #000000; font-weight: bold;">/</span>web<span style="color: #000000; font-weight: bold;">/</span>sites<span style="color: #000000; font-weight: bold;">/</span>.htpasswd_devel_somedomain_net username2<br />
....<br />
<br />
<span style="color: #7a0874; font-weight: bold;">exit</span></div></div>
<p>Create the apache log directory for your app</p>
<div class="codecolorer-container bash blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #c20cb9; font-weight: bold;">mkdir</span> <span style="color: #660033;">-p</span> <span style="color: #000000; font-weight: bold;">/</span>var<span style="color: #000000; font-weight: bold;">/</span>log<span style="color: #000000; font-weight: bold;">/</span>apache2<span style="color: #000000; font-weight: bold;">/</span>devel_somedomain_net</div></div>
<p>Install Passenger</p>
<div class="codecolorer-container bash blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">gem <span style="color: #c20cb9; font-weight: bold;">install</span> passenger<br />
passenger-install-apache2-module</div></div>
<p>Create a file for loading passenger module into Apache (<b>vim /etc/apache2/mods-available/passenger.load</b>). Be careful with versions on the names as they may have changed.</p>
<div class="codecolorer-container bash blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">LoadModule passenger_module <span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>lib<span style="color: #000000; font-weight: bold;">/</span>ruby<span style="color: #000000; font-weight: bold;">/</span>gems<span style="color: #000000; font-weight: bold;">/</span><span style="color: #000000;">1.8</span><span style="color: #000000; font-weight: bold;">/</span>gems<span style="color: #000000; font-weight: bold;">/</span>passenger-2.2.15<span style="color: #000000; font-weight: bold;">/</span>ext<span style="color: #000000; font-weight: bold;">/</span>apache2<span style="color: #000000; font-weight: bold;">/</span>mod_passenger.so<br />
PassengerRoot <span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>lib<span style="color: #000000; font-weight: bold;">/</span>ruby<span style="color: #000000; font-weight: bold;">/</span>gems<span style="color: #000000; font-weight: bold;">/</span><span style="color: #000000;">1.8</span><span style="color: #000000; font-weight: bold;">/</span>gems<span style="color: #000000; font-weight: bold;">/</span>passenger-2.2.15<br />
PassengerRuby <span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>bin<span style="color: #000000; font-weight: bold;">/</span>ruby1.8</div></div>
<p>Enable passenger module</p>
<div class="codecolorer-container bash blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">a2enmod passenger</div></div>
<p>Change the user and group executing Apache service to match your unprivileged user (<b>vim /etc/apache2/envvars</b>)</p>
<div class="codecolorer-container bash blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #666666; font-style: italic;">#export APACHE_RUN_USER=www-data</span><br />
<span style="color: #666666; font-style: italic;">#export APACHE_RUN_GROUP=www-data</span><br />
<span style="color: #7a0874; font-weight: bold;">export</span> <span style="color: #007800;">APACHE_RUN_USER</span>=web<br />
<span style="color: #7a0874; font-weight: bold;">export</span> <span style="color: #007800;">APACHE_RUN_GROUP</span>=service</div></div>
<p>Restart Apache</p>
<div class="codecolorer-container bash blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>init.d<span style="color: #000000; font-weight: bold;">/</span>apache2 restart</div></div>
<p><b>9. Git and Gitosis</b></p>
<p>If you don&#8217;t want to pay a Github account and you don&#8217;t want your source to be visible to everyone, you&#8217;ll want to host your own Git server. There are different choices for that, but I like Gitosis because it&#8217;s simple and I can manage it from my command line, only editing a config file.</p>
<p>Install Git</p>
<div class="codecolorer-container bash blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #c20cb9; font-weight: bold;">apt-get</span> <span style="color: #660033;">-t</span> lenny-backports <span style="color: #c20cb9; font-weight: bold;">install</span> git-arch</div></div>
<p>Gitosis is written in Python, so you need to install python&#8217;s setup-tools in order to install Gitosis</p>
<div class="codecolorer-container bash blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #c20cb9; font-weight: bold;">apt-get install</span> python-setuptools</div></div>
<p>Clone and install Gitosis</p>
<div class="codecolorer-container bash blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #7a0874; font-weight: bold;">cd</span> <span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>local<span style="color: #000000; font-weight: bold;">/</span>src<br />
<span style="color: #c20cb9; font-weight: bold;">git clone</span> git:<span style="color: #000000; font-weight: bold;">//</span>eagain.net<span style="color: #000000; font-weight: bold;">/</span>gitosis.git<br />
<span style="color: #7a0874; font-weight: bold;">cd</span> gitosis<br />
python setup.py <span style="color: #c20cb9; font-weight: bold;">install</span></div></div>
<p>Create a new unprivileged user for hosting Gitosis and its repositories. It does not need a password (so it can&#8217;t log in) but it needs a shell as all management occours using an SSH session.</p>
<div class="codecolorer-container bash blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">adduser \<br />
<span style="color: #660033;">--system</span> \<br />
<span style="color: #660033;">--shell</span> <span style="color: #000000; font-weight: bold;">/</span>bin<span style="color: #000000; font-weight: bold;">/</span><span style="color: #c20cb9; font-weight: bold;">sh</span> \<br />
<span style="color: #660033;">--gecos</span> <span style="color: #ff0000;">'git version control'</span> \<br />
<span style="color: #660033;">--group</span> \<br />
<span style="color: #660033;">--disabled-password</span> \<br />
<span style="color: #660033;">--home</span> <span style="color: #000000; font-weight: bold;">/</span>home<span style="color: #000000; font-weight: bold;">/</span><span style="color: #c20cb9; font-weight: bold;">git</span> \<br />
<span style="color: #c20cb9; font-weight: bold;">git</span><br />
&nbsp;<br />
usermod <span style="color: #660033;">-g</span> service <span style="color: #c20cb9; font-weight: bold;">git</span></div></div>
<p>Upload your ssh public key to the server, leave it in /tmp/ and call it <b>user@host.pub</b> being <i>user@host</i> the final string specified into the file itself (<i>ivan@mbp-local</i>, or something similar)</p>
<p>Initialize Gitosis using the SSH key you just uploaded, which will be the Gitosis admin</p>
<div class="codecolorer-container bash blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #c20cb9; font-weight: bold;">su</span> - <span style="color: #c20cb9; font-weight: bold;">git</span><br />
gitosis-init <span style="color: #000000; font-weight: bold;">&lt;</span> <span style="color: #000000; font-weight: bold;">/</span>tmp<span style="color: #000000; font-weight: bold;">/</span>ivan\<span style="color: #000000; font-weight: bold;">@</span>ibelmonte-mbp.local.pub</div></div>
<p><b>In your local computer</b> clone the Gitosis repository so you can manage it from now on</p>
<div class="codecolorer-container bash blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #c20cb9; font-weight: bold;">git clone</span> <span style="color: #c20cb9; font-weight: bold;">git</span><span style="color: #000000; font-weight: bold;">@</span>devel.somedomain.net:gitosis-admin.git</div></div>
<p>Enter the </i>gitosis-admin</i> directory and check the contents. It has to show a filename called <i>gitosis.conf</i> and a directory called <i>keydir</i>.</p>
<p><b>10. Add a repository for your app</b></p>
<p>Edit the Gitosis config (<b>vim gitosis.conf</b>) and add a new group, formed with one user (or more, separated with spaces), and its repository</p>
<div class="codecolorer-container bash blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #7a0874; font-weight: bold;">&#91;</span>group your_app_name<span style="color: #7a0874; font-weight: bold;">&#93;</span><br />
members = user1<span style="color: #000000; font-weight: bold;">@</span>host1 user2<span style="color: #000000; font-weight: bold;">@</span>host2 ...<br />
writable = your_repo_name</div></div>
<p>Make sure to put user&#8217;s keyfiles into the <i>keydir</i> directory, following the previously mentioned format. Upload your changes.</p>
<div class="codecolorer-container bash blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #c20cb9; font-weight: bold;">git add</span> .<br />
<span style="color: #c20cb9; font-weight: bold;">git commit</span> <span style="color: #660033;">-a</span> <span style="color: #660033;">-m</span> <span style="color: #ff0000;">&quot;Added user2 to your_app group&quot;</span><br />
<span style="color: #c20cb9; font-weight: bold;">git push</span></div></div>
<p><b>In your local computer</b> you can now create an application and add its files to the repo</p>
<div class="codecolorer-container bash blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">rails your_app<br />
<span style="color: #7a0874; font-weight: bold;">cd</span> your_app<br />
<span style="color: #c20cb9; font-weight: bold;">git init</span><br />
<span style="color: #c20cb9; font-weight: bold;">git remote</span> add origin <span style="color: #c20cb9; font-weight: bold;">git</span><span style="color: #000000; font-weight: bold;">@</span>devel.somedomain.net:your_app.git<br />
<span style="color: #c20cb9; font-weight: bold;">git add</span> .<br />
<span style="color: #c20cb9; font-weight: bold;">git commit</span> <span style="color: #660033;">-a</span> <span style="color: #660033;">-m</span> <span style="color: #ff0000;">&quot;Initial import&quot;</span><br />
<span style="color: #c20cb9; font-weight: bold;">git push</span> origin master:refs<span style="color: #000000; font-weight: bold;">/</span>heads<span style="color: #000000; font-weight: bold;">/</span>master</div></div>
<p><b>11. Capistrano</b></p>
<p>You&#8217;ll want to deploy your software to your newly configured server. Capistrano is the best choice I know, since it creates versioned directories to let you roll back and forth, remotely run tasks on the hosted version of your app, place a custom &#8220;under maintenance&#8221; page, etc&#8230;</p>
<p>Install Capistrano</p>
<div class="codecolorer-container bash blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">gem <span style="color: #c20cb9; font-weight: bold;">install</span> capistrano</div></div>
<p>Capify your application</p>
<div class="codecolorer-container bash blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #7a0874; font-weight: bold;">cd</span> <span style="color: #000000; font-weight: bold;">/</span>path<span style="color: #000000; font-weight: bold;">/</span>to<span style="color: #000000; font-weight: bold;">/</span>your<span style="color: #000000; font-weight: bold;">/</span>app<br />
capify .</div></div>
<p>Create a recipe (<b>vim config/deploy.rb</b>)</p>
<div class="codecolorer-container ruby blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="ruby codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color:#008000; font-style:italic;"># set a target name, so you can also use it to deploy to a production server</span><br />
<br />
<span style="color:#008000; font-style:italic;"># set :targetname, 'www'</span><br />
set <span style="color:#ff3333; font-weight:bold;">:targetname</span>, <span style="color:#996600;">'devel'</span><br />
&nbsp;<br />
<span style="color:#9966CC; font-weight:bold;">if</span> targetname == <span style="color:#996600;">'devel'</span><br />
&nbsp; set <span style="color:#ff3333; font-weight:bold;">:rails_env</span>, <span style="color:#996600;">'beta'</span><br />
<span style="color:#9966CC; font-weight:bold;">end</span><br />
&nbsp;<br />
set <span style="color:#ff3333; font-weight:bold;">:application</span>, <span style="color:#996600;">&quot;#{targetname}.somedomain.net&quot;</span><br />
set <span style="color:#ff3333; font-weight:bold;">:deploy_to</span>, <span style="color:#996600;">&quot;/home/web/sites/#{application}&quot;</span><br />
set <span style="color:#ff3333; font-weight:bold;">:user</span>, <span style="color:#996600;">&quot;web&quot;</span><br />
set <span style="color:#ff3333; font-weight:bold;">:runner</span>, <span style="color:#996600;">&quot;web&quot;</span><br />
set <span style="color:#ff3333; font-weight:bold;">:repository</span>, <span style="color:#996600;">&quot;git@devel.somedomain.net:your_app.git&quot;</span><br />
set <span style="color:#ff3333; font-weight:bold;">:deploy_via</span>, <span style="color:#ff3333; font-weight:bold;">:remote_cache</span><br />
set <span style="color:#ff3333; font-weight:bold;">:copy_exclude</span>, <span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#996600;">&quot;.git&quot;</span>, <span style="color:#996600;">&quot;.gitignore&quot;</span><span style="color:#006600; font-weight:bold;">&#93;</span><br />
set <span style="color:#ff3333; font-weight:bold;">:scm</span>, <span style="color:#ff3333; font-weight:bold;">:git</span><br />
set <span style="color:#ff3333; font-weight:bold;">:use_sudo</span>, <span style="color:#0000FF; font-weight:bold;">false</span><br />
&nbsp;<br />
<span style="color:#008000; font-style:italic;"># Master branch of course. If not, change</span><br />
<span style="color:#008000; font-style:italic;">#</span><br />
<span style="color:#008000; font-style:italic;"># set :branch, master</span><br />
&nbsp;<br />
ssh_options<span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#ff3333; font-weight:bold;">:forward_agent</span><span style="color:#006600; font-weight:bold;">&#93;</span> = <span style="color:#0000FF; font-weight:bold;">true</span><br />
&nbsp;<br />
role <span style="color:#ff3333; font-weight:bold;">:app</span>, <span style="color:#996600;">&quot;#{targetname}.somedomain.net&quot;</span><br />
role <span style="color:#ff3333; font-weight:bold;">:web</span>, <span style="color:#996600;">&quot;#{targetname}.somedomain.net&quot;</span><br />
role <span style="color:#ff3333; font-weight:bold;">:db</span>, &nbsp;<span style="color:#996600;">&quot;#{targetname}.somedomain.net&quot;</span>, <span style="color:#ff3333; font-weight:bold;">:primary</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#0000FF; font-weight:bold;">true</span><br />
&nbsp;<br />
namespace <span style="color:#ff3333; font-weight:bold;">:deploy</span> <span style="color:#9966CC; font-weight:bold;">do</span><br />
&nbsp; desc <span style="color:#996600;">&quot;Restarting passenger with restart.txt&quot;</span><br />
&nbsp; task <span style="color:#ff3333; font-weight:bold;">:restart</span>, <span style="color:#ff3333; font-weight:bold;">:roles</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#ff3333; font-weight:bold;">:app</span>, <span style="color:#ff3333; font-weight:bold;">:except</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#006600; font-weight:bold;">&#123;</span> <span style="color:#ff3333; font-weight:bold;">:no_release</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#0000FF; font-weight:bold;">true</span> <span style="color:#006600; font-weight:bold;">&#125;</span> <span style="color:#9966CC; font-weight:bold;">do</span><br />
&nbsp; &nbsp; run <span style="color:#996600;">&quot;touch #{current_path}/tmp/restart.txt&quot;</span><br />
&nbsp; <span style="color:#9966CC; font-weight:bold;">end</span><br />
&nbsp;<br />
&nbsp; <span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#ff3333; font-weight:bold;">:start</span>, <span style="color:#ff3333; font-weight:bold;">:stop</span><span style="color:#006600; font-weight:bold;">&#93;</span>.<span style="color:#9900CC;">each</span> <span style="color:#9966CC; font-weight:bold;">do</span> <span style="color:#006600; font-weight:bold;">|</span>t<span style="color:#006600; font-weight:bold;">|</span><br />
&nbsp; &nbsp; desc <span style="color:#996600;">&quot;#{t} task is a no-op with mod_rails&quot;</span><br />
&nbsp; &nbsp; task t, <span style="color:#ff3333; font-weight:bold;">:roles</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#ff3333; font-weight:bold;">:app</span> <span style="color:#9966CC; font-weight:bold;">do</span> ; <span style="color:#9966CC; font-weight:bold;">end</span><br />
&nbsp; <span style="color:#9966CC; font-weight:bold;">end</span><br />
<span style="color:#9966CC; font-weight:bold;">end</span></div></div>
<p><b>12. SSH keys</b></p>
<p>In order to deploy your app without typing any password, you&#8217;ll have to set up a SSH key authentication between you and the unprivileged user of the server (<i>web</i> user).</p>
<p>Copy the content of your local ssh keyfile (commonly ~/.ssh/<i>id_rsa.pub</i>) and paste at the end of <b>/home/web/.ssh/authorized_keys</b> on the server. You&#8217;ll want to repeat this process for each developer so they can also deploy without typing a password.</p>
<p>You&#8217;ll also need to generate a SSH key for your <i>web</i> user on the server, and add it as a member of the repo in gitosis. Otherwise you won&#8217;t be able to deploy your app, because the server won&#8217;t let itself access to the repo for fetching.</p>
<p><b>13. Redmine</b></p>
<p>Redmine is one of those powerful tools that make your life easier when working with other developers, designers, webmasters and CEO&#8217;s&#8230; it helps you to keep tracking of issues, bugs, timings, files and documents, wikis and it also lets you graphically browse your repositories. If you&#8217;ve never tested it, now it&#8217;s your time.</p>
<p><b>NOTE:</b> you&#8217;ll need to create a new entry on your DNS server. Set up a CNAME called <i>redmine</i> pointing to <i>devel.somedomain.net</i></p>
<p>Redmine needs mod_rewrite support on Apache</p>
<div class="codecolorer-container bash blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">a2enmod rewrite</div></div>
<p>You&#8217;ll need subversion to checkout the source code of Redmine</p>
<div class="codecolorer-container bash blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #c20cb9; font-weight: bold;">apt-get install</span> subversion</div></div>
<p>Su to your unprivileged user</p>
<div class="codecolorer-container bash blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #c20cb9; font-weight: bold;">su</span> - web</div></div>
<p>Checkout the code</p>
<div class="codecolorer-container bash blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #7a0874; font-weight: bold;">cd</span> sites<br />
<span style="color: #c20cb9; font-weight: bold;">svn co</span> http:<span style="color: #000000; font-weight: bold;">//</span>redmine.rubyforge.org<span style="color: #000000; font-weight: bold;">/</span>svn<span style="color: #000000; font-weight: bold;">/</span>tags<span style="color: #000000; font-weight: bold;">/</span>1.0.1<span style="color: #000000; font-weight: bold;">/</span> redmine.somedomain.net<br />
<span style="color: #7a0874; font-weight: bold;">cd</span> redmine.somedomain.net</div></div>
<p>Create a database for redmine (<b>mysql -uroot -p</b>)</p>
<div class="codecolorer-container bash blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">mysql<span style="color: #000000; font-weight: bold;">&gt;</span> CREATE DATABASE redmine CHARACTER SET utf8;<br />
mysql<span style="color: #000000; font-weight: bold;">&gt;</span> GRANT ALL PRIVILEGES ON redmine.<span style="color: #000000; font-weight: bold;">*</span> TO redmine<span style="color: #000000; font-weight: bold;">@</span>localhost IDENTIFIED BY <span style="color: #ff0000;">'redmine123'</span>;</div></div>
<p>Edit Redmine&#8217;s database configuration file (<b>vim config/database.yml</b>)</p>
<div class="codecolorer-container ruby blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="ruby codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">production:<br />
&nbsp; adapter: mysql<br />
&nbsp; database: redmine<br />
&nbsp; host: localhost<br />
&nbsp; username: redmine<br />
&nbsp; password: redmine123<br />
&nbsp; encoding: utf8<br />
&nbsp; socket: <span style="color:#006600; font-weight:bold;">/</span>var<span style="color:#006600; font-weight:bold;">/</span>run<span style="color:#006600; font-weight:bold;">/</span>mysqld<span style="color:#006600; font-weight:bold;">/</span>mysqld.<span style="color:#9900CC;">sock</span></div></div>
<p>Place a secret key for Redmine cookies on its environment file, inside the <i>Initializer</i> block (<b>vim config/environment.rb</b>)</p>
<div class="codecolorer-container ruby blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="ruby codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">config.<span style="color:#9900CC;">action_controller</span>.<span style="color:#9900CC;">session</span> = <span style="color:#006600; font-weight:bold;">&#123;</span> <span style="color:#ff3333; font-weight:bold;">:key</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#996600;">&quot;_redmine_somedomain_com_session&quot;</span>, <span style="color:#ff3333; font-weight:bold;">:secret</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#996600;">&quot;578359e95c3f2sj9enw10amkd81508ff&quot;</span> <span style="color:#006600; font-weight:bold;">&#125;</span></div></div>
<p>Migrate the database</p>
<div class="codecolorer-container bash blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #c20cb9; font-weight: bold;">env</span> <span style="color: #007800;">RAILS_ENV</span>=production rake db:migrate</div></div>
<p>Edit the SMTP configuration for Redmine to be able to send notification emails (<b>vim config/email.yml</b>)</p>
<div class="codecolorer-container ruby blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="ruby codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">production:<br />
&nbsp; delivery_method: <span style="color:#ff3333; font-weight:bold;">:smtp</span><br />
&nbsp; smtp_settings:<br />
&nbsp; &nbsp; address: <span style="color:#996600;">&quot;smtp.somedomain.net&quot;</span><br />
&nbsp; &nbsp; port: <span style="color:#996600;">'25'</span><br />
&nbsp; &nbsp; domain: <span style="color:#996600;">&quot;somedomain.net&quot;</span><br />
&nbsp; &nbsp; authentication: <span style="color:#ff3333; font-weight:bold;">:login</span><br />
&nbsp; &nbsp; user_name: <span style="color:#996600;">&quot;your_username&quot;</span><br />
&nbsp; &nbsp; password: <span style="color:#996600;">&quot;your_password&quot;</span></div></div>
<p>If you want to relay over Gmail or your domain&#8217;s email is hosted on Google apps, you&#8217;ll need to install a tls authentication plugin</p>
<div class="codecolorer-container bash blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">ruby script<span style="color: #000000; font-weight: bold;">/</span>plugin <span style="color: #c20cb9; font-weight: bold;">install</span> git:<span style="color: #000000; font-weight: bold;">//</span>github.com<span style="color: #000000; font-weight: bold;">/</span>collectiveidea<span style="color: #000000; font-weight: bold;">/</span>action_mailer_optional_tls.git</div></div>
<p>Use this config for use with Gmail / Google apps</p>
<div class="codecolorer-container ruby blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="ruby codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">production:<br />
&nbsp; delivery_method: <span style="color:#ff3333; font-weight:bold;">:smtp</span><br />
&nbsp; smtp_settings:<br />
&nbsp; &nbsp; tls: <span style="color:#0000FF; font-weight:bold;">true</span><br />
&nbsp; &nbsp; address: <span style="color:#996600;">&quot;smtp.gmail.com&quot;</span><br />
&nbsp; &nbsp; port: <span style="color:#996600;">'587'</span><br />
&nbsp; &nbsp; domain: <span style="color:#996600;">&quot;gmail.com&quot;</span> &nbsp; <span style="color:#008000; font-style:italic;"># use &quot;somedomain.net&quot; in case of Google Apps</span><br />
&nbsp; &nbsp; authentication: <span style="color:#ff3333; font-weight:bold;">:plain</span><br />
&nbsp; &nbsp; user_name: <span style="color:#996600;">&quot;your_username&quot;</span><br />
&nbsp; &nbsp; password: <span style="color:#996600;">&quot;your_password&quot;</span></div></div>
<p>Exit su, and become root again</p>
<div class="codecolorer-container bash blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #7a0874; font-weight: bold;">exit</span></div></div>
<p>Create a new Apache virtualhost (<b>vim /etc/apache2/sites-available/redmine_somedomain_net</b>)</p>
<div class="codecolorer-container bash blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #000000; font-weight: bold;">&lt;</span>VirtualHost <span style="color: #000000; font-weight: bold;">*</span>:<span style="color: #000000;">80</span><span style="color: #000000; font-weight: bold;">&gt;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; ServerName redmine.somedomain.net<br />
&nbsp; &nbsp; &nbsp; &nbsp; RailsEnv production<br />
&nbsp; &nbsp; &nbsp; &nbsp; DocumentRoot <span style="color: #000000; font-weight: bold;">/</span>home<span style="color: #000000; font-weight: bold;">/</span>web<span style="color: #000000; font-weight: bold;">/</span>sites<span style="color: #000000; font-weight: bold;">/</span>redmine.somedomain.net<span style="color: #000000; font-weight: bold;">/</span>public<br />
&nbsp;<br />
&nbsp; &nbsp; &nbsp; &nbsp; CustomLog <span style="color: #000000; font-weight: bold;">/</span>var<span style="color: #000000; font-weight: bold;">/</span>log<span style="color: #000000; font-weight: bold;">/</span>apache2<span style="color: #000000; font-weight: bold;">/</span>redmine_somedomain_net<span style="color: #000000; font-weight: bold;">/</span>access.log combined<br />
&nbsp; &nbsp; &nbsp; &nbsp; ErrorLog <span style="color: #000000; font-weight: bold;">/</span>var<span style="color: #000000; font-weight: bold;">/</span>log<span style="color: #000000; font-weight: bold;">/</span>apache2<span style="color: #000000; font-weight: bold;">/</span>redmine_somedomain_net<span style="color: #000000; font-weight: bold;">/</span>error.log<br />
<span style="color: #000000; font-weight: bold;">&lt;/</span>VirtualHost<span style="color: #000000; font-weight: bold;">&gt;</span></div></div>
<p>Create an Apache log directory for redmine</p>
<div class="codecolorer-container bash blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #c20cb9; font-weight: bold;">mkdir</span> <span style="color: #000000; font-weight: bold;">/</span>var<span style="color: #000000; font-weight: bold;">/</span>log<span style="color: #000000; font-weight: bold;">/</span>apache2<span style="color: #000000; font-weight: bold;">/</span>redmine_somedomain_net<span style="color: #000000; font-weight: bold;">/</span></div></div>
<p>Enable your new virtualhost and restart Apache</p>
<div class="codecolorer-container bash blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">a2ensite redmine.somedomain.net<br />
<span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>init.d<span style="color: #000000; font-weight: bold;">/</span>apache2 restart</div></div>
<p><b>14. Start writing Ruby on Rails</b></p>
<p>Here comes the funny part. Enjoy! ;-)</p>
]]></content:encoded>
			<wfw:commentRss>http://ivanhq.net/2010/09/08/set-up-a-full-development-server-for-a-ruby-on-rails-project/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Project-open en Debian (update 1)</title>
		<link>http://ivanhq.net/2007/11/20/project-open-en-debian-update-1/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=project-open-en-debian-update-1</link>
		<comments>http://ivanhq.net/2007/11/20/project-open-en-debian-update-1/#comments</comments>
		<pubDate>Tue, 20 Nov 2007 19:45:46 +0000</pubDate>
		<dc:creator>ivan</dc:creator>
				<category><![CDATA[Debian]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[project-open]]></category>

		<guid isPermaLink="false">http://ivanhq.net/2007/11/20/project-open-en-debian-update-1/</guid>
		<description><![CDATA[He actualizado el mini tutorial de instalación de ]Project-open[ en Debian ETCH. Un chico llamado Martin Van Es me ha escrito explicando algunos trucos para hacer funcionar la versión 4 de Aolserver con la versión 8.x de PostgreSQL. Yo lo he probado y funciona perfectamente. Aquí está el tuto. Como siempre, espero que sea de [...]]]></description>
			<content:encoded><![CDATA[<p><a href='http://www.project-open.com'><img align='left' src='http://ivanhq.net/wp-content/uploads/2007/09/po-mini.jpg' alt='po-mini.jpg' /></a>He actualizado el mini tutorial de instalación de <a href="http://www.project-open.com">]Project-open[</a> en Debian ETCH. Un chico llamado <b>Martin Van Es</b> me ha escrito explicando algunos trucos para hacer funcionar la versión 4 de Aolserver con la versión 8.x de PostgreSQL. Yo lo he probado y funciona perfectamente.</p>
<p><a href="http://www.ivanhq.net/project-open-on-debian-etch/">Aquí está</a> el tuto. Como siempre, espero que sea de ayuda!</p>
<blockquote><p>
I have updated the mini-tutorial about installing <a href="http://www.project-open.com">]Project-open[</a> on Debian ETCH. A guy called <b>Martin Van Es</b> sent  me some emails with tips on making it work with Aolserver4 and PostgreSQL 8.1. I&#8217;ve tested it and works okay.</p>
<p><a href="http://www.ivanhq.net/project-open-on-debian-etch/">Here is</a> the tutorial. I hope it helps!<br />
</a></p>
</blockquote>
]]></content:encoded>
			<wfw:commentRss>http://ivanhq.net/2007/11/20/project-open-en-debian-update-1/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

