Home arrow Ruby-on-Rails arrow Page 3 - Application Deployment
RUBY-ON-RAILS

Application Deployment


Before an application can make it onto the Internet, it needs to go into a production environment and be deployed. This multi-part article series will show you how to do this for the Ruby-on-Rails ecommerce application we've been working on. It is excerpted from chapter 12 of the book Practical Rails Projects, written by Eldon Alameda (Apress; ISBN: 1590597818).

Author Info:
By: Apress Publishing
Rating: 5 stars5 stars5 stars5 stars5 stars / 2
August 05, 2010
TABLE OF CONTENTS:
  1. · Application Deployment
  2. · Connecting to the Production Server: SSH
  3. · Installing the Web Server: LightTPD
  4. · Installing the Application Server: Ruby on Rails and FastCGI

print this article
SEARCH DEVARTICLES

Application Deployment - Installing the Web Server: LightTPD
(Page 3 of 4 )

The web server handles the communication between the userís browser and the Emporium application, which is running on the application server in one or more separate processes. When a request comes in from the Internet, the web server forwards the request (by acting as a reverse proxy and a load balancer) to one of the application servers.

In this book, we use LightTPD as the web server, because it is a tried-and-tested open source web server that, according to its homepage (http://www.lighttpd.net) is optimized for high performance. This claim is backed up by benchmarks, which put it among the fastest web servers available currently, and in front of the more popular Apache in some areas. LightTPD is easy to configure and includes themod_fastcgimodule, which can communicate with external FastCGI processes running Ruby on Rails applications. After being forwarded by LightTPD, the request is processed by Ruby on Rails, and the output is sent back to the client, again using the FastCGI protocol.


Tip  The LightTPD wiki (http://trac.lighttpd.net/trac/wiki/) is a good starting point if you want to find out more about LightTPD and how to use it with Ruby on Rails.


Here, we provide instructions for installing LightTPD from source on Ubuntu Linux. You can also find a binary installation package for Windows, Mac OS X, and most Linux distributions athttp://www.lighttpd.net/download.

Although some commands are specific to Ubuntu Linux, the installation instructions are generally applicable to most Linux/Unix platforms, with some exceptions, such as how dependencies are installed. See the Rails wiki (wiki.rubyonrails.org) and other online resources for detailed instructions on how to set up and configure the software on other platforms.


Tip  If you are using Mac OS X, you can find a good resource for how to set up Rails, LightTPD, FastCGI, and MySQL athttp://hivelogic.com/articles/2005/12/01/ ruby_rails_lighttpd_mysql_tiger.


LightTPD has the following external dependencies, which must be installed separately and before LightTPD itself:

  1. The Perl Compatible Regular Expressions (PCRE) library, used bymod_rewriteand other modules 
     
  2. Thezlibcompression library, used for enablinggzipand other compression support 
     
  3. OpenSSL for enabling HTTPS and Secure Sockets Layer (SSL)

On Ubuntu Linux, you can install the dependencies with theapt-getcommand:

$ sudo apt-get install libpcre3-dev
$ sudo apt-get install zlib1g-dev
$ sudo apt-get install open-ssl
$ sudo apt-get install libssl-dev

You also need to install the compiler provided by GCC, which is available through thebuild-essentialspackage in Ubuntu Linux:

$ sudo apt-get install build-essentials

Next, download the latest available stable source LightTPD package fromhttp://www.lighttpd.net/downloadto a directory on your production server (such as/usr/local/srcor/tmp). Then execute the following commands one by one (weíve omitted the output of the commands here for the sake of clarity):

$ tar xzvf lighttpd-1.x.x.tar.gz
$ cd lighttpd-1.x.x
$ ./configure --with-openssl
$ make
$ sudo make install

These commands extract the package and compile the source.


Tip  For more information about compiling LightTPD, refer to theINSTALLandREADMEfiles, which are located inside the source package.


As we said, you need to install both the OpenSSL package and the SSL development libraries and headers in order to run LightTPD. If you didnít install them, you would get an error similar to the one shown here when starting LightTPD:

SSL: ssl requested but openssl support is not compiled in

You can verify that the required dependencies are found by inspecting the output of theconfigure command:

  .
  checking for OpenSSL... yes
  checking openssl/ssl.h usability... yes
  checking openssl/ssl.h presence... yes
  .
  .
  checking pcre.h usability... yes
  checking pcre.h presence... yes
  checking for pcre.h... yes
  checking for deflate in -lz... yes
  checking zlib.h usability... yes
  checking zlib.h presence... yes
  checking for zlib.h... yes
  .

If you donít see any errors while compiling and installing the source, it means you can continue and verify that the installation was successful. Execute the following command to print the version information of the binary you just compiled:

$ lighttpd -v

  lighttpd-1.4.11 - a light and fast webserver
  Build-Date: May 14 2006 20:46:11

Weíll show you how to configure LightTPD after we install the other software.


blog comments powered by Disqus
RUBY-ON-RAILS ARTICLES

- Ruby-on-Rails Faces Second Security Flaw in ...
- Ruby 2.0 Prepped for February 2013 Release
- Why LinkedIn Switched from Ruby on Rails
- Adding Style with Action Pack
- Handling HTML in Templates with Action Pack
- Filters, Controllers and Helpers in Action P...
- Action Pack and Controller Filters
- Action Pack Categories and Events
- Logging Out, Events and Templates with Actio...
- Action Pack Sessions and Architecture
- More on Action Pack Partial Templates
- Action Pack Partial Templates
- Displaying Error Messages with the Action Pa...
- Action Pack Request Parameters
- Creating an Action Pack Registration Form

Watch our Tech Videos 
Dev Articles Forums 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us 
Weekly Newsletter
 
Developer Updates  
Free Website Content 
Contact Us 
Site Map 
Privacy Policy 
Support 

Developer Shed Affiliates

 




© 2003-2018 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap
Popular Web Development Topics
All Web Development Tutorials