Plesk

How to install different Ruby versions on Plesk server?

Question

How to install different Ruby versions on Plesk server?

Answer

Plesk provides its own set of Ruby interpreters which are installed to /opt/plesk/ruby/ directory.

Note: It is possible to check what versions of Ruby are currently installed by running the following command via SSH:
# ls -al /opt/plesk/ruby/
The output of ruby -v command or which ruby command indicates system version of ruby, that is installed in /usr/local/rvm/rubies/ folder path.
To install and make default ruby 2.5.1 on the system execute the command
# rvm install "ruby-2.5.1"​ and then # rvm --default use 2.5.1
Refer to the following forum thread for additional information.

To build a custom version of Ruby with a ruby-build tool apply the steps below. In this example Ruby version 2.4.0-dev is being installed:

  1. Install Ruby Plesk extension
  2. Connect to the Plesk server via SSH
  3. Install the ruby-build tool:

    # mkdir -p "$(rbenv root)"/plugins
    # git clone https://github.com/rbenv/ruby-build.git "$(rbenv root)"/plugins/ru

  4. Install additional packages:
    • On Debian/Ubuntu operating systems run:

      # apt install autoconf bison build-essential libssl-dev libyaml-dev libreadline6-dev zlib1g zlib1g-dev

    • On RedHat/CentOS/CloudLinux operating systems run:

      # yum install autoconf bison build-essential libssl-dev libyaml-dev libreadline6-dev zlib1g zlib1g-dev

  5. Run the following commands to build Ruby:

    # /root/.rbenv/plugins/ru/bin/ruby-build 2.4.0-dev /opt/plesk/ruby/2.4.0-dev/
    # /opt/plesk/ruby/2.4.0-dev/bin/gem install bundler
    # plesk sbin rubymng register 2.4.0-dev /opt/plesk/ruby/2.4.0-dev

  6. Log in to Plesk GUI

  7. Go to Extensions > Ruby and click on Refresh