DEV Community

Rıdvan Tülemen for OpenLAB

Posted on

Set Up Ruby on Rails Server on Ubuntu Server 20.04

Installation and running processes for the Rails Server we have created for the Yusufreis are as described below.

Downloading Files

Download the Server's files at first.

git clone https://github.com/starbuckr/railsserver
Enter fullscreen mode Exit fullscreen mode

Then, go to the directory where our project is located and install necessary packages.

cd railsserver
sudo apt install ruby ruby-dev ruby-bundler nodejs npm libsqlite3-dev zlib1-dev
sudo npm install yarn -g
yarn install --check-files
Enter fullscreen mode Exit fullscreen mode

Configuring Rails Server's Settings

If the Ruby version you are currently using is not 2.5.5, you need to change the ruby ​​'2.5.5' line in the Gemfile. For example, if your Ruby version is 2.7.0 we need to edit it as this.

ruby '2.7.0'
Enter fullscreen mode Exit fullscreen mode

After installing packages, configure Gem and database settings.

sudo bundle install
rails db:migrate
Enter fullscreen mode Exit fullscreen mode

Running The Server

In order to run the server, use rails server or rails s command.

rails s
Enter fullscreen mode Exit fullscreen mode

If you want to connect the server from other local machines, you need to change running ip address.

rails s -b 0.0.0.0
Enter fullscreen mode Exit fullscreen mode

You can then access this server from any device connected to that network. For example, if the ip address of our Ubuntu Server machine is 192.168.1.56, you can access the server by entering the address 192.168.1.56:3000 in your browser.

Latest comments (0)