rails 教程 http://ihower.tw/rails3/
http://railstutorial-china.org/
ruby on rails 的环境搭建 https://www.digitalocean.com/community/articles/how-to-install-ruby-on-rails-on-ubuntu-12-04-lts-precise-pangolin-with-rvm
nginx 的环境搭建与配置
安装启动 nginx 脚本
wget https://raw.github.com/gist/1548664/53f6d7ccb9dfc82a50c95e9f6e2e60dc59e4c2fb/nginx
sudo cp nginx /etc/init.d/
sudo chmod +x /etc/init.d/nginx
sudo update-rc.d nginx defaults
nginx 的配置 server { listen 80; //端口号 server_name localhost;//域名
#charset koi8-r;
#access_log logs/host.access.log main;
location / { root /home/xiaolong/workspace/skynet/public;//项目public的绝对路径 index index.html index.htm; passenger_enabled on; //是否允许 passenger 插件的使用 rails_env development;//指定发布模式,默认为 production,如果为 production 的话就要先 precompile rails assets 下 } error_page 500 502 503 504 /50x.html; location = /50x.html { root html; } }
参考 安装 nginx https://hisea.me/p/rails31-ubuntu-passenger-nginx-quick-deploy
环境配置 http://blog.enjoyrails.com/2009/05/22/195
403 错误解决方法http://ruby-china.org/topics/4523
capistrano 的配置
配置 deploy.rb
require 'rvm/capistrano' # 支持 rvm require 'bundler/capistrano' # 支持自动 bundler set :rvm_autolibs_flag, "read-only" # more info: rvm help autolibs
set :application, "skynet" #应用的名字
set :keep_releases, 10
set :location, "0.0.0.1" #部署的 ip 地址
set :location, "www.netpom.com"
role :web, location # Your HTTP server, Apache/etc
role :app, location # This may be the same as your Web
server
role :db, location, :primary => true # This is where Rails migrations will run
#role :db, "3dtzk.com"
#server details default_run_options[:pty] = true # Must be set for the password prompt set :deploy_to, "/home/xiaolong/skynet.com" #部署在服务器上的地址
set :user, "xiaolong" #ssh 连接服务器的帐号
set :use_sudo, false
set :ssh_options, { :forward_agent => true }
#repo details
set :scm, :git
# Or: accurev
, bzr
, cvs
, darcs
, git
, mercurial
, perforce
, subversion
or none
set :scm_username, "HuberyDu" #github 帐号
set :scm_passphrase, "xxxx" #设置 github ssh 时设置到密码
set :repository, "[email protected]:dreamlx/skynet.git" #项目在 github 上的帐号
set :branch, "master" #github 上具体的分支
set :deploy_via, :remote_cache
#tasks namespace :deploy do task :restart, :roles => :app do run "touch #{current_path}/tmp/restart.txt" end
task :stop, :roles => :app do #do nonthing end
desc "Symlink shared resources on each release - not used" task :symlink_shared, :roles => :app do #run "ln -nfs #{shared_path}/config/database.yml #{release_path}/config/database.yml" end
task :precompile, :roles => :web do
run "cd #{current_path} && #{rake} RAILS_ENV=production assets:precompile"
end
end
after "deploy:update", "deploy:migrate" after "deploy:migrate", "deploy:symlink_shared" after "deploy:migrate", "deploy:precompile"
然后把修改过的内容提交到 git 上 第一次部署 $ cap deploy:setup $ cap deploy:check $ cap deploy:migrations 发布 cap deploy
参考https://github.com/capistrano/capistrano/wiki http://ruby-china.org/topics/6424
学习了近两个星期了,挺喜欢这门语言的