HowTo:
Install Subversion, Ruby Gems, and a locally developed Ruby on Rails App on Bluehost
Nota Bena: After much searching, many experiments, and a few tears this is the best way I have found to set the aforementioned things up. I have cited my virtual sources where I had any. Many thanks to the other developers who have struggled before us.
1. Install Subversion
#
# this is how I installed subversion 1.4.3 on my bluehost account
#
mkdir ~/src
# get and make 'apr-0.9.13' (this isn't included in the subversion tarball)
cd ~/src
wget http://apache.ausgamers.com/apr/apr-0.9.13.tar.gz
tar -xzf apr-0.9.13.tar.gz
cd apr-0.9.13
./configure --prefix=$HOME
make
make install
# get and make 'apr-util 0.9.13' (this isn't included in the subversion tarball either)
cd ~/src
wget http://apache.planetmirror.com.au/di...-0.9.13.tar.gz
tar -xzf apr-util-0.9.13.tar.gz
cd apr-util-0.9.13
./configure --prefix=$HOME --with-apr=$HOME
make
make install
# get and make 'subversion-1.4.3'
cd ~/src
wget http://subversion.tigris.org/downloa...n-1.4.3.tar.gz
tar -xzf subversion-1.4.3.tar.gz
cd subversion-1.4.3
./configure --prefix=$HOME --without-berkeley-db --with-zlib --with-ssl
# at this point there's a bit of complaining about berkeley db, let's ignore that...
make
make install
# check it works!
cd
svn --version
# yay!
From: Subversion [Archive] - bluehostforum.com
http://www.bluehostforum.com/archive...php/t-134.html
2. Enable Local Gems
Howto Install your own Gems for Rails
What you need to know:
- path to where you will store your local gems
eg: /home/yourusername/gems
- path to the base gems
eg: /usr/lib/ruby/gems/1.8
What you will do:
- Setup GEM_HOME which is where you will INSTALL new gems and GEM_PATH which is where you will FIND gems.
- Make the gem program, your shell, and rails know about your gems
- Install a gem
- Test to see if its working
How to do it:
1. ssh to your account
$ ssh yourusername@yourdomain.com
2. Make sure you are in YOUR home directory
$ cd ~
3. Find the path you are in
$ pwd
/home/yourusername
4. Find where the base gems are installed
$ gem environment
Rubygems Environment:
- VERSION: 0.8.10 (0.8.10)
- INSTALLATION DIRECTORY: /usr/lib/ruby/gems/1.8
- GEM PATH:
- /usr/lib/ruby/gems/1.8
- REMOTE SOURCES:
- http://gems.rubyforge.org
5. Create a directory to install your local gems
$ mkdir gems
6. Create a .gemrc file in your home directory (~) to declare GEM_PATH and GEM_HOME for the gem program. This is in yaml format. Replace gemhome with the full path to where you will store the gems locally in your account. Replace the gempath with whatever the path is on your machine if its different.
$ vi .gemrc
# add what is below
gemhome: /home/yourusername/gems
gempath:
- /home/yourusername/gems
- /usr/lib/ruby/gems/1.8
7. Verify the environment is changed.
$ gem environment
Rubygems Environment:
- VERSION: 0.8.10 (0.8.10)
- INSTALLATION DIRECTORY: /home/yourusername/gems
- GEM PATH:
- /home/yourusername/gems
- /usr/lib/ruby/gems/1.8
- REMOTE SOURCES:
- http://gems.rubyforge.org
8. Install a gem
$ gem install RedCloth
Attempting local installation of 'RedCloth'
Local gem file not found: RedCloth*.gem
Attempting remote installation of 'RedCloth'
Successfully installed RedCloth-3.0.4
9. Add the GEM_PATH to your Rails envorinments.rb file. Do this on each of your apps that will use the local gems. This will tell Rails where to find your gems. For this example, my rails apps are in the RailsApps directory and I'm modifying the app1 configuration.
You will add the ENV line into the environment.rb file. A good place to put it would be at the top of the file, so you remember you added it.
$ vi ~/RailsApps/app1/config/environment.rb
ENV['GEM_PATH'] = '/home/yourusername/gems:/usr/lib/ruby/gems/1.8'
11. Add to your shell environment. This is assuming you are using bash. The .bash_profile will be read next time you login and do this automatically for you.
$ vi .bash_profile
export GEM_PATH=/home/yourusername/gems:/usr/lib/ruby/gems/1.8
export GEM_HOME=/home/yourusername/gems
Then from the command line
$ export GEM_PATH=/home/yourusername/gems:/usr/lib/ruby/gems/1.8
$ export GEM_HOME=/home/yourusername/gems
Verify it
$ echo $GEM_PATH
$ echo $GEM_HOME
12. Run irb to test. You'll see require_gem 'RedCloth' came back as true and 'NotARealGem' throw an error.
$ irb
irb(main):001:0> require 'rubygems'
=> true
irb(main):002:0> require_gem 'RedCloth'
=> true
irb(main):003:0> puts RedCloth.new("h1. Header 1\n\nparagraph\n\n").to_html
<h1>Header 1</h1>
<p>paragraph</p>
=> nil
irb(main):004:0> require_gem 'NotARealGem'
Gem::LoadError: Could not find RubyGem NotARealGem (> 0.0.0)
from /usr/lib/site_ruby/1.8/rubygems.rb:194:in `report_activate_error'
from /usr/lib/site_ruby/1.8/rubygems.rb:136:in `activate'
from /usr/lib/site_ruby/1.8/rubygems.rb:37:in `require_gem_with_options'
from /usr/lib/site_ruby/1.8/rubygems.rb:31:in `require_gem'
from (irb):4
13. Now test it out in your app too to make sure that Rails picked up that ENV setting.
(from: http://forums.site5.com/showthread.php?t=11954)
3. Update config/environment.rb
#add this line
ENV['GEM_PATH'] = '/home/yourusername/gems:/usr/lib/ruby/gems/1.8'
4. Update the public/dispatch.* files (if you developed locally and FTPed yourapp to the server)
- create a new testapp with the rails command on the host server
- delete the public/dispatch.* files from YourApp
- copy the public/dispatch.* files from testapp to yourapp/public
5. Configure Subversion for Rails
This was originally written by Jake at http://blog.unquiet.net/archives/200...th-subversion/ .. but that site seems not to be showing content properly, so I salvaged this from the Google cache. I also added two new lines to make it remove /tmp folder which is now in Rails.
Just dump this into a file called svn.rake in your lib/tasks folder, and use rake configure_for_svn to sort everything out on your initial check out:
desc "Configure Subversion for Rails"
task :configure_for_svn do
system "svn remove log/*"
system "svn commit -m 'removing all log files from subversion'"
system 'svn propset svn:ignore "*.log" log/'
system "svn update log/"
system "svn commit -m 'Ignoring all files in /log/ ending in .log'"
system 'svn propset svn:ignore "*.db" db/'
system "svn update db/"
system "svn commit -m 'Ignoring all files in /db/ ending in .db'"
system "svn move config/database.yml config/database.example"
system "svn commit -m 'Moving database.yml to database.example to provide a template for anyone who checks out the code'"
system 'svn propset svn:ignore "database.yml" config/'
system "svn update config/"
system "svn commit -m 'Ignoring database.yml'"
system "svn remove tmp/*"
system "svn commit -m 'Removing /tmp/ folder'"
system 'svn propset svn:ignore "*" tmp/'
end
desc "Add new files to subversion"
task :add_new_files do
system "svn status | grep '^\?' | sed -e 's/? *//' | sed -e 's/ /\ /g' | xargs svn add"
end
desc "shortcut for adding new files"
task :add => [ :add_new_files ]
# see also: http://railscasts.com/episodes/36
# and
#http://blog.teksol.info/articles/200...rails-projects
6. Check out yourapp and scream for joy!
I hope this is helpful - it certainly is what it took to get my project off the ground (or at least on the server).


Reply With Quote
