You can skip this on Centos, but for RHEL you need to log into RHN or your Satellite server and enable the optional server repo for your machine (required for ruby-devel and rubygems).
Install the required development packages.
yum install gcc gcc-c++ make curl-devel openssl-devel zlib-devel httpd-devel apr-devel apr-util-devel sqlite-devel
Install ruby, ruby-devel, and rubygems:
yum install ruby ruby-devel rubygems
Next, use gems to install Rails and Passenger. (Note this takes a while.)
gem install rails passenger
Build the Passenger apache module by running:
passenger-install-apache2-module
That will also give you some relevant instructions on how to configure Apache. Now let's create a test application.
cd /var/www/htmlEdit Gemfile and add:
rails new railstest
cd railstest
Run bundle install to install therubyracer javascript engine (takes a minute or two)gem 'therubyracer'
bundle install
Generate our hello world controller:
rails generate controller hello
Edit config/routes.rb and uncomment the next to last line
match ':controller(/:action(/:id(.:format)))'Edit app/views/hello/index.html.erb add some hello world text.
At this point you can test the application to make sure it works with the default rails server. Run rails server and open http://hostaddress:3000/hello and you should see your hello world text. Kill this and proceed with your apache configuration.
This assumes you have a default httpd install. Change this accordingly if you already have other vhosts configured. (Note the RailsEnv option, you'll need to set this accordingly in the future)
Add the following to /etc/httpd/conf/httpd.conf
LoadModule passenger_module /usr/lib/ruby/gems/1.8/gems/passenger-3.0.9/ext/apache2/mod_passenger.soRestart apache, browse to http://hostaddress/hello and you should see your hello world text!
PassengerRoot /usr/lib/ruby/gems/1.8/gems/passenger-3.0.9
PassengerRuby /usr/bin/ruby
<VirtualHost *:80>
DocumentRoot /var/www/html/railstest/public
<Directory /var/www/html/railstest/public>
AllowOverride All
Options -MultiViews
RailsEnv development
</Directory>
</VirtualHost>
1 comments:
Thanks for the guide, it works on CentOS 6.
2 fix:
I had to remove one of the 2 versions of rack that where installed:
gem uninstall rack --version 1.4.0
And I had to create the db/development.sqlite3 base with the command:
rake db:create
Post a Comment