Build Ruby on Rails Environment _ruby topic on Aliyun (Aliyun) server

Source: Internet
Author: User
Tags git clone ruby on rails aliyun

1, Aliyun a key to install the Web-wide environment

Download one-click to install Web full-environment Sh.zip compression pack
Upload to the server, decompression, execute the script, detailed steps described here

$ mv sh.zip/home/tmp/& cd/home/tmp
$ unzip sh.zip
$ chmod-r 777 Sh & cd SH
# arbitrary selection of a method to execute a script
# method One
$./install.sh
# Method Two
$/install_nginx_xxx.sh
$./install_mysql_xxx.sh

2, install RVM and the specified ruby version

Install RVM with the specified ruby version

$ curl-l Https://get.rvm.io | Bash-s stable--ruby=1.9.3
# Note When the installation is complete, follow the prompts to execute the source command

To see if the installation was successful

$ ruby-v
Ruby 1.9.3p448 (2013-06-27 revision 41675) [I686-linux]
$ gem-v
2.1.9

Change gem source to increase gem download speed

$ gem source-r https://rubygems.org/$ gem source-a http://ruby.taobao.org

3, install Git, compile JavaScript runtime environment Node.js

Installing the Git tool

$ yum Install git

Compiling node.js (JavaScript runtime Environment)

$ git clone https://github.com/joyent/node.git
$ cd node
$./configure && make && make Install
    #如果无法编译, say name need to call Python upgrade to 2.6 or 2.7
#如果缺少bz2, need to yum install Bzip2-devel, recompile python

Clone your project.

$ git clone path/to/your/project.git
# Installation project Specifies GEM package
$ cd path/to/your/project
$ bundle Install

4. Configure unicorn files and run production environment

View the Unicorn Configuration instance config/unicorn.rb

Start Unicron production environment

$ unicorn_rails-c config/unicorn.rb-e production-d

Close the Unicorn process

$ kill-9 $ (cat tmp/pids/unicorn.pid)

5. Configure Nginx Virtual Host

Add Nginx Virtual Host Configuration

$ vim/path/to/your/nginx/vhosts/xxxx.conf

Configuration content (replace Chinese characters with corresponding valid content):

Upstream Unicorn_server
{
 Server UNIX: Project root directory/tmp/sockets/unicorn.sock fail_timeout=0;
}

Server 
{
 listen    ;
 server_name domain name;
 Root/public;
 Location/ 
 {
  proxy_redirect off;
  Proxy_set_header Host $host;
  Proxy_set_header x-forwarded-host $host;
  Proxy_set_header x-forwarded-server $host;
  Proxy_set_header x-real-ip $remote _addr;
  Proxy_set_header x-forwarded-for $proxy _add_x_forwarded_for;
  Proxy_buffering on;
  if (!-f $request _filename) {
    proxy_pass http://unicorn_server;
    break;
  }
 }

 Location ~ ^/(assets)/ 
 {
   expires max;
   Add_header Cache-control public;
 }



Friendly Tips

Low memory server add Memory release task

$ vim/etc/crontab

Add the following on the last line (free memory 1 o'clock in the morning every day):

 
 

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.