http://developer.apple.com/tools/deployonrailsleopard.html
First we have go for Software Configuration management.(SCM)
Ex. SVN, but i will use git here
It can be installed using
$ gem install git
or
$ sudo apt-get install git-core git-doc
Create the git repository
$ mkdir -p ~/git/app.git
- where app is the ruby application name
$ cd ~/git/app.git
$ git --bare init
Initialized empty Git repository in /home/kr/REPOSITORY/git/mum.git/
The directories are created here.
$ ls -l
total 32drwxr-xr-x 2 kr localuser 4096 2010-05-20 09:30 branches/
drwxr-xr-x 2 kr localuser 4096 2010-05-20 09:30 hooks/
drwxr-xr-x 2 kr localuser 4096 2010-05-20 09:30 info/
drwxr-xr-x 4 kr localuser 4096 2010-05-20 09:30 objects/
drwxr-xr-x 4 kr localuser 4096 2010-05-20 09:30 refs/
-rw-r--r-- 1 kr localuser 66 2010-05-20 09:30 config
-rw-r--r-- 1 kr localuser 73 2010-05-20 09:30 description
-rw-r--r-- 1 kr localuser 23 2010-05-20 09:30 HEAD
To setup the ssh key on the server
$ test -e ~/.ssh/id_dsa.pub || ssh-keygen -t dsa
Generating public/private dsa key pair.
Enter file in which to save the key (/home/kr/.ssh/id_dsa):
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /home/kr/.ssh/id_dsa.
Your public key has been saved in /home/kr/.ssh/id_dsa.pub.
The key fingerprint is:
so:me:..:fi:ng:er:..:pr:in:t. kr@BIOINFO
The key's randomart image is:
+--[ DSA 1024]----+
| .. |
| o. |
| ... |
| .. . |
|. .o+ . S |
|.+.+o. o |
|o.. E.= |
|. os.. |
| o+o. |
+-----------------+
$ cat ~/.ssh/id_dsa.pub >> ~/.ssh/authorized_keys2
Generating public/private dsa key pair.
Enter file in which to save the key (/home/kr/.ssh/id_dsa):
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /home/kr/.ssh/id_dsa.
Your public key has been saved in /home/kr/.ssh/id_dsa.pub.
The key fingerprint is:
so:me:..:fi:ng:er:..:pr:in:t. kr@BIOINFO
The key's randomart image is:
+--[ DSA 1024]----+
| .. |
| o. |
| ... |
| .. . |
|. .o+ . S |
|.+.+o. o |
|o.. E.= |
|. os.. |
| o+o. |
+-----------------+
$ cat ~/.ssh/id_dsa.pub >> ~/.ssh/authorized_keys2
Setup git subversion
- in the Ruby application directory eg. mum
$ vim .gitignore
db/*.sqlite3
log/*.log
tmp/**/*
log/*.log
tmp/**/*
Now commit everything to the local repository which was generated above
$ git init
Initialized empty Git repository in /home/kr/Public/mum/.git/
Initialized empty Git repository in /home/kr/Public/mum/.git/
$ git add .
$ git commit -m "initial commit"
[master (root-commit) b3dd69e] initial commit
Committer: Kashi Revanna
Your name and email address were configured automatically based
on your username and hostname. Please check that they are accurate.
You can suppress this message by setting them explicitly:
git config --global user.name "Your Name"
git config --global user.email you@example.com
If the identity used for this commit is wrong, you can fix it with:
git commit --amend --author='Your Name'
60 files changed, 9111 insertions(+), 0 deletions(-)
create mode 100644 .gitignore
create mode 100644 README
create mode 100644 Rakefile
create mode 100644 app/controllers/application.rb
create mode 100644 app/controllers/mum_controller.rb
create mode 100644 app/helpers/application_helper.rb
create mode 100644 app/helpers/mum_helper.rb
create mode 100644 app/views/mum/index.rhtml
create mode 100644 config/boot.rb
create mode 100644 config/database.yml
create mode 100644 config/environment.rb
create mode 100644 config/environments/development.rb
create mode 100644 config/environments/production.rb
create mode 100644 config/environments/test.rb
create mode 100644 config/initializers/inflections.rb
create mode 100644 config/initializers/mime_types.rb
create mode 100644 config/initializers/new_rails_defaults.rb
create mode 100644 config/locales/en.yml
create mode 100644 config/routes.rb
create mode 100644 doc/README_FOR_APP
create mode 120000 doc/api
create mode 100644 public/404.html
create mode 100644 public/422.html
create mode 100644 public/500.html
create mode 100755 public/dispatch.cgi
create mode 100755 public/dispatch.fcgi
create mode 100755 public/dispatch.rb
create mode 100644 public/favicon.ico
create mode 100644 public/images/rails.png
create mode 100644 public/index.html
create mode 100644 public/javascripts/application.js
create mode 100644 public/javascripts/controls.js
create mode 100644 public/javascripts/dragdrop.js
create mode 100644 public/javascripts/effects.js
create mode 100644 public/javascripts/prototype.js
create mode 100644 public/robots.txt
create mode 100755 script/about
create mode 100755 script/console
create mode 100755 script/dbconsole
create mode 100755 script/destroy
create mode 100755 script/generate
create mode 100755 script/performance/benchmarker
create mode 100755 script/performance/profiler
create mode 100755 script/performance/request
create mode 100755 script/plugin
create mode 100755 script/process/inspector
create mode 100755 script/process/reaper
create mode 100755 script/process/spawner
create mode 100755 script/runner
create mode 100755 script/server
create mode 100644 test/functional/mum_controller_test.rb
create mode 100644 test/performance/browsing_test.rb
create mode 100644 test/test_helper.rb
create mode 120000 vendor/actionmailer
create mode 120000 vendor/actionpack
create mode 120000 vendor/activemodel
create mode 120000 vendor/activerecord
create mode 120000 vendor/activeresource
create mode 120000 vendor/activesupport
create mode 120000 vendor/rails
create mode 120000 vendor/railties
[master (root-commit) b3dd69e] initial commit
Committer: Kashi Revanna
Your name and email address were configured automatically based
on your username and hostname. Please check that they are accurate.
You can suppress this message by setting them explicitly:
git config --global user.name "Your Name"
git config --global user.email you@example.com
If the identity used for this commit is wrong, you can fix it with:
git commit --amend --author='Your Name
60 files changed, 9111 insertions(+), 0 deletions(-)
create mode 100644 .gitignore
create mode 100644 README
create mode 100644 Rakefile
create mode 100644 app/controllers/application.rb
create mode 100644 app/controllers/mum_controller.rb
create mode 100644 app/helpers/application_helper.rb
create mode 100644 app/helpers/mum_helper.rb
create mode 100644 app/views/mum/index.rhtml
create mode 100644 config/boot.rb
create mode 100644 config/database.yml
create mode 100644 config/environment.rb
create mode 100644 config/environments/development.rb
create mode 100644 config/environments/production.rb
create mode 100644 config/environments/test.rb
create mode 100644 config/initializers/inflections.rb
create mode 100644 config/initializers/mime_types.rb
create mode 100644 config/initializers/new_rails_defaults.rb
create mode 100644 config/locales/en.yml
create mode 100644 config/routes.rb
create mode 100644 doc/README_FOR_APP
create mode 120000 doc/api
create mode 100644 public/404.html
create mode 100644 public/422.html
create mode 100644 public/500.html
create mode 100755 public/dispatch.cgi
create mode 100755 public/dispatch.fcgi
create mode 100755 public/dispatch.rb
create mode 100644 public/favicon.ico
create mode 100644 public/images/rails.png
create mode 100644 public/index.html
create mode 100644 public/javascripts/application.js
create mode 100644 public/javascripts/controls.js
create mode 100644 public/javascripts/dragdrop.js
create mode 100644 public/javascripts/effects.js
create mode 100644 public/javascripts/prototype.js
create mode 100644 public/robots.txt
create mode 100755 script/about
create mode 100755 script/console
create mode 100755 script/dbconsole
create mode 100755 script/destroy
create mode 100755 script/generate
create mode 100755 script/performance/benchmarker
create mode 100755 script/performance/profiler
create mode 100755 script/performance/request
create mode 100755 script/plugin
create mode 100755 script/process/inspector
create mode 100755 script/process/reaper
create mode 100755 script/process/spawner
create mode 100755 script/runner
create mode 100755 script/server
create mode 100644 test/functional/mum_controller_test.rb
create mode 100644 test/performance/browsing_test.rb
create mode 100644 test/test_helper.rb
create mode 120000 vendor/actionmailer
create mode 120000 vendor/actionpack
create mode 120000 vendor/activemodel
create mode 120000 vendor/activerecord
create mode 120000 vendor/activeresource
create mode 120000 vendor/activesupport
create mode 120000 vendor/rails
create mode 120000 vendor/railties
To push all the code to the server
$ git remote add origin ssh://user@hostname/~/REPOSITORY/git/mum.git
- shouldnt return any error
$ git push origin master
The authenticity of host 'localhost (::1)' can't be established.
RSA key fingerprint is
RSA key fingerprint is
so:me:..:fi:ng:er:..:pr:in:t.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added 'localhost' (RSA) to the list of known hosts.
Counting objects: 82, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (64/64), done.
Writing objects: 100% (82/82), 82.79 KiB, done.
Total 82 (delta 14), reused 0 (delta 0)
To ssh://localhost/~/REPOSITORY/git/mum.git
* [new branch] master -> master
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added 'localhost' (RSA) to the list of known hosts.
Counting objects: 82, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (64/64), done.
Writing objects: 100% (82/82), 82.79 KiB, done.
Total 82 (delta 14), reused 0 (delta 0)
To ssh://localhost/~/REPOSITORY/git/mum.git
* [new branch] master -> master
Check if this gem is already installed
$ gem list -d capistrano
If not found, install it
$ gem install capistrano
Check by typing
$ cap
- mine gave error saying it is not found, so
$ sudo apt-get install capistrano
Check again
$ cap
- it should give a list of options.
Steps
$ capify .
[add] writing `./Capfile'
[add] writing `./config/deploy.rb'
[done] capified!
More notes on Capistrano
Edit the config/deploy.rb
my file
## Some important information
set :user, "kr"
set :domain, "localhost"
set :application, "mum"
## file paths
set :repository, "#{user}@#{domain}:/home/../git/#{application}.git"
# If you aren't deploying to /u/apps/#{application} on the target
# servers (which is the default), you can specify the actual location
# via the :deploy_to variable:
# set :deploy_to, "/var/www/#{application}"
set :deploy_to, "/home/#{user}/Public/#{application}"
# If you aren't using Subversion to manage your source code, specify
# your SCM below:
# set :scm, :subversion
set :scm, "git"
set :branch, "master"
set :scm_verbose, true
set :use_sudo, false
## task that causes Passenger to initiate a restart
namespace :deploy do
task :restart do
run "touch #{current_path}/tmp/restart.txt"
end
end
role :app, "localhost"
role :web, "localhost"
role :db, "localhost", :primary => true
set :user, "kr"
set :domain, "localhost"
set :application, "mum"
## file paths
set :repository, "#{user}@#{domain}:/home/../git/#{application}.git"
# If you aren't deploying to /u/apps/#{application} on the target
# servers (which is the default), you can specify the actual location
# via the :deploy_to variable:
# set :deploy_to, "/var/www/#{application}"
set :deploy_to, "/home/#{user}/Public/#{application}"
# If you aren't using Subversion to manage your source code, specify
# your SCM below:
# set :scm, :subversion
set :scm, "git"
set :branch, "master"
set :scm_verbose, true
set :use_sudo, false
## task that causes Passenger to initiate a restart
namespace :deploy do
task :restart do
run "touch #{current_path}/tmp/restart.txt"
end
end
role :app, "localhost"
role :web, "localhost"
role :db, "localhost", :primary => true
This is how you deploy the server using cap
$ cap deploy:setup
* executing `deploy:setup'
* executing "mkdir -p
* executing `deploy:setup'
* executing "mkdir -p
/home/kr/Public/mum
/home/kr/Public/mum/releases
/home/kr/Public/mum/shared
/home/kr/Public/mum/shared/system
/home/kr/Public/mum/shared/log
/home/kr/Public/mum/shared/pids
&& chmod g+w
/home/kr/Public/mum
/home/kr/Public/mum/releases
/home/kr/Public/mum/shared
/home/kr/Public/mum/shared/system
/home/kr/Public/mum/shared/log
/home/kr/Public/mum/shared/pids"
servers: ["localhost"]
[localhost] executing command
command finished
servers: ["localhost"]
[localhost] executing command
command finished
$ cap deploy:check
* executing `deploy:check'
* executing "test -d /home/krevanna/Public/mum/releases"
servers: ["localhost"]
[localhost] executing command
command finished
* executing "test -w /home/krevanna/Public/mum"
servers: ["localhost"]
[localhost] executing command
command finished
* executing "test -w /home/krevanna/Public/mum/releases"
servers: ["localhost"]
[localhost] executing command
command finished
* executing "which git"
servers: ["localhost"]
[localhost] executing command
command finished
You appear to have all necessary dependencies installed
* executing `deploy:check'
* executing "test -d /home/krevanna/Public/mum/releases"
servers: ["localhost"]
[localhost] executing command
command finished
* executing "test -w /home/krevanna/Public/mum"
servers: ["localhost"]
[localhost] executing command
command finished
* executing "test -w /home/krevanna/Public/mum/releases"
servers: ["localhost"]
[localhost] executing command
command finished
* executing "which git"
servers: ["localhost"]
[localhost] executing command
command finished
You appear to have all necessary dependencies installed
$ cap deploy:migrations
$ cap deploy
- It shouldnt give errors
Also modify the Apache virtual host as below
From the web-browser, the url is localhost/mum
ServerAdmin webmaster@localhost
ServerName localhost
DocumentRoot /home/kr/Public/mum/public
Options Indexes FollowSymLinks MultiViews
AllowOverride None
Order allow,deny
allow from all
This is very educational guide on passenger setup
http://www.modrails.com/documentation/Users%20guide%20Apache.html
Also modify the Apache virtual host as below
From the web-browser, the url is localhost/mum
ServerAdmin webmaster@localhost
ServerName localhost
DocumentRoot /home/kr/Public/mum/public
Options Indexes FollowSymLinks MultiViews
AllowOverride None
Order allow,deny
allow from all
This is very educational guide on passenger setup
http://www.modrails.com/documentation/Users%20guide%20Apache.html
More notes on Capistrano
http://www.capify.org/index.php/Capistrano
No comments:
Post a Comment