Web development is at its best. More and more developers are targeting this area. Even in universities of informatics, it is very common to teach development technologies for the web. In this sense, Ruby, which is a famous and quite popular programming language, has something to contribute too, Ruby on Rails. So, this post is about how to install Ruby on Rails on Debian 9.
Ruby on Rails is a web application development framework that uses Ruby as its programming language. In addition, it is open source and applications are created from the MVC architecture (Model, View, Controller). In short, not only is it free to use, but you can also help make it better.
So, in this post, you will learn to install Ruby on Rails on Debian 9.
Two ways to install it
A great advantage of Ruby on Rails is that it can be installed in two possible ways on Debian 9. As you know Debian 9 is a very safe operating system and for many developers, it is the main option to build their applications.
One of the options is to do it from the APT package manager. It’s quite simple and puts Ruby on Rails at a distance command.
The other option is to do it through RVM (ruby version manager), this way is more complex but we can have access to specific versions.
1. Using APT
Actually, this way of installing Ruby on Rails on Debian 9 is quite simple to do. It all boils down to the execution of the following command.
:~$ su :~# apt install ruby rails
And that’s it.
This form of installation, has a big problem, you will not have a new version of the framework. Depending on many factors this can be either a problem or a big problem. It’s simple, but I don’t recommend it.
2. Install Ruby on Rails using the RVM
In contrast, this method is a little more complicated but believe me it’s better. In the first place, it is necessary to install some dependencies.
:~# apt install build-essential curl nodejs
Next, add the RVM GPG keys.
:~# curl -sSL https://rvm.io/mpapis.asc | gpg2 --import - curl -sSL https://rvm.io/pkuczynski.asc | gpg2 --import -
Then, use curl to download the RVM installation script. With this script, you will install Ruby.
:~# curl -sSL https://get.rvm.io | bash -s stable --ruby
3.- Installing RVMThen, make RVM available for the user.
:~# source /etc/profile.d/rvm.sh
Now, install ruby. So it’ll take a while.
:~# rvm install ruby
After that, check the Ruby version.
:~# ruby -v
Now, install Rails.
:~# gem install rails -v 5.2.1
Using this command we tell gem to install a specific version of Rails. In this case, I chose the latest stable version at the time of writing this post.
3. Start a new project
Now you can start a new project. To do this create the folder where the site will be located. It is important that these commands are not executed by the root user, to avoid permission problems.
:~$ mkdir /home/angelo/example :~$ cd /home/angelo/example
Of course, replace the name and the Path of your project.
Now, create the project. Replace example for your project name.
:~$ rails new example
Note: If you can not use rails command. Just log out and log in again.
Then, run the following command to start creating the project as such.
:~$ rails s
Note: you can run
bundle install command to install all gem missed. After that, run
rails s command again.
Finally, open your web browser and go to
http://IP_SERVER:3000. You will see something like this.
And that’s all.
Ruby on Rails is a widely used framework worldwide. Many of the world’s most famous companies use this framework to design their web applications. Therefore, it is a good idea to learn something about it. Today you learned how to install it on Debian 9.
Please share this post with your friends