Skip to content →

How To Install the Latest Ruby with Rails & LSAPI & OpenLiteSpeed

Ruby is a popular web programming language that is used for a variety of things while Ruby on Rails is a popular web programming framework that is used to create websites.

In this tutorial we will be installing both and demonstrating how to link them to OpenLiteSpeed. This tutorial assumes you followed the Installation and Configuration of OpenLiteSpeed with PHP, MariaDB, LetsEncrypt SSL, PHPMyAdmin, and NinjaFirewall on Debian 10 Buster.

We use GBEnv here as the current version of Ruby on Debian 10 (2.5.5) is below the minimum required version for some applications

sudo apt install dh-autoreconf autoconf bison build-essential libssl-dev libyaml-dev libreadline-dev zlib1g-dev libncurses5-dev libffi-dev libgdbm-dev curl git
git clone https://github.com/rbenv/rbenv.git /var/lib/rbenv
git clone https://github.com/rbenv/ruby-build.git /var/lib/rbenv/plugins/ruby-build

Lets add that path to the profile path and the sudoers path

nano /etc/profile

Add the following line before export PATH

PATH=$PATH:"/var/lib/rbenv/bin"

then

visudo

add the following to the end of secure_path (inside the double-quotes):

:/var/lib/rbenv/bin:/var/lib/rbenv/shims/

Now lets add it to the bashrc files, append the following lines to the TOP of the bashrc file

sudo nano /etc/bash.bashrc
export RBENV_ROOT=/var/lib/rbenv
eval "$(rbenv init -)"\

Make rbenv

cd /var/lib/rbenv/ && src/configure && make -C src

and reboot the system to ensure it applies to every user

sudo reboot

We need to initialize rbenv and check that it has been installed properly

rbenv init
curl -fsSL https://github.com/rbenv/rbenv-installer/raw/master/bin/rbenv-doctor | bash

Finally we can install the latest ruby

rbenv install $(rbenv install -l | grep -v - | tail -1)
rbenv global $(rbenv install -l | grep -v - | tail -1)

Now we have to install git and some ruby gems

sudo gem install rubygems-update
sudo gem install rack
sudo gem install ruby-lsapi
sudo gem install bundler
sudo gem install rails

Time to test it out, Navigate to VHost Configuration in the OpenLiteSpeed Web Console

First we’ll need to enable SuExec in order to run ruby apps with rack later on, navigate to Basic->Security and match the settings below

Under Context, create a new Context and fill in the following details, and save

Now to make the directory (remember to replace VHOSTDIRECTORY with your VHOST’s directory) and the sample application

mkdir /var/www/VHOSTDIRECTORY/html2
nano /var/www/VHOSTDIRECTORY/html2/config.ru

Paste the following in for your sample application

app = proc do |env|
message = "It works!\n"
version = "Ruby %s\n" % RUBY_VERSION
response = [message, version].join("\n")
[200, {"Content-Type" => "text/plain"}, [response]]
end
run app

Then set the permissions

chown -R lsadm:lsadm /var/www/VHOSTDIRECTORY/html2

Now refresh your OpenLiteSpeed server configuration, and head over to your configured VHOST Domain

If you see something like this; congratulations you’re finished

Published in Uncategorized

Comments

Leave a Reply

Your email address will not be published.