Installing Ruby on Rails (RoR) on a VPS server can differ slightly depending on your server’s operating system. Here are the general steps for installing it on a Ubuntu-based VPS server:
1. Update System Packages: Before you start, it’s a good practice to update all system packages.
```
sudo apt-get update
sudo apt-get upgrade
```
1. Install Node.js: Rails requires Node.js to manage the JavaScript assets. Install it by using the following command:
```
sudo apt-get install -y nodejs
```
1. Install Yarn: Another JS package Manager. Install it using:
```
curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | sudo apt-key add -
echo “deb https://dl.yarnpkg.com/debian/ stable main” | sudo tee /etc/apt/sources.list.d/yarn.list
sudo apt-get update
sudo apt-get install yarn
```
1. Install Ruby: There are various ways to install Ruby. Here, we will use RVM (Ruby Version Manager) to manage Ruby installations.
```
sudo apt-get install curl gpg
\curl -sSL https://get.rvm.io | bash -s stable
source ~/.rvm/scripts/rvm
```
To install Ruby, use the following command:
```
rvm install 3.0.2 (or whatever the latest version of Ruby is)
rvm use 3.0.2 —default
```
To check ruby was installed successfully, use:
```
ruby -v
```
You should see something like `ruby 3.0.2p107 (2021-07-07 revision 0db68f0233) [x86_64-linux]`.
1. Install SQLite3:
```
sudo apt-get install libsqlite3-dev
```
1. Install Rails
Lastly, you can install Rails. It can simply be installed with a single command:
```
gem install rails
```
To check rails was installed successfully, use:
```
rails -v
```
You should see something like `Rails 6.1.4`.
That’s it you have installed Ruby on Rails on your VPS server.