Install Apache Passenger for Ruby

A small note on how to install Apache passenger on CentOS to work with Ruby. I assume you have the following packages installed:

  • ruby-mysql
  • rubygems
  • ruby-libs
  • ruby-irb
  • ruby

Ruby Passenger is being installed like this:

gem install passenger --version 3.0.12

Optionally the version can be removed. Then the latest available version of the package will be installed.

If you don’t have devel packages installed the gem installer will pop out with the following error:

mkmf.rb can\'t find header files for ruby ​​at /usr/lib/ruby/ruby.h

We do:

yum -y install gcc mysql-devel ruby-devel

Let’s go back one step.

To install the Apache module, run the following command:

passenger-install-apache2-module

At the very beginning, it checks whether the necessary libraries are present in the system. As a result, you get the following message: Screenshot from 2014-05-07 10:11:29

Press Enter and get the expected fixes: Screenshot from 2014-05-07 10:11:42

Install the missing packages:

yum -y install gcc-c++ curl-devel zlib-devel httpd-devel apr-devel apr-util-devel

We start again:

passenger-install-apache2-module

At the end we get the following message: Screenshot from 2014-05-07 10:15:03

Now we need to create a file /etc/httpd/conf.d/ruby-passenger.conf with the following contexts:

LoadModule passenger_module /usr/lib/ruby/gems/1.8/gems/passenger-3.0.12/ext/apache2/mod_passenger.so
PassengerRoot /usr/lib/ruby/gems/1.8/gems/passenger-3.0.12
PassengerRuby /usr/bin/ruby