<?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/"
	xmlns:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:media="http://search.yahoo.com/mrss/"
	>

<channel>
	<title>Procbits &#187; SQL</title>
	<atom:link href="http://procbits.com/category/sql/feed/" rel="self" type="application/rss+xml" />
	<link>http://procbits.com</link>
	<description>source code snippets and other random musings about software</description>
	<lastBuildDate>Wed, 01 Feb 2012 19:41:37 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>
<cloud domain='procbits.com' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
<image>
		<url>http://s2.wp.com/i/buttonw-com.png</url>
		<title>Procbits &#187; SQL</title>
		<link>http://procbits.com</link>
	</image>
	<atom:link rel="search" type="application/opensearchdescription+xml" href="http://procbits.com/osd.xml" title="Procbits" />
	<atom:link rel='hub' href='http://procbits.com/?pushpress=hub'/>
		<item>
		<title>Deploying a Rails application on Ubuntu 8.04 LTS with Phusion Passenger and SQL Server 2005</title>
		<link>http://procbits.com/2009/03/10/deploying-a-rails-application-on-ubuntu-804-lts-with-phusion-passenger-and-sql-server-2005/</link>
		<comments>http://procbits.com/2009/03/10/deploying-a-rails-application-on-ubuntu-804-lts-with-phusion-passenger-and-sql-server-2005/#comments</comments>
		<pubDate>Tue, 10 Mar 2009 05:50:10 +0000</pubDate>
		<dc:creator>JP</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[Rails]]></category>
		<category><![CDATA[Ruby]]></category>
		<category><![CDATA[SQL]]></category>

		<guid isPermaLink="false">http://procbits.com/?p=5</guid>
		<description><![CDATA[This article will provide step by step instructions for preparing and then deploying a Rails application on Ubuntu 8.04 LTS that uses Microsoft SQL Server 2005. Install Ruby sudo apt-get install ruby-full build-essential Install Apache 2 sudo apt-get install apache2 apache2-mpm-prefork apache2-prefork-dev Install Ruby Gems Do not install Ruby Gems from Apt.  This will screw [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=procbits.com&amp;blog=6893023&amp;post=5&amp;subd=procbits&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<div>
<p>This article will provide step by step instructions for preparing and then deploying a Rails application on Ubuntu 8.04 LTS that uses Microsoft SQL Server 2005.</p>
<p><strong>Install Ruby</strong><br />
<code>sudo apt-get install ruby-full build-essential</code></p>
<p><strong>Install Apache 2</strong><br />
<code>sudo apt-get install apache2 apache2-mpm-prefork apache2-prefork-dev</code></p>
<p><strong>Install Ruby Gems</strong><br />
Do not install Ruby Gems from Apt.  This will screw up your Gems repository as Apt and Gems will both want to manage it.  Download the latest Gems package from <a href="http://rubyforge.org/" target="_blank">http://rubyforge.org</a>.  At the time of this writing the latest version is 1.3.  Version 1.3 is also the version that I used.<code><br />
wget <a href="http://rubyforge.org/frs/download.php/43985/rubygems-1.3.0.tgz" target="_blank">http://rubyforge.org/frs/download.php/43985/rubygems-1.3.0.tgz</a><br />
tar xzvf rubygems-1.3.0.tgz<br />
cd rubygems-1.3.0<br />
sudo ruby setup.rb<br />
sudo ln -s /usr/bin/gem1.8 /usr/bin/gem<br />
sudo gem update --system</code></p>
<p><strong>Install Rails</strong><br />
Make sure to install the proper version.  You may need to pass the &#8220;&#8211;version&#8221; flag.<br />
<code>sudo gem install rails</code></p>
<p><strong>Install Phusion Passenger</strong><br />
This allows us to deploy Rails application with as much simplicity as it takes to deploy a PHP application.  This we can avoid using Mongrel/Proxy Balancing/(Apache|Lighttpd|Nginx).<code><br />
sudo gem install passenger<br />
sudo passenger-install-apache2-module</code></p>
<p>Next add the following to your /etc/apache2/apache2.conf file:<br />
<code> LoadModule passenger_module /usr/lib/ruby/gems/1.8/gems/passenger-2.0.3/ext/apache2/mod_passenger.so<br />
PassengerRoot /usr/lib/ruby/gems/1.8/gems/passenger-2.0.3<br />
PassengerRuby /usr/bin/ruby1.8</code></p>
<p><strong>Install Ruby/ODBC/SQLServer2005 Compatibility</strong><br />
In /etc/profile add the following:<br />
<code> export ODBCINI=/etc/odbc.ini<br />
export ODBCSYSINI=/etc<br />
export FREETDSCONF=/etc/freetds/freetds.conf</code></p>
<p>Make sure you restart your shell after this!</p>
<p>Now install UnixODBC:<code><br />
sudo apt-get install unixodbc<br />
sudo apt-get install unixodbc-dev<br />
sudo apt-get install tdsodbc<br />
</code></p>
<p>Now install FreeTDS (stable) from source. The FreeTDS in the Apt repository is version 0.63 and will not work with SQL Server 2005. At the time of this writing, the current stable version is 0.82.<code><br />
wget <a href="ftp://ftp.ibiblio.org/pub/Linux/ALPHA/freetds/stable/freetds-stable.tgz" target="_blank">ftp://ftp.ibiblio.org/pub/Linux/ALPHA/freetds/stable/freetds-stable.tgz</a><br />
cd freetds-stable<br />
./configure<br />
make<br />
sudo make install</code></p>
<p>Edit /etc/freetds/freetds.conf and add the following:<code><br />
[YOUR_DB_DEFINITION_NAME]<br />
host = 172.24.40.100<br />
port = 1433<br />
tds version = 8.0<br />
</code></p>
<p>Test it with the following:<code><br />
sqsh -S YOUR_DB_DEFINITION_NAME -U USERNAME -P PASSWORD<br />
</code></p>
<p>Once actually logged in, you can run some SQL and verify the results. Make sure to type “go” after each command and also make sure to “use” the right database.</p>
<p>Now edit /etc/odbc.ini and add the following:<code><br />
[YOUR_DB_DEFINITION_NAME]<br />
Driver          = FreeTDS<br />
Description     = ODBC connection via FreeTDS<br />
Trace           = No<br />
Servername      = YOUR_DB_DEFINITION_NAME<br />
Database        = YOUR_ACTUAL_DB_NAME<br />
</code></p>
<p>Edit /etc/odbcinst.ini and add the following:<code><br />
[FreeTDS]<br />
Description     = TDS driver (Sybase/Microsoft SQL)<br />
Driver          = /usr/lib/odbc/libtdsodbc.so<br />
Setup           = /usr/lib/odbc/libtdsS.so<br />
CPTimeout       =<br />
CPReuse         =<br />
FileUsage       = 1<br />
</code></p>
<p>Now test it….<code><br />
isql YOUR_DB_DEFINITION_NAME USERNAME PASSWORD<br />
</code></p>
<p>Install Ruby ODBC:<code><br />
wget <a href="http://www.ch-werner.de/rubyodbc/ruby-odbc-0.9995.tar.gz" target="_blank">http://www.ch-werner.de/rubyodbc/ruby-odbc-0.9995.tar.gz</a><br />
tar zvxf ruby-odbc-0.9995.tar.gz<br />
cd ruby-odbc-0.9995/<br />
ruby extconf.rb<br />
make<br />
sudo make install<br />
</code></p>
<p>Install ActiveRecord ODBC Adapter<code><br />
sudo gem install activerecord-odbc-adapter<br />
</code></p>
<p>Edit your database.yml in your application and configure it like…<code><br />
development:<br />
adapter: odbc<br />
dsn: YOUR_DB_DEFINITION_NAME<br />
username: USERNAME<br />
password: PASSWORD<br />
</code></p>
<p>Now dump your Rails app in /var/www/yourrailsapp and add a new Apache Virtual Host as seen in the previous post. Configure the virtual host DocumentRoot to point to the public directory in Apache2.  Do not forget to change ownership of your rails app to www-data. (chown -R www-data:www-data yourrailsapp) That’s all there is too it! Now you can deploy a number of Rails apps in Apache with little trouble!</p></div>
<p>Are you a Git user? Let me help you make project management with Git simple. Checkout <a href="http://gitpilot.com" target="_blank">Gitpilot</a>.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/procbits.wordpress.com/5/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/procbits.wordpress.com/5/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/procbits.wordpress.com/5/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/procbits.wordpress.com/5/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/procbits.wordpress.com/5/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/procbits.wordpress.com/5/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/procbits.wordpress.com/5/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/procbits.wordpress.com/5/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/procbits.wordpress.com/5/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/procbits.wordpress.com/5/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/procbits.wordpress.com/5/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/procbits.wordpress.com/5/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/procbits.wordpress.com/5/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/procbits.wordpress.com/5/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=procbits.com&amp;blog=6893023&amp;post=5&amp;subd=procbits&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://procbits.com/2009/03/10/deploying-a-rails-application-on-ubuntu-804-lts-with-phusion-passenger-and-sql-server-2005/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/0f56a5e429de009a27b0ae8f796ef2df?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">JP</media:title>
		</media:content>
	</item>
	</channel>
</rss>
