主頁 > 知識庫 > 在阿里云 (aliyun) 服務(wù)器上搭建Ruby On Rails環(huán)境

在阿里云 (aliyun) 服務(wù)器上搭建Ruby On Rails環(huán)境

熱門標(biāo)簽:Win7旗艦版 電話運營中心 客戶服務(wù) 語音系統(tǒng) 百度AI接口 硅谷的囚徒呼叫中心 呼叫中心市場需求 企業(yè)做大做強

1、阿里云的一鍵安裝web全環(huán)境

下載一鍵安裝web全環(huán)境 sh.zip 壓縮包
上傳至服務(wù)器,解壓、執(zhí)行腳本,具體步驟詳見這里

$ mv sh.zip /home/tmp/  cd /home/tmp
$ unzip sh.zip
$ chmod -R 777 sh  cd sh
# 任意選擇一種方法執(zhí)行腳本
# 方法一
$ ./install.sh
# 方法二
$ ./install_nginx_xxx.sh
$ ./install_mysql_xxx.sh

2、安裝RVM與指定的Ruby版本

安裝RVM與指定的Ruby版本

$ curl -L https://get.rvm.io | bash -s stable --ruby=1.9.3
# 注意安裝完成后,根據(jù)提示執(zhí)行source命令

查看是否安裝成功

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

更換 gem source,提高gem下載速度

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

3、安裝git、編譯 javascript 運行時環(huán)境 node.js

安裝git工具

$ yum install git

編譯node.js(javascript運行時環(huán)境)

$ git clone https://github.com/joyent/node.git
$ cd node
$ ./configure  make  make install
#如果無法編譯,說名需要叫python升級到2.6或2.7
#如果缺少bz2,需要yum install bzip2-devel后,重新編譯python

克隆你的項目

$ git clone path/to/your/project.git
# 安裝項目指定gem包
$ cd path/to/your/project
$ bundle install

4、配置unicorn文件并運行生產(chǎn)環(huán)境

查看unicorn配置實例 config/unicorn.rb

啟動unicron生產(chǎn)環(huán)境

$ unicorn_rails -c config/unicorn.rb -E production -D

關(guān)閉unicorn進(jìn)程

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

5、配置nginx虛擬主機

添加nginx虛擬主機配置

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

配置內(nèi)容(將漢字替換成相應(yīng)有效內(nèi)容):

upstream unicorn_server
{
 server unix:項目根目錄/tmp/sockets/unicorn.sock fail_timeout=0;
}

server 
{
 listen    80;
 server_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;
 }
}


友情提示

低內(nèi)存服務(wù)器添加內(nèi)存釋放任務(wù)

$ vim /etc/crontab

在最后一行添加如下內(nèi)容(每天凌晨1點釋放內(nèi)存):

00 1 * * * echo 3 > /proc/sys/vm/drop_caches 

您可能感興趣的文章:
  • 阿里云CentOS7搭建Apache+PHP+MySQL環(huán)境
  • 阿里云go開發(fā)環(huán)境搭建過程

標(biāo)簽:山西 喀什 海南 長沙 山西 濟(jì)南 安康 崇左

巨人網(wǎng)絡(luò)通訊聲明:本文標(biāo)題《在阿里云 (aliyun) 服務(wù)器上搭建Ruby On Rails環(huán)境》,本文關(guān)鍵詞  ;如發(fā)現(xiàn)本文內(nèi)容存在版權(quán)問題,煩請?zhí)峁┫嚓P(guān)信息告之我們,我們將及時溝通與處理。本站內(nèi)容系統(tǒng)采集于網(wǎng)絡(luò),涉及言論、版權(quán)與本站無關(guān)。
  • 相關(guān)文章
  • 收縮
    • 微信客服
    • 微信二維碼
    • 電話咨詢

    • 400-1100-266