<?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>catapult-creative.com &#187; Linux</title>
	<atom:link href="http://www.catapult-creative.com/tag/linux/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.catapult-creative.com</link>
	<description>worldwide (web) whatnot</description>
	<lastBuildDate>Wed, 18 Aug 2010 13:33:39 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.5</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Installing Rails on CentOS 5</title>
		<link>http://www.catapult-creative.com/2009/02/04/installing-rails-on-centos-5/</link>
		<comments>http://www.catapult-creative.com/2009/02/04/installing-rails-on-centos-5/#comments</comments>
		<pubDate>Wed, 04 Feb 2009 19:31:00 +0000</pubDate>
		<dc:creator>Trevor</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[remember-tip]]></category>

		<guid isPermaLink="false">tag:www.catapult-creative.com,2009-02-04:91</guid>
		<description><![CDATA[Note: Since this post originally went up, some of the packages have changed/updated.  I&#8217;ve kept things pretty well up-to-date, but you might want to double check the latest versions and alter the bash commands accordingly.  Be aware that as of this writing, the Ruby team has made 1.9.1 the latest stable and only [...]]]></description>
			<content:encoded><![CDATA[<p><em><strong>Note:</strong> Since this post originally went up, some of the packages have changed/updated.  I&#8217;ve kept things pretty well up-to-date, but you might want to double check the latest versions and alter the bash commands accordingly.  Be aware that as of this writing, the Ruby team has made 1.9.1 the latest stable and only Rails itself is deemed compatible with Ruby 1.9x.  I.e., Rails passes all its own tests on 1.9.1, but most plugins, libraries, etc are likely to give you problems right now.  So your best bet is to use 1.8.7 for awhile until your favorite libraries jump on board the 1.9 wagon. &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&#8211;Trevor (August 17, 2009)</em></p>


<p>I recently had to roll a new VM for work in order to run <a href="http://rubyonrails.org/" title="Ruby on Rails">Rails</a> and <a href="http://www.sinatrarb.com/" title="Sinatra">Sinatra</a> apps on <a href="http://www.modrails.com/" title="Overview &amp;#x2014; Phusion Passenger&amp;trade; (a.k.a. mod_rails / mod_rack)">Apache/Passenger</a>.  My company favors CentOS as the default distro for all our boxes, so I wasn&#8217;t able to use all the super-up-to-date packages that Ubuntu makes available, and I ended up building everything from source.  For posterity and for anyone else who needs it, here&#8217;s a list of what to do and how to do it.</p>

<h3>Dependencies</h3>

<p>You&#8217;ll need several libraries and the MySQL server, and you can use yum to install them all at once.  This set includes the gcc compiler, the gcc-c++ compiler, and the zlib development headers for Ruby.  <strong>Remember:</strong> not all libraries are the same &#8212; you&#8217;re going to need to make sure that you&#8217;re compiling Ruby w/ 32 or 64-bit development headers as appropriate for your architecture.</p>

<div class="codecolorer-container text blackboard" style="overflow:auto;white-space:nowrap;width:620px"><table cellspacing="0" cellpadding="0"><tbody><tr><td class="line-numbers"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br /></div></td><td><div class="text codecolorer" style="font-family:Monaco,Lucida Console,monospace">sudo yum install httpd-devel\<br />
&nbsp; openssl-devel\<br />
&nbsp; zlib-devel\<br />
&nbsp; gcc\ <br />
&nbsp; gcc-c++\ <br />
&nbsp; curl-devel\ <br />
&nbsp; expat-devel\ <br />
&nbsp; gettext-devel\ <br />
&nbsp; mysql-server\ <br />
&nbsp; mysql-devel</div></td></tr></tbody></table></div>

<h3>Ruby</h3>

<p>Next up is Ruby.  We&#8217;ll install 1.8.7-p72, the latest stable as of this writing.  First, we&#8217;ll make a &#8220;src&#8221; directory in /usr/local to hold everything:</p>

<div class="codecolorer-container text blackboard" style="overflow:auto;white-space:nowrap;width:620px"><table cellspacing="0" cellpadding="0"><tbody><tr><td class="line-numbers"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br /></div></td><td><div class="text codecolorer" style="font-family:Monaco,Lucida Console,monospace">sudo mkdir /usr/local/src<br />
&nbsp; cd /usr/local/src<br />
&nbsp; sudo curl -O ftp://ftp.ruby-lang.org/pub/ruby/1.8/ruby-1.8.7-p72.tar.gz<br />
&nbsp; sudo tar xzvf ruby-1.8.7-p72.tar.gz<br />
&nbsp; cd ruby-1.8.7-p72<br />
&nbsp; sudo ./configure --enable-shared --enable-pthread<br />
&nbsp; sudo make<br />
&nbsp; sudo make install</div></td></tr></tbody></table></div>

<p>Ok now for a weird thing &#8212; you need to remake and re-install Ruby after using it to run a script that helps you make a new makefile.  This is so that you can tell it where the zlib headers live:</p>

<div class="codecolorer-container text blackboard" style="overflow:auto;white-space:nowrap;width:620px"><table cellspacing="0" cellpadding="0"><tbody><tr><td class="line-numbers"><div>1<br />2<br />3<br />4<br />5<br /></div></td><td><div class="text codecolorer" style="font-family:Monaco,Lucida Console,monospace">cd ext/zlib<br />
&nbsp; ruby extconf.rb --with-zlib-include=/usr/include --with-zlib-lib=/usr/lib<br />
&nbsp; cd ../../<br />
&nbsp; sudo make<br />
&nbsp; sudo make install</div></td></tr></tbody></table></div>

<p>After all that happens, you should have Ruby installed.  Check and see by doing:</p>

<div class="codecolorer-container text blackboard" style="overflow:auto;white-space:nowrap;width:620px"><table cellspacing="0" cellpadding="0"><tbody><tr><td class="line-numbers"><div>1<br /></div></td><td><div class="text codecolorer" style="font-family:Monaco,Lucida Console,monospace">ruby --version</div></td></tr></tbody></table></div>

<p>You should see something like:</p>

<div class="codecolorer-container text blackboard" style="overflow:auto;white-space:nowrap;width:620px"><table cellspacing="0" cellpadding="0"><tbody><tr><td class="line-numbers"><div>1<br /></div></td><td><div class="text codecolorer" style="font-family:Monaco,Lucida Console,monospace">ruby 1.8.7 (2008-08-11 patchlevel 72) [i686-linux]</div></td></tr></tbody></table></div>

<h3>Rubygems</h3>

<p>Now that you have Ruby installed, Rubygems is easy &#8212; the whole thing is in Ruby so there&#8217;s nothing to build/compile.</p>

<div class="codecolorer-container text blackboard" style="overflow:auto;white-space:nowrap;width:620px"><table cellspacing="0" cellpadding="0"><tbody><tr><td class="line-numbers"><div>1<br />2<br />3<br />4<br />5<br /></div></td><td><div class="text codecolorer" style="font-family:Monaco,Lucida Console,monospace">cd /usr/local/src<br />
&nbsp; sudo wget http://rubyforge.org/frs/download.php/60718/rubygems-1.3.5.tgz<br />
&nbsp; sudo tar xzvf rubygems-1.3.5.tgz<br />
&nbsp; cd rubygems-1.3.5<br />
&nbsp; sudo ruby setup.rb</div></td></tr></tbody></table></div>

<h3>Rails, Passenger, MySQL and Sinatra</h3>

<p>Now that Ruby and Rubygems are installed, you can install Rails, Passenger, and Sinatra as gems:</p>

<div class="codecolorer-container text blackboard" style="overflow:auto;white-space:nowrap;width:620px"><table cellspacing="0" cellpadding="0"><tbody><tr><td class="line-numbers"><div>1<br /></div></td><td><div class="text codecolorer" style="font-family:Monaco,Lucida Console,monospace">sudo gem install rails passenger sinatra</div></td></tr></tbody></table></div>

<p>That will take awhile, as there&#8217;s a ton of documentation to build for Rails, and Passenger has to compile some native extensions.</p>

<p>Once that&#8217;s done, finish the Passenger installation with their nifty installer tool:</p>

<div class="codecolorer-container text blackboard" style="overflow:auto;white-space:nowrap;width:620px"><table cellspacing="0" cellpadding="0"><tbody><tr><td class="line-numbers"><div>1<br /></div></td><td><div class="text codecolorer" style="font-family:Monaco,Lucida Console,monospace">sudo passenger-install-apache2-module</div></td></tr></tbody></table></div>

<p>Follow the provided instructions at the end of the installer for adding lines to httpd.conf:</p>

<div class="codecolorer-container text blackboard" style="overflow:auto;white-space:nowrap;width:620px"><table cellspacing="0" cellpadding="0"><tbody><tr><td class="line-numbers"><div>1<br />2<br />3<br /></div></td><td><div class="text codecolorer" style="font-family:Monaco,Lucida Console,monospace">LoadModule passenger_module /usr/local/lib/ruby/gems/1.8/gems/passenger-2.0.6/ext/apache2/mod_passenger.so<br />
PassengerRoot /usr/local/lib/ruby/gems/1.8/gems/passenger-2.0.6<br />
PassengerRuby /usr/local/bin/ruby</div></td></tr></tbody></table></div>

<p>After that, install the MySQL gem, making sure to specify where the config is:</p>

<div class="codecolorer-container text blackboard" style="overflow:auto;white-space:nowrap;width:620px"><table cellspacing="0" cellpadding="0"><tbody><tr><td class="line-numbers"><div>1<br /></div></td><td><div class="text codecolorer" style="font-family:Monaco,Lucida Console,monospace">sudo gem install mysql -- --with-mysql-config=/usr/bin/mysql_config</div></td></tr></tbody></table></div>

<h3>Disabling <span class="caps">SEL</span>inux</h3>

<p>The RedHat family of distros (RHEL, CentOS, Fedora) come with <span class="caps">SEL</span>inux enabled by default.  If you want to learn how to make it work with Passenger, you can try <a href="http://www.modrails.com/documentation/Users%20guide.html#_the_apache_error_log_says_that_the_spawn_manager_script_does_not_exist_or_that_it_does_not_have_permission_to_execute_it" title="Phusion Passenger users guide">this tip</a> from the Passenger user&#8217;s guide.  I just turned it off because the box is only going to be used for these apps, and <span class="caps">SEL</span>inux seems like overkill.  Here&#8217;s how to shut it down:</p>

<p>First, disable it temporarily:</p>

<div class="codecolorer-container text blackboard" style="overflow:auto;white-space:nowrap;width:620px"><table cellspacing="0" cellpadding="0"><tbody><tr><td class="line-numbers"><div>1<br /></div></td><td><div class="text codecolorer" style="font-family:Monaco,Lucida Console,monospace">sudo echo 0 &gt;/selinux/enforce</div></td></tr></tbody></table></div>

<p>That&#8217;s not a permanent fix though, because the next time the server boots, it&#8217;ll be turned back on again.  You need to edit the config file and turn it off.  Open it with your favorite editor and change one line.  You need to be root or running as sudo to edit this file, and I prefer Vim when on remote servers, so it&#8217;s:</p>

<div class="codecolorer-container text blackboard" style="overflow:auto;white-space:nowrap;width:620px"><table cellspacing="0" cellpadding="0"><tbody><tr><td class="line-numbers"><div>1<br /></div></td><td><div class="text codecolorer" style="font-family:Monaco,Lucida Console,monospace">sudo vim /etc/sysconfig/selinux</div></td></tr></tbody></table></div>

<p>Change this:</p>

<div class="codecolorer-container text blackboard" style="overflow:auto;white-space:nowrap;width:620px"><table cellspacing="0" cellpadding="0"><tbody><tr><td class="line-numbers"><div>1<br /></div></td><td><div class="text codecolorer" style="font-family:Monaco,Lucida Console,monospace">SELINUX=enforcing</div></td></tr></tbody></table></div>

<p>to this:</p>

<div class="codecolorer-container text blackboard" style="overflow:auto;white-space:nowrap;width:620px"><table cellspacing="0" cellpadding="0"><tbody><tr><td class="line-numbers"><div>1<br /></div></td><td><div class="text codecolorer" style="font-family:Monaco,Lucida Console,monospace">SELINUX=disabled</div></td></tr></tbody></table></div>

<h3>Restart Apache</h3>

<p>You should be able to restart Apache now and have Passenger come up no problem.  There are several ways to restart Apache, but I like to use the service way to keep it simple:</p>

<div class="codecolorer-container text blackboard" style="overflow:auto;white-space:nowrap;width:620px"><table cellspacing="0" cellpadding="0"><tbody><tr><td class="line-numbers"><div>1<br /></div></td><td><div class="text codecolorer" style="font-family:Monaco,Lucida Console,monospace">sudo /sbin/service httpd restart</div></td></tr></tbody></table></div>

<h3>Optional: Installing Git </h3>

<p>For <span class="caps">SCM, </span>there are a lot of reasons why I like <a href="http://git-scm.com/" title="Git - Fast Version Control System">Git</a> better than Subversion.  It&#8217;s got a bit of a learning curve, but once you go Git, you never go back.</p>

<div class="codecolorer-container text blackboard" style="overflow:auto;white-space:nowrap;width:620px"><table cellspacing="0" cellpadding="0"><tbody><tr><td class="line-numbers"><div>1<br />2<br />3<br />4<br />5<br />6<br /></div></td><td><div class="text codecolorer" style="font-family:Monaco,Lucida Console,monospace">cd /usr/local/src<br />
curl -O http://www.kernel.org/pub/software/scm/git/git-1.6.0.4.tar.gz<br />
tar zxf git-1.6.0.4.tar.gz<br />
cd git-1.6.0.4<br />
sudo make all<br />
sudo make install</div></td></tr></tbody></table></div>

<p>And the man pages:</p>

<div class="codecolorer-container text blackboard" style="overflow:auto;white-space:nowrap;width:620px"><table cellspacing="0" cellpadding="0"><tbody><tr><td class="line-numbers"><div>1<br />2<br />3<br />4<br /></div></td><td><div class="text codecolorer" style="font-family:Monaco,Lucida Console,monospace">cd /usr/local/src <br />
curl -O http://www.kernel.org/pub/software/scm/git/git-manpages-1.6.0.4.tar.gz<br />
cd /usr/local/share/man<br />
tar -zxf /usr/local/src/git-manpages-1.6.0.4.tar.gz</div></td></tr></tbody></table></div>

<p>Now you should have Git installed and ready.  Prove it:</p>

<div class="codecolorer-container text blackboard" style="overflow:auto;white-space:nowrap;width:620px"><table cellspacing="0" cellpadding="0"><tbody><tr><td class="line-numbers"><div>1<br /></div></td><td><div class="text codecolorer" style="font-family:Monaco,Lucida Console,monospace">git --version</div></td></tr></tbody></table></div>

<p>You should see something like:</p>

<div class="codecolorer-container text blackboard" style="overflow:auto;white-space:nowrap;width:620px"><table cellspacing="0" cellpadding="0"><tbody><tr><td class="line-numbers"><div>1<br /></div></td><td><div class="text codecolorer" style="font-family:Monaco,Lucida Console,monospace">git version 1.6.0.4</div></td></tr></tbody></table></div>

<p>And that&#8217;s it &#8212; you now have a full Ruby stack ready to go on CentOS 5.  Much of this tutorial was adapted from the awesome <a href="http://hivelogic.com/articles/2008/02/ruby-rails-leopard" title="Hivelogic - Installing Ruby, Rubygems, Rails, and Mongrel on Mac OS X 10.5 (Leopard)">Hivelogic post</a> on installing the stack on OS X Leopard.</p>]]></content:encoded>
			<wfw:commentRss>http://www.catapult-creative.com/2009/02/04/installing-rails-on-centos-5/feed/</wfw:commentRss>
		<slash:comments>37</slash:comments>
		</item>
	</channel>
</rss>
