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
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
Add the following on the last line (free memory 1 o'clock in the morning every day):