> ## Documentation Index
> Fetch the complete documentation index at: https://kb.hosting.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Setting up multiple versions of Ruby with the cPanel Ruby Selector

> Learn to set up multiple Ruby versions in cPanel with CloudLinux and the Ruby Selector.

Shared and Reseller Hosting accounts using the cPanel control panel and running CloudLinux offer multiple versions of Ruby. You can set up your account to use one version or several. Instructions for both options are shown in this article.

<Note>
  These instructions apply to servers with the cPanel control panel and Ruby Selector installed. Check for the **Setup Ruby App** icon in the **Software** section of cPanel before proceeding.
</Note>

## Setting up one Ruby version

To set up one Ruby version for use at the command line, follow these steps:

1. Log into your account [using SSH](/docs/using-ssh-secure-shell).

2. See the available Ruby versions by typing the command as shown and viewing the results.

   ```bash theme={null}
   example@example.com [~]# ls /opt/alt | grep ruby
   ruby18/
   ruby19/
   ruby20/
   ruby21/
   ruby22/
   ruby23/
   ruby24/
   ruby25/ 
   ruby26/
   ```

   The two digits on each line in the listing represent the version number, where the actual version number has a dot between the 2 digits. For example, *ruby26* is Ruby version 2.6.

3. Choose a version to use. In this example, we use Ruby 2.6.

4. Create a directory for local gems.Some gems are pre-installed globally on the server, but additional gems must be installed in the user account.The directory *\~ruby/gems* is used here but other values may be used.

   ```bash theme={null}
   example@example.com [~]# mkdir -p ~/ruby/gems
   ```

5. Edit the file *\~/.bash\_profile* and add these lines at the bottom, replacing *ruby26* and *ruby* red with the desired values for your installation:

   ```
   RUBYHOME="/opt/alt/ruby26"
   ORIG_GEM_HOME=$("$RUBYHOME/bin/gem" --config-file "" env GEM_HOME)
   GEM_HOME="$HOME/ruby"
   GEM_PATH="$GEM_HOME:$ORIG_GEM_HOME"
   GEM_SPEC_CACHE="$GEM_HOME/specs"
   PATH="$RUBYHOME/bin:$PATH"
   export RUBYHOME
   export GEM_HOME
   export GEM_PATH
   export GEM_SPEC_CACHE
   export PATH
   ```

6. Update your environment with the following command:

   ```bash theme={null}
   example@example.com [~]# source ~/.bash_profile
   ```

7. Check the installation with this command:

   ```bash theme={null}
   example@example.com [~] ruby -v
   ruby 2.6.1p33 (2019-01-30 revision 66950) [x86_64-linux]
   ```

   The configured Ruby version will now be available each time you log in.

## Setting up multiple Ruby versions with the Ruby Selector

The Ruby Selector makes it possible to use multiple versions of Ruby in your account by creating a virtual environment for each desired version.

To create a virtual environment, follow these steps:

1. Log in to cPanel.
   > 📘 Note
   >
   > If you do not know how to log in to your cPanel account, please see [this article](/docs/accessing-cpanel).

2. On the **Tools** page, in the **Software** section, click **Setup Ruby App**:\
   ![cPanel - Software - Setup Ruby App icon](https://static.hosting.com/kb/kb-cpanel-jupiter-software-setup-ruby-app-icon.png)

3. Click the **Setup Ruby App** icon in the **SOFTWARE** section of cPanel.

4. Select the desired Ruby version from the **Ruby version** listbox.![](https://static.hosting.com/kb/kb-setup-ruby-app-form.png)

5. Enter the desired application name in the **App Directory** text box.

6. Select a domain in the **App Domain/URI** listbox.You must select a domain even if you will not be using Ruby for a website.

7. Optionally, enter a path in the **App Domain/URI** text box.

8. Click the **Setup** button. The application is set up and a new application detail form is added to the page.

   > 🚧 Important
   >
   > The Ruby Selector adds several lines to the domain selected in step X above:
   >
   > ```
   > # DO NOT REMOVE. CLOUDLINUX PASSENGER CONFIGURATION BEGIN
   > PassengerAppRoot "/home/example/myapp"
   > PassengerBaseURI "/"
   > PassengerRuby "/home/pinebrea/rubyvenv/myapp/2.6/bin/ruby"
   > # DO NOT REMOVE. CLOUDLINUX PASSENGER CONFIGURATION END
   > ```
   >
   > If you will not be using Ruby for your website you must remove these lines from the .htaccess file.

To use the new environment follow these steps:

1. Copy the **Command for entering to virtual environment** from the application detail form.![](https://static.hosting.com/kb/kb-setup-ruby-app-application-details.png)

2. Log in to your account using SSH.

3. Paste the **Command for entering to virtual environment** on the command line and press enter. The command prompt will change as shown.

   ```bash theme={null}
   example@example.com [~]# source /home/example/rubyvenv/myapp/2.6/bin/activate
   (myapp:2.6)example@example.com [~]#
   ```

4. Enter the following command to check that the installation is successfull:

   ```bash theme={null}
   (myapp:2.6)example@example.com [~]# ruby -v
   ruby 2.6.1p33 (2019-01-30 revision 66950) [x86_64-linux]
   ```

5. Exit the virtual environment by typing **deactivate** as shown.

   ```bash theme={null}
   (myapp:2.6)example@example.com [~]# deactivate
   example@example.com [~]#
   ```

You can repeat the steps above to configure several versions of Ruby for use in your account.

You must enter the related **Command for entering to virtual environment** each time you want to use a configured version of Ruby.
