After installing PHP, I decided to install Ruby. However, The latest version of Ruby is 1.8.5-5.el5_4.8, which is to say, not 1.8.6
Here’s a link to installing Ruby Enterprise (from the makers of Phusion Passenger, the mod_rails plugin)
http://www.floydprice.com/2008/08/installing-ruby-enterprise-edition-on-centos-52/
I decided to install the latest official Ruby 1.8.6 (p-399 dated 2/4/2010) from source:
wget ftp://ftp.ruby-lang.org//pub/ruby/1.8/ruby-1.8.6-p399.zip unzip ruby-1.8.6-p399.zip cd ruby-1.8.6-p399 ./configure make make install
This installs to /usr/local/bin/ruby , if you want installed to /usr/bin/ruby you can specify
./configure --prefix=/usr
or just create symlinks:
ln -s /usr/local/bin/ruby /usr/bin/ruby ln -s /usr/local/bin/erb /usr/bin/erb ln -s /usr/local/bin/irb /usr/bin/irb ln -s /usr/local/bin/ri /usr/bin/ri ln -s /usr/local/bin/rdoc /usr/bin/rdoc ln -s /usr/local/bin/testrb /usr/bin/testrb ln -s /usr/local/lib/ruby /usr/lib/ruby ln -s /usr/local/lib/libruby-static.a /usr/lib/libruby-static.a
then install rubygems
wget http://rubyforge.org/frs/download.php/60718/rubygems-1.3.5.tgz tar -xvzf rubygems-1.3.5.tgzcd rubygems-1.3.5ruby setup.rb gem install --system ERROR: While executing gem ... (OptionParser::InvalidOption) invalid option: --system
I don’t know what this problem is, but I did
gem update --system
and got
Nothing to update
So I installed rails
gem install rails -v 2.1.2
I got rake 0.8.7, so I’m happy
Then I installed mod_rails, following the instructions from
http://www.modrails.com/install.html
gem install passenger passenger-install-apache2-module
Then I created /etc/httpd/conf.d/rails.conf
LoadModule passenger_module /usr/local/lib/ruby/gems/1.8/gems/passenger-2.2.9/ext/apache2/mod_passenger.so PassengerRoot /usr/local/lib/ruby/gems/1.8/gems/passenger-2.2.9 PassengerRuby /usr/local/bin/ruby
Then I create a rails project with a vhost as described in the passenger installer
<VirtualHost *:80> ServerName modrails.centos.vm DocumentRoot /var/www/vhosts/modrails/public # <-- be sure to point to 'public'! <Directory /var/www/vhosts/modrails/public> AllowOverride all # <-- relax Apache security settings Options -MultiViews # <-- MultiViews must be turned off </Directory> </VirtualHost>
(note the comments needed moved to their own line)
Create a vhosts director under /etc/httpd/vhosts
mkdir /etc/httpd/vhosts
Add the following line to /etc/httpd/conf/httpd.conf
Include vhosts/*.conf
add the new hostname to /etc/hosts
192.168.41.128 modrails.centos.vm
And finally, create the project:
mkdir /var/www/vhosts cd /var/www/vhosts rails modrails
Only, I get this message at http://modrails.centos.vm/
You’re riding Ruby on Rails!
About your application’s environment
The page you were looking for doesn't exist (404)The page you were looking for doesn't exist.
You may have mistyped the address or the page may have moved.
That might be a mod_rails thing, since it looks like it’s running in Production mode.
I force it to dev by editing config/environment.rb and adding this line:
ENV['RAILS_ENV'] = 'development'
but that doesn’t work. Specifying in the vhost conf:
RailsEnv development
gives a different error:
MissingSourceFile in Rails/infoController#properties
no such file to load -- sqlite3
RAILS_ROOT: /var/www/vhosts/modrailstest
/usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `gem_original_require'
/usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `require'
...
/usr/local/lib/ruby/gems/1.8/gems/passenger-2.2.9/lib/phusion_passenger/abstract_server.rb:196:in `start_synchronously'
/usr/local/lib/ruby/gems/1.8/gems/passenger-2.2.9/bin/passenger-spawn-server:61
This error occurred while loading the following files:
sqlite3
Request
Parameters:
None
--- flash: !map:ActionController::Flash::FlashHash {}
Response
Headers:
{"X-Powered-By"=>"Phusion Passenger (mod_rails/mod_rack) 2.2.9", "cookie"=>[], "Cache-Control"=>"no-cache"}
So I installed the sqlite gem:
gem install sqlite3
and now I get:
NameError in Rails/infoController#properties
uninitialized constant Encoding
RAILS_ROOT: /var/www/vhosts/modrailstest
/usr/local/lib/ruby/gems/1.8/gems/activesupport-2.1.2/lib/active_support/dependencies.rb:279:in `load_missing_constant' /usr/local/lib/ruby/gems/1.8/gems/activesupport-2.1.2/lib/active_support/dependencies.rb:468:in `const_missing'
/usr/local/lib/ruby/gems/1.8/gems/sqlite3-0.0.8/lib/sqlite3/encoding.rb:9:in `find'... /usr/local/lib/ruby/gems/1.8/gems/passenger-2.2.9/lib/phusion_passenger/abstract_server.rb:196:in `start_synchronously' /usr/local/lib/ruby/gems/1.8/gems/passenger-2.2.9/bin/passenger-spawn-server:61
Request
Parameters:
None
--- flash: !map:ActionController::Flash::FlashHash {}
Response
Headers:
{"X-Powered-By"=>"Phusion Passenger (mod_rails/mod_rack) 2.2.9", "cookie"=>[], "Cache-Control"=>"no-cache"}
Git isn’t available on CentOS 5.2 either, but a Git yum package for Fedora is available from the EPEL extras, which can be installed with:
rpm -Uvh http://download.fedora.redhat.com/pub/epel/5/i386/epel-release-5-3.noarch.rpm yum install git