« Backblaze B2 Data Corruption Bug | Deleting built-in apps from Windows 10 » |
Installing Ruby 2.7 + Passenger with Apache on Centos 7
Wednesday, April 5, 2023
CentOS 7 comes with Ruby 2.0, which was released in 2013 and has been deprecated since 2016. (Even CentOS/AlmaLinux 8’s core repos only have Ruby 2.5, which is also outdated, but at least they have dnf
streams which make changing the version much easier.) Here is a quick guide to installing Ruby 2.7 on CentOS 7 and getting it working with Apache + Passenger.
First, install/enable the SCL, whose repo definition is provided by the default extras
repo, then install Ruby from it:
# yum install centos-release-scl # yum install rh-ruby27
At this point, Ruby 2.7 is installed, and if you want to run it locally (e.g. to run bundle
etc), you can do so by enabling the SCL and spawning a shell:
$ scl enable rh-ruby27 bash # or other preferred shell $ bundle install ... # or whatever other Ruby commands
Next, install Passenger by following the official guide. If you already have EPEL enabled, then it is likely you only need to install the Passenger repo and then install the Apache module:
# curl --fail -sSLo /etc/yum.repos.d/passenger.repo \ https://oss-binaries.phusionpassenger.com/yum/definitions/el-passenger.repo # yum install mod_passenger
At this point you will have two versions of Ruby installed, and Passenger will be using the wrong one (v2.0) by default. To get it to point to Ruby 2.7, edit /etc/sysconfig/httpd
and add this line so that Apache knows about the right library path:
LD_LIBRARY_PATH=/opt/rh/rh-ruby27/root/usr/local/lib64:/opt/rh/rh-ruby27/root/usr/lib64
Then edit /etc/httpd/conf.d/passenger.conf
so that it can see this environment variable + points to the right Ruby binary:
PassengerRuby /opt/rh/rh-ruby27/root/usr/bin/ruby PassEnv LD_LIBRARY_PATH
Restart Apache, and that’s all!
Comments
There are no comments.