Many beautiful applications and websites are built on the Ruby programming language. and setting up your environment is the first step. This brief tutorial shows students and new users how to set up a Ruby on Rails environment on Ubuntu 16.04 | 18.04 and 18.10. There are many tutorials online that will help you set up your environment. however, this post will make it easy for students and new users who are just learning how to create their own Ruby on Rails environments. These are the packages we’re going to set up.
Ruby version 2.5.3 Rails version 5.2.1 MariaDB
Installing Ruby
To install Ruby and Rails on Ubuntu, you’ll need to install some dependencies. To make that happen, install Node.js and Yarn repositories. This will make installing the dependencies easier. First, install these curl and git packages. Then run the commands below to add Node.js and Yarn repositories and keys to your system. Then install some core packages to get your environment going. When you’re done. continue below: After adding the repositories and installing the necessary packages above, install Ruby with your local profile settings using rbenv. you’ll then use rbenv to install ruby-build. After setting up your local profile, run the commands below to install Ruby version 2.5.3. If a newer version is available, replace the version number with that. Visit this site to find out Ruby’s latest versions. To verify that Ruby is installed, run the commands below: You should see similar lines below: Another package management you’ll want to install is bundler. to do that, run the commands below gem install bundler Now run the command below after installing the bundler.
Install Rails
Now that the Ruby environment is set up, run the commands below to install Rails. Rails can be installed from Node.Js. Run the commands below to install the Node.js repository, then install the Node.js package. Now that Node.js is installed, run the commands below to install Rails. Don’t forget to rehash your rbenv environment installing install new packages. To verify if Rails is installed, run the commands below. You should see something similar to the lines below:
Install MariaDB
Usually, a database server is used for most applications. and MariaDB is a great open-source database server. to install it on Ubuntu, run the commands below: After installing MariaDB, the commands below can be used to stop, start and enable the MariaDB service to always start up when the server boots. Run these on Ubuntu 16.04 LTS Run these on Ubuntu 18.10 and 18.04 LTS Next, run the commands below to secure the database server with a root password if you were not prompted to do so during the installation. When prompted, answer the questions below by following the guide.
Enter current password for root (enter for none): Just press the Enter Set root password? [Y/n]: Y New password: Enter password Re-enter new password: Repeat password Remove anonymous users? [Y/n]: Y Disallow root login remotely? [Y/n]: Y Remove test database and access to it? [Y/n]: Y Reload privilege tables now? [Y/n]: Y
Now that MariaDB is installed, to test whether the database server was successfully installed, run the commands below. type the root password when prompted. If you see a similar screen as shown above, then the server was successfully installed. After that, Ruby and Rails should be installed and your environment ready for you to start building apps based on Ruby and Rails. Conclusion: This post showed you how to install Ruby on Rails on Ubuntu Linux.