<?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; Linux</title>
	<atom:link href="http://ivanhq.net/category/linux/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>Pure-ftpd capabilities for OpenVZ hosts</title>
		<link>http://ivanhq.net/2011/03/24/pure-ftpd-capabilities-for-openvz-hosts/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=pure-ftpd-capabilities-for-openvz-hosts</link>
		<comments>http://ivanhq.net/2011/03/24/pure-ftpd-capabilities-for-openvz-hosts/#comments</comments>
		<pubDate>Thu, 24 Mar 2011 19:40:36 +0000</pubDate>
		<dc:creator>ivan</dc:creator>
				<category><![CDATA[Linux]]></category>

		<guid isPermaLink="false">http://ivanhq.net/?p=551</guid>
		<description><![CDATA[Trying to get pure-ftpd running on an OpenVZ virtual server and getting this message? [ERROR] Unable to switch capabilities : Operation not permitted Shut the VPS down, enter the host via SSH and enable needed capabilities for your VPS (where $VPS_ID is your VPS id, ie 101, 102&#8230;) for CAP in CHOWN DAC_READ_SEARCH SETGID SETUID [...]]]></description>
			<content:encoded><![CDATA[<p>Trying to get pure-ftpd running on an OpenVZ virtual server and getting this message?</p>
<pre>
[ERROR] Unable to switch capabilities : Operation not permitted
</pre>
<p>Shut the VPS down, enter the host via SSH and enable needed capabilities for your VPS (where $VPS_ID is your VPS id, ie 101, 102&#8230;)</p>
<pre>
for CAP in CHOWN DAC_READ_SEARCH SETGID SETUID NET_BIND_SERVICE NET_ADMIN SYS_CHROOT SYS_NICE CHOWN DAC_READ_SEARCH SETGID SETUID NET_BIND_SERVICE NET_ADMIN SYS_CHROOT SYS_NICE; do vzctl set $VPS_ID --capability ${CAP}:on --save; done
</pre>
<p>That&#8217;s it :-)</p>
]]></content:encoded>
			<wfw:commentRss>http://ivanhq.net/2011/03/24/pure-ftpd-capabilities-for-openvz-hosts/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<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>Recursive crop with Imagemagick</title>
		<link>http://ivanhq.net/2010/03/04/recursive-crop-with-imagemagick/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=recursive-crop-with-imagemagick</link>
		<comments>http://ivanhq.net/2010/03/04/recursive-crop-with-imagemagick/#comments</comments>
		<pubDate>Thu, 04 Mar 2010 01:12:47 +0000</pubDate>
		<dc:creator>ivan</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[scripts]]></category>

		<guid isPermaLink="false">http://ivanhq.net/?p=361</guid>
		<description><![CDATA[A very simple and tiny shellscript for cropping images recursively with Imagemagick on Linux. In my case I am working on a Ruby on Rails website, managing images and its thumbnails with attachment_fu. After some months I decided to convert all user stored thumbnails to a cropped format. This is what this script was for. [...]]]></description>
			<content:encoded><![CDATA[<p>A very simple and tiny shellscript for cropping images recursively with <a href="http://www.imagemagick.org">Imagemagick</a> on Linux. In my case I am working on a Ruby on Rails website, managing images and its thumbnails with <a href="http://github.com/technoweenie/attachment_fu">attachment_fu</a>. After some months I decided to convert all user stored thumbnails to a cropped format. This is what this script was for.</p>
<div class="codecolorer-container bash blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;height:500px;"><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;">#!/bin/bash</span><br />
<span style="color: #666666; font-style: italic;">#</span><br />
<span style="color: #666666; font-style: italic;"># very little and tiny shellscript for cropping images </span><br />
<span style="color: #666666; font-style: italic;"># massively and recursively with Linux and Imagemagick</span><br />
<span style="color: #666666; font-style: italic;"># Make sure you have Imagemagick installed (ie: try to </span><br />
<span style="color: #666666; font-style: italic;"># execute &quot;convert&quot; binary)</span><br />
<span style="color: #666666; font-style: italic;">#</span><br />
<span style="color: #666666; font-style: italic;"># USAGE: place this script in your images parent directory,</span><br />
<span style="color: #666666; font-style: italic;"># edit and change the size names and widths</span><br />
<span style="color: #666666; font-style: italic;">#</span><br />
<span style="color: #666666; font-style: italic;"># Ivan Belmonte &lt;ivan@ivanhq.net - http://ivanhq.net&gt;</span><br />
<br />
<span style="color: #007800;">SIZES</span>=<span style="color: #ff0000;">&quot;icon:48 thumb:120&quot;</span> <span style="color: #666666; font-style: italic;"># change them for your needs</span><br />
<span style="color: #007800;">FORMATS</span>=<span style="color: #ff0000;">&quot;jpg JPG jpeg JPEG gif GIF png PNG&quot;</span><br />
<br />
<br />
<span style="color: #666666; font-style: italic;"># remove previously sized files</span><br />
<span style="color: #000000; font-weight: bold;">for</span> SIZE <span style="color: #000000; font-weight: bold;">in</span> <span style="color: #800000;">${SIZES}</span>; <span style="color: #000000; font-weight: bold;">do</span><br />
&nbsp; <span style="color: #007800;">SIZENAME</span>=<span style="color: #000000; font-weight: bold;">`</span><span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #800000;">${SIZE}</span> <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">cut</span> <span style="color: #660033;">-f</span> <span style="color: #000000;">1</span> <span style="color: #660033;">-d</span> :<span style="color: #000000; font-weight: bold;">`</span><br />
&nbsp; <span style="color: #c20cb9; font-weight: bold;">find</span> . <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">grep</span> <span style="color: #660033;">-i</span> _<span style="color: #800000;">${SIZENAME}</span> <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">xargs</span> <span style="color: #c20cb9; font-weight: bold;">rm</span> <span style="color: #660033;">-f</span><br />
<span style="color: #000000; font-weight: bold;">done</span><br />
<br />
<br />
<span style="color: #666666; font-style: italic;"># start resizing and cropping</span><br />
<span style="color: #000000; font-weight: bold;">for</span> FORMAT <span style="color: #000000; font-weight: bold;">in</span> <span style="color: #800000;">${FORMATS}</span>; <span style="color: #000000; font-weight: bold;">do</span><br />
<br />
&nbsp; <span style="color: #000000; font-weight: bold;">for</span> FILE <span style="color: #000000; font-weight: bold;">in</span> <span style="color: #000000; font-weight: bold;">`</span><span style="color: #c20cb9; font-weight: bold;">find</span> . <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">grep</span> <span style="color: #800000;">${FORMAT}</span><span style="color: #000000; font-weight: bold;">`</span>; <span style="color: #000000; font-weight: bold;">do</span><br />
<br />
&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">for</span> SIZE <span style="color: #000000; font-weight: bold;">in</span> <span style="color: #800000;">${SIZES}</span>; <span style="color: #000000; font-weight: bold;">do</span><br />
<br />
&nbsp; &nbsp; &nbsp; <span style="color: #007800;">SIZENAME</span>=<span style="color: #000000; font-weight: bold;">`</span><span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #800000;">${SIZE}</span> <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">cut</span> <span style="color: #660033;">-f</span> <span style="color: #000000;">1</span> <span style="color: #660033;">-d</span> :<span style="color: #000000; font-weight: bold;">`</span><br />
&nbsp; &nbsp; &nbsp; <span style="color: #007800;">SIZEWIDTH</span>=<span style="color: #000000; font-weight: bold;">`</span><span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #800000;">${SIZE}</span> <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">cut</span> <span style="color: #660033;">-f</span> <span style="color: #000000;">2</span> <span style="color: #660033;">-d</span> :<span style="color: #000000; font-weight: bold;">`</span><br />
&nbsp; &nbsp; &nbsp; <span style="color: #007800;">FILENAME</span>=<span style="color: #000000; font-weight: bold;">`</span><span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #800000;">${FILE}</span> <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">sed</span> s<span style="color: #000000; font-weight: bold;">/</span><span style="color: #ff0000;">&quot;.<span style="color: #007800;">${FORMAT}</span>&quot;</span><span style="color: #000000; font-weight: bold;">//</span>g<span style="color: #000000; font-weight: bold;">`</span><br />
<br />
&nbsp; &nbsp; &nbsp; convert <span style="color: #800000;">${FILE}</span> <span style="color: #660033;">-resize</span> \<br />
&nbsp; &nbsp; &nbsp; <span style="color: #ff0000;">&quot;<span style="color: #007800;">${SIZEWIDTH}</span>^&gt;&quot;</span> <span style="color: #800000;">${FILENAME}</span>_<span style="color: #800000;">${SIZENAME}</span>.<span style="color: #800000;">${FORMAT}</span><br />
<br />
&nbsp; &nbsp; &nbsp; convert <span style="color: #660033;">-gravity</span> Center <span style="color: #660033;">-crop</span> \<br />
&nbsp; &nbsp; &nbsp; <span style="color: #800000;">${SIZEWIDTH}</span>x<span style="color: #800000;">${SIZEWIDTH}</span>+<span style="color: #000000;">0</span>+<span style="color: #000000;">0</span> \<br />
&nbsp; &nbsp; &nbsp; <span style="color: #800000;">${FILENAME}</span>_<span style="color: #800000;">${SIZENAME}</span>.<span style="color: #800000;">${FORMAT}</span> \<br />
&nbsp; &nbsp; &nbsp; <span style="color: #800000;">${FILENAME}</span>_<span style="color: #800000;">${SIZENAME}</span>.<span style="color: #800000;">${FORMAT}</span><br />
<br />
&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">done</span><br />
<br />
&nbsp; <span style="color: #000000; font-weight: bold;">done</span><br />
<br />
<span style="color: #000000; font-weight: bold;">done</span><br />
<br />
<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;OK&quot;</span><br />
<br />
<span style="color: #666666; font-style: italic;"># enjoy :-)</span></div></div>
]]></content:encoded>
			<wfw:commentRss>http://ivanhq.net/2010/03/04/recursive-crop-with-imagemagick/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Massive emailer</title>
		<link>http://ivanhq.net/2009/11/20/massive-emailer/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=massive-emailer</link>
		<comments>http://ivanhq.net/2009/11/20/massive-emailer/#comments</comments>
		<pubDate>Fri, 20 Nov 2009 13:04:10 +0000</pubDate>
		<dc:creator>ivan</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[Networking]]></category>
		<category><![CDATA[Programación]]></category>
		<category><![CDATA[Ruby on Rails]]></category>

		<guid isPermaLink="false">http://ivanhq.net/?p=320</guid>
		<description><![CDATA[Yesterday I did a talk at Xing offices in Barcelona. It was about some tips on how to send emails massively from a Ruby on Rails application without being tagged as a spammer by Hotmail, Gmail or Yahoo. I&#8217;m not a dedicated expert on this, but I&#8217;ve been learning these things while developing last internet [...]]]></description>
			<content:encoded><![CDATA[<p>Yesterday I did a talk at Xing offices in Barcelona. It was about some tips on how to send emails massively from a Ruby on Rails application without being tagged as a spammer by Hotmail, Gmail or Yahoo. I&#8217;m not a dedicated expert on this, but I&#8217;ve been learning these things while developing last internet site, and I thought it may be also interesting for other developers.<br />
Here are the slides (in english) of the presentation, formerly named  &#8220;<b>Massive emailing with Linux, Postfix and Ruby on Rails</b>&#8220;.</p>
<div style="width:490px;text-align:center" id="__ss_2544347"><object style="margin:0px" width="425" height="355"><param name="movie" value="http://static.slidesharecdn.com/swf/ssplayer2.swf?doc=massiveemailer-091120062912-phpapp02&#038;stripped_title=massive-emailing-with-linux-postfix-and-ruby-on-rails" /><param name="allowFullScreen" value="true"/><param name="allowScriptAccess" value="always"/><embed src="http://static.slidesharecdn.com/swf/ssplayer2.swf?doc=massiveemailer-091120062912-phpapp02&#038;stripped_title=massive-emailing-with-linux-postfix-and-ruby-on-rails" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="425" height="355"></embed></object></div>
<p><a href="http://www.ivanhq.net/stuff/massive_emailer.pdf">Here is the PDF</a> for downloading.</p>
]]></content:encoded>
			<wfw:commentRss>http://ivanhq.net/2009/11/20/massive-emailer/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Remote pair programming</title>
		<link>http://ivanhq.net/2009/03/24/remote-pair-programming/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=remote-pair-programming</link>
		<comments>http://ivanhq.net/2009/03/24/remote-pair-programming/#comments</comments>
		<pubDate>Tue, 24 Mar 2009 01:53:31 +0000</pubDate>
		<dc:creator>ivan</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[Networking]]></category>
		<category><![CDATA[Programación]]></category>

		<guid isPermaLink="false">http://ivanhq.net/?p=221</guid>
		<description><![CDATA[Pair programming es una técnica en la que dos programadores trabajan con una misma consola, sobre el mismo código. Normalmente uno hace la función de driver y el otro la de observer. El objetivo es evidente: crear un mejor código, a la vez que conseguir que ambos programadores lo conozcan con el mismo nivel de [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://en.wikipedia.org/wiki/Pair_programming">Pair programming</a> es una técnica en la que dos programadores trabajan con una misma consola, sobre el mismo código. Normalmente uno hace la función de <i>driver</i> y el otro la de <i>observer</i>. El objetivo es evidente: crear un mejor código, a la vez que conseguir que ambos programadores lo conozcan con el mismo nivel de profundidad.</p>
<p>Hoy tenía un problema con el proyecto en el que estoy trabajando, y pedí a Mauro que me echase un cable a ver si entre los dos conseguíamos solucionarlo. Él estaba en su casa, y yo en la mía. Los ingredientes para cocinar un pair programming <b>realmente fluído</b> en remoto:</p>
<ul>
<li><b>Port forwarding:</b> un puerto para el acceso remoto por <b>SSH</b> y otro para el acceso al <b>servidor de aplicaciones</b> (acceso web)</li>
<li><b>screen:</b> Usando una versión ligeramente modificada del <a href="http://www.userlinux.net/1470_archivo_screenrc">screenrc de r0sk</a>. Usamos tres consolas: <b>[0]</b> log del servidor, <b>[1]</b> vim con el código, <b>[2]</b> una bash para hacer accesos de mysql u otras cosas que necesitemos</li>
<li><b>vim:</b> con los controles mapeados para trabajar con tabs, y el plugin de FuzzyFinderTextMate para buscar y abrir archivos&#8230; así se puede hacer todo en una sola consola</li>
<li><b>Skype:</b> Para hablar todo el rato durante la sesión de programación</li>
</ul>
<p>Los programadores <i>maceros</i> que usan TextMate suelen hacer el pair programming usando VNC, pero aunque no lo he probado pongo las dos manos en el fuego a que tiene que ser una cagada. La pareja <b>screen+vim</b> es brutal por lo lightweight y lo flexible, y consume muy poquito ancho de banda con lo que la comunicación del conjunto (ssh + skype) es perfecta.</p>
<p>La experiencia ha sido GENIAL, y hemos resuelto el problema en aproximadamente 1 hora. Es como trabajar en <a href="http://en.wikipedia.org/wiki/Pair_programming">pair programming</a> en local, tocando el mismo código y comentando todo el rato. Ha sido una pasada, y lo recomiendo a todos los programadores que trabajen separados físicamente del resto del equipo.</p>
]]></content:encoded>
			<wfw:commentRss>http://ivanhq.net/2009/03/24/remote-pair-programming/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>backupMussol 0.1</title>
		<link>http://ivanhq.net/2008/09/08/backupmussol-01/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=backupmussol-01</link>
		<comments>http://ivanhq.net/2008/09/08/backupmussol-01/#comments</comments>
		<pubDate>Mon, 08 Sep 2008 13:00:39 +0000</pubDate>
		<dc:creator>ivan</dc:creator>
				<category><![CDATA[Linux]]></category>

		<guid isPermaLink="false">http://ivanhq.net/2008/09/08/backupmussol-01/</guid>
		<description><![CDATA[Ya son varios los amigos o colegas que me preguntan cómo hago los backups en los servidores del trabajo. En realidad uso sólamente tres herramientas: Mondo Rescue, DAR y el ya conocido rsync. Mondo es una herramienta para crear imágenes del sistema autoarrancables (liveCD) y poderlas planchar en un CD o DVD (o en varios [...]]]></description>
			<content:encoded><![CDATA[<p>Ya son varios los amigos o colegas que me preguntan cómo hago los backups en los servidores del trabajo. En realidad uso sólamente tres herramientas: <a href="http://www.mondorescue.com">Mondo Rescue</a>, <a href="http://dar.linux.free.fr">DAR</a> y el ya conocido <a href="http://samba.anu.edu.au/rsync/">rsync</a>.</p>
<ul>
<li>Mondo es una herramienta para crear imágenes del sistema autoarrancables (liveCD) y poderlas planchar en un CD o DVD (o en varios si es muy grande). Después se puede arrancar el sistema con ellas y restaurarlo así al estado en que se encontraba en el momento de sacar el backup.</li>
<li>DAR, por su parte, es una herramienta de backup diferencial.</li>
<li>Y rsync todos sabemos lo que es. Yo lo uso para hacer un mirror de los discos en lugar de usar RAID1, de esta forma tengo una ventana de tiempo de 24 horas para restaurar un backup en caso de fallo en el filesystem (ya que con un RAID1 se propaga al momento, y sí: lo he sufrido ya una vez, la primera y la última).</li>
</ul>
<p>Todas estas herramientas las uso mediante un pequeño set de scripts, es muy sencillito y no tiene mucha complicación, así que he decidido liberarlos para que los podais usar si estais interesados.</p>
<p>He creado una página nueva (se ve en el menú lateral) llamada <a href="http://ivanhq.net/mussol-scripts">Mussol Scripts</a> y lo he dejado ahí junto con un par más que había escrito anteriormente para otras cosas.</p>
<p>Espero que os sea de utilidad :-)</p>
]]></content:encoded>
			<wfw:commentRss>http://ivanhq.net/2008/09/08/backupmussol-01/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Serveralias en lighttpd</title>
		<link>http://ivanhq.net/2008/06/13/serveralias-en-lighttpd/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=serveralias-en-lighttpd</link>
		<comments>http://ivanhq.net/2008/06/13/serveralias-en-lighttpd/#comments</comments>
		<pubDate>Fri, 13 Jun 2008 00:28:14 +0000</pubDate>
		<dc:creator>ivan</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[Networking]]></category>

		<guid isPermaLink="false">http://ivanhq.net/2008/06/13/serveralias-en-lighttpd/</guid>
		<description><![CDATA[Valga cuanto menos a modo de recordatorio personal. Un virtualhost habitual (atención al ==): $HTTP["host"] == "www.something.net" { Para que www.something.net, www.something.com o www.something.lo_que_sea apunten al mismo documentroot (atención al =~): $HTTP["host"] =~ "www.something" { Y para que www.something.net y www.otherthing.net apunten al mismo documentroot: $HTTP["host"] =~ "(www.something.net&#124;www.otherthing.net)" {]]></description>
			<content:encoded><![CDATA[<p>Valga cuanto menos a modo de recordatorio personal.</p>
<p>Un virtualhost habitual (atención al <b>==</b>):</p>
<pre>
$HTTP["host"] == "www.something.net" {
</pre>
<p>Para que <b>www.something.net</b>, <b>www.something.com</b> o <b>www.something.lo_que_sea</b> apunten al mismo documentroot (atención al <b>=~</b>):</p>
<pre>
$HTTP["host"] =~ "www.something" {
</pre>
<p>Y para que <b>www.something.net</b> y <b>www.otherthing.net</b> apunten al mismo documentroot:</p>
<pre>
$HTTP["host"] =~ "(www.something.net|www.otherthing.net)" {
</pre>
]]></content:encoded>
			<wfw:commentRss>http://ivanhq.net/2008/06/13/serveralias-en-lighttpd/feed/</wfw:commentRss>
		<slash:comments>0</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>
		<item>
		<title>Paquetes de Slackware con makepkg</title>
		<link>http://ivanhq.net/2007/09/25/paquetes-de-slackware-con-makepkg/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=paquetes-de-slackware-con-makepkg</link>
		<comments>http://ivanhq.net/2007/09/25/paquetes-de-slackware-con-makepkg/#comments</comments>
		<pubDate>Tue, 25 Sep 2007 21:32:35 +0000</pubDate>
		<dc:creator>ivan</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[opinión]]></category>
		<category><![CDATA[Slackware]]></category>

		<guid isPermaLink="false">http://ivanhq.net/2007/09/25/paquetes-de-slackware-con-makepkg/</guid>
		<description><![CDATA[Siempre cuando he impartido cursos de Linux lo he hecho bajo Slackware. Uno de los temas que me parecen más interesantes es la gestión de paquetes. Entre otras cosas porque es prácticamente lo que más se le ha echado en cara siempre a Slackware desde Debian o Red Hat. Slackware tiene herramientas de gestión de [...]]]></description>
			<content:encoded><![CDATA[<p><img src="/wp-content/uploads/2007/07/slackware.png" align="left">Siempre cuando he impartido cursos de Linux lo he hecho bajo <a href="http://www.slackware.com">Slackware</a>. Uno de los temas que me parecen más interesantes es la gestión de paquetes. Entre otras cosas porque es prácticamente lo que más se le ha echado en cara siempre a Slackware desde Debian o Red Hat.</p>
<p><a href="http://www.slackware.com">Slackware</a> tiene herramientas de gestión de paquetes, y son flexibles y funcionan perfectamente. Desde luego jamás he visto petar un paquete de slackware como he visto petar un paquete instalado con apt.<br />
El sistema de paquetes de Slackware es muy sencillo: descomprimir el binario, copiar los contenidos a su sitio y guardar una base de datos de referencia para borrarlos cuando se desee. No falla. ¿Para qué más?</p>
<p>Ahora bien, no hay paquetes de slackware para todo lo que se desea. Así que aquí va una pequeña explicación de cómo crear paquetes para Slackware usando <b>makepkg</b>, una de las herramientas propias de la distribución.</p>
<p><b>1. Crear un área de trabajo para compilar el paquete</b></p>
<pre>
mkdir /work
mkdir /work/scripts
mkdir /work/builds
</pre>
<p><b>2. Descargar el fuente y compilarlo</b></p>
<pre>
cd /usr/local/src
tar zxvfp progname-progversion.tar.gz
cd progname-progversion/
./configure --prefix=/usr --sysconfdir=/etc --localstatedir=/var
make
</pre>
<p><b>3. Instalarlo dentro del área de trabajo</b></p>
<pre>
make install DESTDIR=/work/builds
cp -Rp doc/ /work/builds/usr/
# copiar más cosas que se quieran incorporar al paquete
</pre>
<p><b>4. Crear el paquete</b></p>
<pre>
cd /work/builds
makepkg progname-progversion-arch-build.tgz
# contestar SI a la pregunta sobre enlaces y permisos
</pre>
<p><b>5. Mover el paquete a su sitio y limpiar los restos</b></p>
<pre>
mkdir -p /var/spool/packages
mv progname-progversion-arch-build.tgz /var/spool/packages/
rm -rf *
</pre>
<p><b>6. Instalar el paquete</b></p>
<pre>
cd /var/spool/packages
installpkg progname-progversion-arch-build.tgz
</pre>
<p><b>7. Praise Bob!</b></p>
<div align="center"><a href='http://www.subgenius.com' title='bob.jpg'><img src='http://ivanhq.net/wp-content/uploads/2007/09/bob.jpg' alt='bob.jpg' /></a></div>
]]></content:encoded>
			<wfw:commentRss>http://ivanhq.net/2007/09/25/paquetes-de-slackware-con-makepkg/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>]Project-open[ on Debian</title>
		<link>http://ivanhq.net/2007/09/18/project-open-on-debian/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=project-open-on-debian</link>
		<comments>http://ivanhq.net/2007/09/18/project-open-on-debian/#comments</comments>
		<pubDate>Tue, 18 Sep 2007 18:21:16 +0000</pubDate>
		<dc:creator>ivan</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[project-open]]></category>

		<guid isPermaLink="false">http://ivanhq.net/2007/09/18/project-open-on-debian/</guid>
		<description><![CDATA[He escrito una página con las instrucciones y los paquetes para instalar ]Project-open[ en Debian ETCH. Nunca había hecho paquetes de Debian, así que supongo que serán un poco primitivos. En cualquier caso son perfectamente funcionales. También lo he posteado en la web de la empresa. Será bien recibida cualquier aportación o comentario :-) ---- [...]]]></description>
			<content:encoded><![CDATA[<p><a href='http://www.project-open.com' title=']Project-open['><img align='left' src='http://ivanhq.net/wp-content/uploads/2007/09/po-mini1.thumbnail.jpg' alt='po-mini1.jpg' /></a>He escrito <a href="http://ivanhq.net/project-open-on-debian-etch/">una página</a> con las instrucciones y los paquetes para instalar <a href="http://www.project-open.com">]Project-open[</a> en Debian ETCH. Nunca había hecho paquetes de Debian, así que supongo que serán un poco primitivos. En cualquier caso son perfectamente funcionales.<br />
También lo he posteado en <a href="http://sysdivision.com/index.php?do=26">la web de la empresa</a>.<br />
Será bien recibida cualquier aportación o comentario :-)</p>
<p>----</p>
<p>I've written <a href="http://ivanhq.net/project-open-on-debian-etch/">a page</a> with instructions and packages for installing <a href="http://www.project-open.com">]Project-open[</a> on Debian ETCH. I&#8217;ve never built any debian package, so maybe they&#8217;re so primitive. But anyway they&#8217;re completely functional.<br />
I&#8217;ve posted it on <a href="http://sysdivision.com/index.php?do=26">my company&#8217;s website too</a>.<br />
Comments will be appreciated :-)</p>
]]></content:encoded>
			<wfw:commentRss>http://ivanhq.net/2007/09/18/project-open-on-debian/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

