Run Ruby on Rails on Nginx (1)

Source: Internet
Author: User

BKJIA Translation: Nginx has become the third largest Web server in the world. Among the top 10 Web servers used by domestic websites, Nginx is also among the top. Ruby on Rails is a new generation of Web development languages that have become popular in recent years. Its easy-to-use and agile features have attracted the attention of many Web developers.

This article will guide you to install and configure the Ruby on Rails environment step by step on Ubuntu/Debian, and achieve excellent performance with the Nginx runtime environment.

Install Ruby

 
 
  1. export PATH="${PATH}:/var/lib/gems/1.8/bin/" 
  2. echo 'export PATH="${PATH}:/var/lib/gems/1.8/bin/"' >> /etc/bash.bashrc  
  3. aptitude install ruby rubygems vim-ruby rub y-dev libzlib-ruby   
  4. libyaml-ruby libreadline-ruby libncurses-ruby rdoc ri libcurses-ruby   
  5. libruby libruby-extras libfcgi-ruby build-essential libopenssl-ruby   
  6. libdbm-ruby libdbi-ruby libxml-ruby libxml2-dev 

Install Rails

 
 
  1. gem install -v=2.3.5 rails 

Gem install rails should also work, but 2.3.6-2.3.8 is currently being written) there is a problem. If you want to try the latest version, you can use:

 
 
  1. gem install rails –pre 

Or use RVM. RVM is a command line tool that allows us to install, manage, and use multiple Ruby environments more easily.

Applications

My new application is called myapp.example.com.

 
 
  1. cd /var/www  
  2. rails new myapp.example.com  
  3. cd myapp.example.com 

Thin Server

Thin will become a Ruby Server:

 
 
  1. gem install thin  
  2. thin install  
  3. /usr/sbin/update-rc.d -f thin defaults  
  4. thin config -C /etc/thin/myapp.example.com -c 
  5. /var/www/myapp.example.com --servers 3 -e development # or: -e production for caching, etc 

If you do not like Thin, and Mongrels:

 
 
  1. aptitude install mongrel mongrel-cluster  
  2. mongrel_rails cluster::configure -e development -p 3000 -N 3 -c /var/www/myapp.example.com 
  3. -a 127.0.0.1 # or: -e production for caching, etc  
  4. mkdir /etc/mongrel_cluster  
  5. sudo ln -nfs /var/www/myapp.example.com/config/mongrel_cluster.yml /etc/mongrel_cluster/myapp.example.com.yml  
  6. #sudo ln -nfs /var/www/myapp.example.com/config/mongrel_cluster.yml 
  7. /etc/mongrel-cluster/sites-enabled/myapp.example.com.yml 

Install Nginx

Nginx will act as a Web server, and the Ruby request sent by the proxy to Thin runs on port-. Run the following command to install Nginx:

 
 
  1. aptitude install nginx 


Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.