We need to install ruby before rails. You may have ruby from the system but it's better to have a specific ruby version for a project. Get rbenv from github.
$ git clone https://github.com/rbenv/rbenv.git ~/.rbenv $ git clone https://github.com/rbenv/ruby-build.git ~/.rbenv/plugins/ruby-build
Set path and initialize it.
$ echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.bashrc $ ~/.rbenv/bin/rbenv init $ source ~/.bashrc
$ rbenv install -l # check which version you can use $ rbenv install 2.7.2 # the latest or previous one $ rbenv global 2.7.2
$ ruby --version # to confirm version $ gem install rails
$ rails new myapp ... follow $ rails server -p 3000 # or 5000 or 8080
Open terminal and click icon next to Port 3000 so that the page is opened.