Skip to content

Instantly share code, notes, and snippets.

@caok
Last active September 20, 2016 02:51
Show Gist options
  • Save caok/4083224 to your computer and use it in GitHub Desktop.
Save caok/4083224 to your computer and use it in GitHub Desktop.
Jruby商业应用环境构筑

Jruby商业应用环境构筑

配置jruby环境

更新源

sudo apt-get update

安装系统包

sudo apt-get -y install git-core curl zsh exuberant-ctags vim autoconf automake openssl \
  build-essential libc6-dev libreadline6 libreadline6-dev zlib1g zlib1g-dev libssl-dev libyaml-dev \
  mysql-server libmysqlclient-dev libsqlite3-0 libsqlite3-dev sqlite3 \
  ncurses-dev libtool bison libxslt1-dev libxml2-dev libqt4-dev

安装ruby环境管理工具rbenv

curl https://raw.github.com/fesplugas/rbenv-installer/master/bin/rbenv-installer | bash
rbenv bootstrap-ubuntu-12-04

安装ruby

rbenv install 1.9.3-p392
rbenv install jruby-1.6.7.2

生成MYSQL数据库

mysql -h HOSTNAME -u USERNAME -p
create database DATABASE_NAME default character set utf8;

切换jruby环境

export RBENV_VERSION=jruby-1.6.7.2
gem list

确认安装 rake, bundler, kirk

gem update --system
gem install bundler rake kirk
rbenv rehash

配置/etc/init.d/kirk启动文件

kirk

设置为可执行

sudo chmod +x /etc/init.d/kirk

设置开机自启动

sudo update-rc.d kirk defaults

配置/etc/kirkfile文件

kirkfile

配置apache2

安装apache2

sudo apt-get install apache2
sudo a2enmod rewrite proxy_http proxy_balancer
sudo vi /etc/apache2/sites-available/rails

该内容参考 rails-for-apache

sudo a2dissite default #无效默认配置
sudo a2ensite rails #有效rails
sudo service apache2 reload

分布代码

查看rails的uid,gid

id rails

挂载,切换到代码目录下

cd 
mkdir usb
sudo mount /dev/sdb1 usb -o uid=1000,gid=1000
cd usb/

使用ruby-1.9.3环境

unset RBENV_VERSION
rbenv local 1.9.3-p392

确认安装部署工具capistrano,确认config/deploy.rb存在

bundle
rbenv rehash

配置环境变量

export DEPLOY_SERVER=localhost
export DEPLOY_USER=rails
export REPO=/home/rails//.git

从服务器下载时 REPO=[email protected]:app.git 从USB下载时 REPO=/path/to/project/dir/.git

在/u/apps/生成目录结构(只在第一次部署时需要)

cap deploy:setup

更新代码有关命令需要在ruby-1.9.3环境下运行 *jruby 运行 rake assets:precompile 预编译sass,scss文件时挂起

更新代码并冷启动(适用于服务没有启动)

cap deploy:cold

初始数据库数据的生成

cap deploy:seed

更新代码并热启动(使用与服务正在运行)

cap deploy

更新代码,数据库并热启动(使用与服务正在运行)

cap deploy:migrations

版本升级出错,返回上一版本

cap deploy:rollback

更多命令查看

cap -T
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment