Published by daryl March 15th, 2008
in Linux, Ruby, Rails, Ubuntu and hetzner.de.
1. Enable the universe repository
sudo vi /etc/apt/sources.list
Find and uncomment the following lines
deb http://us.archive.ubuntu.com/ubuntu dapper universe main restricted universe
deb http://security.ubuntu.com/ubuntu dapper-security universe
2. Install ruby
sudo apt-get install ruby ri rdoc
3. Install rubygems
sudo apt-get install rubygems
4. Install Rails
sudo gem install rails
NOTE: If you get, as I did, an error at this point:
uninitialized constant Gem::GemRunner
then the fix is:
sudo vi /usr/bin/gem
After the line require ‘rubygems’ add the line:
require 'rubygems/gem_runner'
5. Test installation
cd
rails testapp
cd testapp
./server start
Open a browser to http://localhost:3000 and you should see the rails welcome page.
You can remove the testapp with:
cd
rm -fr testapp
Published by daryl October 4th, 2007
in Linux, Ruby and Rails.
Getting Ruby on Rails running on FC 4 with Plesk proved moderately painful so here’s a quick recap of the steps I had to take. This guide assumes you’re some running some combination of FC4/Plesk 8/Apache 2.0 and you have already created a virtual host for the site you want rails enabled.
1. Install GCC
yum install gcc
2. Install Ruby
yum install ruby ruby-libs ruby-mode ruby-rdoc ruby-irb ruby-ri ruby-docs reby-devel
3. Install Gems
mkdir tmp
cd tmp
wget http://rubyforge.org/frs/download.php/20989/rubygems-0.9.4.tgz
tar -xvzf rubygems-0.9.4.tgz
ruby setup.rb
4. If your going to be using MySQL then:
yum install mysql-devel
gem install mysql --with-mysql-config
5. Install Rails
gem install rails --include-dependencies
You should now have a working install of Ruby on Rails. You can test this by creating a test application…
cd ~
rails testapp
cd testapp
ruby script/server
This should start up the WEBrick server on the default port 3000. You can verify this by going to http://localhost:3000 in a browser where you should see the default Rails page.
Changing the default Ruby Port
If, as happened to me, you find that something else is already using the port 3000 you can start the server passing an alternative port:
ruby script/server -p 3003
This should be enough to get a Rails app up and running.
Using Ruby on Rails with Apache 2.0 and mod_proxy
At this pointed I started looking at integration with Apache. Having read various heartbreaking tales telling of doomed attempts to get FastCGI and it’s ilk up and running I decided to work with mod_proxy, which was installed by default on my combination of FC4/Plesk 8/Apache 2.0.
As it’s Plesk you need to create (or change if it’s already there) the vhost.conf file for the domain that you want to be Rails enabled.
cd /var/www/vhosts/<yourdomain>/conf
vi vhost.conf
Press ‘i’ to enter insert mode and add these lines:
<proxy>
Order deny,allow
Allow from all
</proxy>
ProxyPass / http://www.yourdomain.com:3000/
ProxyPassReverse / http://www.yourdomain.com:3000
ProxyPreserveHost on
Remember to change the domain name and port to your settings.Press ‘Esc’ then enter wq! <Return> to exit and save the file.Now apply your vhost changes and restart Apache.
/usr/local/psa/admin/sbin/websrvmng -u --vhost-name=yourdomain.com
/sbin/service httpd restart
Browse to www.your domain.com in a browser and hopefully you should see the Rails page.Not the most straightforward of installs but Ruby and Tracks GTD make it worth the effort 