1、阿里云的一鍵安裝web全環(huán)境
下載一鍵安裝web全環(huán)境 sh.zip 壓縮包
上傳至服務(wù)器,解壓、執(zhí)行腳本,具體步驟詳見(jiàn)這里
$ 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 運(yùn)行時(shí)環(huán)境 node.js
安裝git工具
編譯node.js(javascript運(yùn)行時(shí)環(huán)境)
$ git clone https://github.com/joyent/node.git
$ cd node
$ ./configure make make install
#如果無(wú)法編譯,說(shuō)名需要叫python升級(jí)到2.6或2.7
#如果缺少bz2,需要yum install bzip2-devel后,重新編譯python
克隆你的項(xiàng)目
$ git clone path/to/your/project.git
# 安裝項(xiàng)目指定gem包
$ cd path/to/your/project
$ bundle install
4、配置unicorn文件并運(yùn)行生產(chǎn)環(huán)境
查看unicorn配置實(shí)例 config/unicorn.rb
啟動(dòng)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虛擬主機(jī)
添加nginx虛擬主機(jī)配置
$ vim /path/to/your/nginx/vhosts/xxxx.conf
配置內(nèi)容(將漢字替換成相應(yīng)有效內(nèi)容):
upstream unicorn_server
{
server unix:項(xiàng)目根目錄/tmp/sockets/unicorn.sock fail_timeout=0;
}
server
{
listen 80;
server_name 域名;
root 項(xiàng)目根目錄/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ù)
在最后一行添加如下內(nèi)容(每天凌晨1點(diǎn)釋放內(nèi)存):
00 1 * * * echo 3 > /proc/sys/vm/drop_caches
您可能感興趣的文章:- 阿里云CentOS7搭建Apache+PHP+MySQL環(huán)境
- 阿里云go開(kāi)發(fā)環(huán)境搭建過(guò)程