Building a Rails Server
Fellow Los Techie ****John Petersen** took the famous (or infamous) **Nerd Dinner** **application created by Scott Hanselman and ported it to the **Ruby on Rails platform. When John was developing this, I recommended we actually put it online and proceeded to purchase the domain name www.railsdinner.com
Owning the domain name was one thing, hosting the site was entirely another. Last week I decided to find a place to host Rails Dinner. That place conveniently, is the server closet in my home office.
I had a spare machine not really doing much so I decided to appropriate it as a Linux server capable of hosting Ruby on Rails applications.
Hosting a Rails application requires a number of moving parts. The moving parts I installed and their purpose are as follows:
|Ubuntu 9.10 Server||Linux server.|
|Ruby (including Gems)||The runtime for ruby|
|Ruby on Rails||MVC based web application framework|
|MySQL||Open source SQL database.|
|Passenger||Runtime deployment tool for Rails applications.|
|nginx||High performance web server|
Around the 3rd or 4th time of trying to install this server I decided to keep a log. The following tasks are what you need to do to get a Rails Server up and running.
|Download and install Ubuntu Server||www.ubuntu.com|
|sudo apt-get install ubuntu-desktop||Optional step to add GUI support to your Linux server.|
|sudo apt-get install ruby-full build-essential||Install ruby and all necessary libraries.|
|sudo apt-get install rubygems||Install ruby gems distribution tools|
|sudo gem install rails||Install rails|
|sudo apt-get install mysql-server||Install mySQL Server|
|sudo apt-get install mysql-client libmysql-ruby libmysqlclient15-dev||Install all libraries used to talk to mySQL|
|sudo gem install passenger||Download all libraries needed to install passenger|
|sudo apt-get install libopenssl-ruby||Install library required to compile nginx web server|
|sudo apt-get install libssl-dev||Install library required to compile nginx web server|
|sudo apt-get install zlib1g-dev||Install library required to compile nginx web server|
Change to directory where nginx build files are located. </p>
NOTE: You may want to add this folder to your systems PATH settings</td> </tr>
Downloads code and compiles (yes compiles!) custom web server with passenger built in. </p>
NOTE: This command is finicky and took me a few tries to get it to run properly.
NOTE: nginx is a high performance web server that is used by a lot of major web sites. It does not have a module/plug-in architecture so passenger is compiled directly into the server code.
Web Server Configuration
After your web server compiles you need do add a script to your system to facilitate the stopping/starting/restarting of the nginx web server.
I found the script (and instructions) below at the following site: http://library.linode.com/development/frameworks/ruby/ruby-on-rails/nginx-ubuntu-9.10-karmic