{"id":99589,"date":"2023-12-08T04:21:33","date_gmt":"2023-12-08T04:21:33","guid":{"rendered":"\/tutorials\/?p=99589"},"modified":"2025-03-27T04:20:24","modified_gmt":"2025-03-27T04:20:24","slug":"install-ruby-on-rails-on-ubuntu","status":"publish","type":"post","link":"\/uk\/tutorials\/install-ruby-on-rails-on-ubuntu","title":{"rendered":"How to Install Ruby on Rails on Ubuntu"},"content":{"rendered":"<p>The Ruby on Rails framework provides various toolkits that help improve web application development efficiency. It offers various code templates and libraries, allowing developers to easily add new functionalities without writing them from scratch.<\/p><p>However, installing Ruby on Rails can be challenging for new developers. Users must first prepare the hosting environment properly and install several dependencies using various commands.<\/p><p>In this article, we will explain how to install Ruby on Rails on a virtual private server (VPS). We will also explain the steps to create a Rails application and provide the best practices when using the framework.&nbsp;<\/p><div class=\"wp-block-image\">\n<figure class=\"aligncenter size-large\"><a href=\"https:\/\/assets.hostinger.com\/content\/tutorials\/pdf\/Linux-Commands-Cheat-Sheet.pdf\" target=\"_blank\" rel=\"noopener\"><img decoding=\"async\" width=\"1024\" height=\"283\" src=\"https:\/\/www.hostinger.com\/tutorials\/wp-content\/uploads\/sites\/2\/2022\/11\/Linux-cheat-sheet-1024x283.png\" alt=\"\" class=\"wp-image-69262\" srcset=\"https:\/\/www.hostinger.com\/uk\/tutorials\/wp-content\/uploads\/sites\/51\/2022\/11\/Linux-cheat-sheet-1536x425.png 1024w, https:\/\/www.hostinger.com\/uk\/tutorials\/wp-content\/uploads\/sites\/51\/2022\/11\/Linux-cheat-sheet-300x83.png 300w, https:\/\/www.hostinger.com\/uk\/tutorials\/wp-content\/uploads\/sites\/51\/2022\/11\/Linux-cheat-sheet-150x41.png 150w, https:\/\/www.hostinger.com\/uk\/tutorials\/wp-content\/uploads\/sites\/51\/2022\/11\/Linux-cheat-sheet-768x212.png 768w, https:\/\/www.hostinger.com\/uk\/tutorials\/wp-content\/uploads\/sites\/51\/2022\/11\/Linux-cheat-sheet.png 2048w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/a><\/figure><\/div><p>\n\n\n\n\n<div class=\"protip\">\n                    <h2 class=\"featured-snippet title\">What Is Ruby on Rails?<\/h2>\n                    <p>Ruby on Rails is a web application framework based on the Ruby programming language. It provides various toolkits, libraries, code templates, and components that help streamline development. This framework uses the popular Model-View-Controller (MVC) architecture, making it highly flexible and suitable for all web applications, including websites and CMSs.<\/p>\n                <\/div>\n\n\n\n<\/p><h2 class=\"wp-block-heading\" id=\"h-how-to-install-ruby-on-rails-on-ubuntu\">How to Install Ruby on Rails on Ubuntu<\/h2><p>In this section, we will explain how to install Ruby on Rails on an <strong>Ubuntu 22.04 <\/strong>virtual private server. Before proceeding, ensure you have purchased a <a href=\"\/uk\/vps-hosting\">VPS hosting plan<\/a> running the operating system.<\/p><h3 class=\"wp-block-heading\" id=\"h-1-prepare-your-ubuntu-server\">1. Prepare Your Ubuntu Server<\/h3><p>To prepare the Rails environment, connect to your VPS <a href=\"\/uk\/tutorials\/how-to-use-putty-ssh\">using an SSH client like PuTTY<\/a> or Terminal. Hostinger users can use the Browser terminal to access their server and run <a href=\"\/uk\/tutorials\/linux-commands\">Linux commands<\/a> remotely via web browsers.<\/p><p>To simplify the preparation process, ensure your system is clean with minimal bloatware and junk files. Unnecessary software on your server can slow down performance and cause conflicts, affecting its functionality.<\/p><p>Hostinger VPS hosting users can choose which software to install. They can also opt for a plain operating system to create a minimal, easy-to-set-up hosting environment.<\/p><?xml encoding=\"utf-8\" ?><figure class=\"wp-block-image size-large\"><a href=\"\/uk\/vps-hosting\" target=\"_blank\" rel=\"noreferrer noopener\"><img decoding=\"async\" width=\"1024\" height=\"300\" src=\"https:\/\/www.hostinger.com\/tutorials\/wp-content\/uploads\/sites\/2\/2023\/02\/VPS-hosting-banner-1024x300.png\" alt=\"\" class=\"wp-image-77934\" srcset=\"https:\/\/www.hostinger.com\/uk\/tutorials\/wp-content\/uploads\/sites\/51\/2023\/02\/VPS-hosting-banner.png 1024w, https:\/\/www.hostinger.com\/uk\/tutorials\/wp-content\/uploads\/sites\/51\/2023\/02\/VPS-hosting-banner-300x88.png 300w, https:\/\/www.hostinger.com\/uk\/tutorials\/wp-content\/uploads\/sites\/51\/2023\/02\/VPS-hosting-banner-150x44.png 150w, https:\/\/www.hostinger.com\/uk\/tutorials\/wp-content\/uploads\/sites\/51\/2023\/02\/VPS-hosting-banner-768x225.png 768w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/a><\/figure><p>Hostinger users can find their server IP address and SSH login credentials through the <strong>VPS<\/strong> <strong>Dashboard <\/strong>&rarr; <strong>Overview<\/strong>. Instead of root, we recommend switching to other superuser accounts to help avoid accidental modifications that may break your system.<\/p><div class=\"wp-block-image\">\n<figure data-wp-context='{\"imageId\":\"69e1daf7755ec\"}' data-wp-interactive=\"core\/image\" class=\"aligncenter size-full wp-lightbox-container\"><img decoding=\"async\" width=\"1460\" height=\"1041\" data-wp-class--hide=\"state.isContentHidden\" data-wp-class--show=\"state.isContentVisible\" data-wp-init=\"callbacks.setButtonStyles\" data-wp-on-async--click=\"actions.showLightbox\" data-wp-on-async--load=\"callbacks.setButtonStyles\" data-wp-on-async-window--resize=\"callbacks.setButtonStyles\" src=\"https:\/\/www.hostinger.com\/tutorials\/wp-content\/uploads\/sites\/2\/2021\/10\/vps-ssh-username-and-ip-address-on-hpanel.png\" alt=\"SSH access credentials on hPanel's VPS overview menu\" class=\"wp-image-125811\" srcset=\"https:\/\/www.hostinger.com\/uk\/tutorials\/wp-content\/uploads\/sites\/51\/2021\/10\/vps-ssh-username-and-ip-address-on-hpanel.png 1460w, https:\/\/www.hostinger.com\/uk\/tutorials\/wp-content\/uploads\/sites\/51\/2021\/10\/vps-ssh-username-and-ip-address-on-hpanel-300x214.png 300w, https:\/\/www.hostinger.com\/uk\/tutorials\/wp-content\/uploads\/sites\/51\/2021\/10\/vps-ssh-username-and-ip-address-on-hpanel-1024x730.png 1024w, https:\/\/www.hostinger.com\/uk\/tutorials\/wp-content\/uploads\/sites\/51\/2021\/10\/vps-ssh-username-and-ip-address-on-hpanel-150x107.png 150w, https:\/\/www.hostinger.com\/uk\/tutorials\/wp-content\/uploads\/sites\/51\/2021\/10\/vps-ssh-username-and-ip-address-on-hpanel-768x548.png 768w\" sizes=\"(max-width: 1460px) 100vw, 1460px\" \/><button class=\"lightbox-trigger\" type=\"button\" aria-haspopup=\"dialog\" aria-label=\"Enlarge\" data-wp-init=\"callbacks.initTriggerButton\" data-wp-on-async--click=\"actions.showLightbox\" data-wp-style--right=\"state.imageButtonRight\" data-wp-style--top=\"state.imageButtonTop\">\n\t\t\t<svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"12\" height=\"12\" fill=\"none\" viewbox=\"0 0 12 12\">\n\t\t\t\t<path fill=\"#fff\" d=\"M2 0a2 2 0 0 0-2 2v2h1.5V2a.5.5 0 0 1 .5-.5h2V0H2Zm2 10.5H2a.5.5 0 0 1-.5-.5V8H0v2a2 2 0 0 0 2 2h2v-1.5ZM8 12v-1.5h2a.5.5 0 0 0 .5-.5V8H12v2a2 2 0 0 1-2 2H8Zm2-12a2 2 0 0 1 2 2v2h-1.5V2a.5.5 0 0 0-.5-.5H8V0h2Z\"><\/path>\n\t\t\t<\/svg>\n\t\t<\/button><\/figure><\/div><p>Once connected, update the Ubuntu repository to ensure you install the latest package version using the following command:<\/p><pre class=\"wp-block-preformatted\">sudo apt update &amp;&amp; sudo apt upgrade<\/pre><h3 class=\"wp-block-heading\" id=\"h-2-install-ruby-on-ubuntu\">2. Install Ruby on Ubuntu<\/h3><p>Ruby on Rails prerequisites include the Ruby programming language, code compiler, and JavaScript runtime. Depending on your application, it may also need other optional packages like <a href=\"\/uk\/tutorials\/how-to-install-and-setup-redis-on-ubuntu\/\">Redis<\/a> or Readline.<\/p><p>For this tutorial, we will show you how to install all the required software using APT.<\/p><p>To install Ruby, run:<\/p><pre class=\"wp-block-preformatted\">sudo apt install ruby-full -y<\/pre><p>Check whether the system has installed Ruby successfully using the following command:<\/p><pre class=\"wp-block-preformatted\">sudo ruby -v<\/pre><div class=\"wp-block-image\">\n<figure class=\"aligncenter size-large\"><a href=\"\/uk\/tutorials\/wp-content\/uploads\/sites\/2\/2023\/12\/terminal-returns-the-installed-ruby-version.png\"><img decoding=\"async\" width=\"1024\" height=\"51\" src=\"\/tutorials\/wp-content\/uploads\/sites\/2\/2023\/12\/terminal-returns-the-installed-ruby-version-1024x51.png\" alt=\"Terminal returns the installed Ruby version\" class=\"wp-image-99591\" srcset=\"https:\/\/www.hostinger.com\/uk\/tutorials\/wp-content\/uploads\/sites\/51\/2023\/12\/terminal-returns-the-installed-ruby-version.png 1024w, https:\/\/www.hostinger.com\/uk\/tutorials\/wp-content\/uploads\/sites\/51\/2023\/12\/terminal-returns-the-installed-ruby-version-300x15.png 300w, https:\/\/www.hostinger.com\/uk\/tutorials\/wp-content\/uploads\/sites\/51\/2023\/12\/terminal-returns-the-installed-ruby-version-150x7.png 150w, https:\/\/www.hostinger.com\/uk\/tutorials\/wp-content\/uploads\/sites\/51\/2023\/12\/terminal-returns-the-installed-ruby-version-768x38.png 768w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/a><\/figure><\/div><p>If the command line interface returns the &ldquo;<strong>Command not found<\/strong>&rdquo; error, it means the package wasn&rsquo;t installed properly. If Terminal outputs the Ruby version number, you can continue installing other essential packages.<\/p><p>You can install different software based on your preference. For this tutorial, we will install the <strong>build-essential<\/strong> compiler package, <strong>Git <\/strong>version control, <strong>PostgreSQL <\/strong>database, SSL library, and <strong>zlib<\/strong> compression:<\/p><pre class=\"wp-block-preformatted\">sudo apt install -y build-essential git-core libssl-dev zlib1g-dev postgresql postgresql-server-dev-all<\/pre><p>\n\n\n<div class=\"protip\">\n                    <h4 class=\"title\">Suggested Reading<\/h4>\n                    <p>Check out our guide on <a href=\"\/uk\/tutorials\/how-to-install-postgresql-on-ubuntu\">how to Install PostgreSQL on Ubuntu<\/a> to learn more about how to set up a default database and Postgres user.<\/p>\n                <\/div>\n\n\n\n<\/p><p>Verify whether these packages are installed correctly by checking their versions. For <strong>build-essential<\/strong>, use the <strong>grep <\/strong>command:<\/p><pre class=\"wp-block-preformatted\">apt list --installed | grep build-essential<\/pre><div class=\"wp-block-image\">\n<figure class=\"aligncenter size-large\"><a href=\"\/uk\/tutorials\/wp-content\/uploads\/sites\/2\/2023\/12\/grep-command-returns-the-build-essential-package-installation-status.png\"><img decoding=\"async\" width=\"1024\" height=\"119\" src=\"\/tutorials\/wp-content\/uploads\/sites\/2\/2023\/12\/grep-command-returns-the-build-essential-package-installation-status-1024x119.png\" alt=\"The grep command in Terminal returns the installation status of the build-essential package\" class=\"wp-image-99593\" srcset=\"https:\/\/www.hostinger.com\/uk\/tutorials\/wp-content\/uploads\/sites\/51\/2023\/12\/grep-command-returns-the-build-essential-package-installation-status.png 1024w, https:\/\/www.hostinger.com\/uk\/tutorials\/wp-content\/uploads\/sites\/51\/2023\/12\/grep-command-returns-the-build-essential-package-installation-status-300x35.png 300w, https:\/\/www.hostinger.com\/uk\/tutorials\/wp-content\/uploads\/sites\/51\/2023\/12\/grep-command-returns-the-build-essential-package-installation-status-150x17.png 150w, https:\/\/www.hostinger.com\/uk\/tutorials\/wp-content\/uploads\/sites\/51\/2023\/12\/grep-command-returns-the-build-essential-package-installation-status-768x89.png 768w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/a><\/figure><\/div><p>Then, run the following command to install the <strong>Node.js<\/strong> JavaScript runtime and <strong>Yarn <\/strong>package manager to enable the asset pipeline:<\/p><pre class=\"wp-block-preformatted\">sudo apt install -y nodejs yarn<\/pre><p>We recommend using the most recent version to ensure optimal compatibility, security, and functionality. If unsure, check the developer release note pages.<\/p><h3 class=\"wp-block-heading\" id=\"h-3-install-rails-on-ubuntu\">3. Install Rails on Ubuntu<\/h3><p>\n\n\n<div class=\"protip\">\n                    <h4 class=\"title\">Pro Tip<\/h4>\n                    <p><a href=\"\/uk\/vps\/rails-hosting\">Hostinger&rsquo;s Rails VPS hosting plans<\/a> allow you to set up Ubuntu with Rails\/OpenLiteSpeed in one click. Each package also offers a browser terminal and Kodee &ndash; an AI Assistant.<\/p>\n                <\/div>\n\n\n\n<\/p><p>We will install Ruby on Rails using the RubyGem package manager. It is the framework&rsquo;s official source, ensuring you get the latest version and frequent updates.<\/p><p>This tool also facilitates Ruby gems installation, removal, and management. It also lets you easily manage dependencies and Ruby libraries to simplify project administration.<\/p><p>RubyGem usually comes pre-installed with the Ruby programming language. Check whether your system has it by querying the version number:<\/p><pre class=\"wp-block-preformatted\">gem -v<\/pre><p>You can also install it manually using APT by running the following command:<\/p><pre class=\"wp-block-preformatted\">sudo apt install rubygems -y<\/pre><p>Install other essential development packages, like the <strong>Bundler <\/strong>dependency management system and <strong>rbenv<\/strong> version manager. Use the following command:<\/p><pre class=\"wp-block-preformatted\">sudo gem install bundler &amp;&amp; sudo apt install rbenv -y<\/pre><p>If you host multiple applications, you might require a different version of Ruby. Instead of setting them up manually, define a default version that applies to your entire system using the<strong> ruby-build<\/strong> plugin and<strong> rbenv<\/strong>.<\/p><p>For example, here&rsquo;s a<strong> rbenv<\/strong> command that sets the default Ruby version as <strong>2.2.3<\/strong>:<\/p><pre class=\"wp-block-preformatted\">rbenv global 2.2.3<\/pre><p>Once the prerequisites are installed, run this <strong>gem<\/strong> command to start the Rails installation process:<\/p><pre class=\"wp-block-preformatted\">sudo gem install rails<\/pre><p>Query the version to check whether you have installed Rails successfully.<\/p><p>Instead of running commands, installing Rails in Hostinger VPS only takes several steps:<\/p><ol class=\"wp-block-list\">\n<li>Log in to the <a href=\"https:\/\/hpanel.hostinger.com\" target=\"_blank\" rel=\"noopener\"><strong>hPanel<\/strong><\/a> and click <strong>VPS<\/strong> on the top menu.<\/li>\n\n\n\n<li>Select your<strong> VPS plan<\/strong>.<\/li>\n\n\n\n<li>Go to the sidebar &rarr;<strong> OS &amp; Panel<\/strong> &rarr;<strong> Operating System<\/strong>.<\/li>\n\n\n\n<li>Under the <strong>Change OS<\/strong> window, click <strong>Application<\/strong>.<\/li>\n\n\n\n<li>Select <strong>OpenLiteSpeed<\/strong> <strong>and Rails<\/strong>.<\/li>\n\n\n\n<li>Click <strong>Change OS<\/strong>.<\/li>\n<\/ol><div class=\"wp-block-image\">\n<figure data-wp-context='{\"imageId\":\"69e1daf77a3ec\"}' data-wp-interactive=\"core\/image\" class=\"aligncenter size-full wp-lightbox-container\"><img decoding=\"async\" width=\"1460\" height=\"419\" data-wp-class--hide=\"state.isContentHidden\" data-wp-class--show=\"state.isContentVisible\" data-wp-init=\"callbacks.setButtonStyles\" data-wp-on-async--click=\"actions.showLightbox\" data-wp-on-async--load=\"callbacks.setButtonStyles\" data-wp-on-async-window--resize=\"callbacks.setButtonStyles\" src=\"https:\/\/www.hostinger.com\/tutorials\/wp-content\/uploads\/sites\/2\/2023\/12\/openlitespeed-rails-vps-template-on-hpanel-operating-system-configuration-page.png\" alt=\"OpenLiteSpeed and Rails VPS template on hPanel's operating system configuration page\" class=\"wp-image-125907\" srcset=\"https:\/\/www.hostinger.com\/uk\/tutorials\/wp-content\/uploads\/sites\/51\/2023\/12\/openlitespeed-rails-vps-template-on-hpanel-operating-system-configuration-page.png 1460w, https:\/\/www.hostinger.com\/uk\/tutorials\/wp-content\/uploads\/sites\/51\/2023\/12\/openlitespeed-rails-vps-template-on-hpanel-operating-system-configuration-page-300x86.png 300w, https:\/\/www.hostinger.com\/uk\/tutorials\/wp-content\/uploads\/sites\/51\/2023\/12\/openlitespeed-rails-vps-template-on-hpanel-operating-system-configuration-page-1024x294.png 1024w, https:\/\/www.hostinger.com\/uk\/tutorials\/wp-content\/uploads\/sites\/51\/2023\/12\/openlitespeed-rails-vps-template-on-hpanel-operating-system-configuration-page-150x43.png 150w, https:\/\/www.hostinger.com\/uk\/tutorials\/wp-content\/uploads\/sites\/51\/2023\/12\/openlitespeed-rails-vps-template-on-hpanel-operating-system-configuration-page-768x220.png 768w\" sizes=\"(max-width: 1460px) 100vw, 1460px\" \/><button class=\"lightbox-trigger\" type=\"button\" aria-haspopup=\"dialog\" aria-label=\"Enlarge\" data-wp-init=\"callbacks.initTriggerButton\" data-wp-on-async--click=\"actions.showLightbox\" data-wp-style--right=\"state.imageButtonRight\" data-wp-style--top=\"state.imageButtonTop\">\n\t\t\t<svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"12\" height=\"12\" fill=\"none\" viewbox=\"0 0 12 12\">\n\t\t\t\t<path fill=\"#fff\" d=\"M2 0a2 2 0 0 0-2 2v2h1.5V2a.5.5 0 0 1 .5-.5h2V0H2Zm2 10.5H2a.5.5 0 0 1-.5-.5V8H0v2a2 2 0 0 0 2 2h2v-1.5ZM8 12v-1.5h2a.5.5 0 0 0 .5-.5V8H12v2a2 2 0 0 1-2 2H8Zm2-12a2 2 0 0 1 2 2v2h-1.5V2a.5.5 0 0 0-.5-.5H8V0h2Z\"><\/path>\n\t\t\t<\/svg>\n\t\t<\/button><\/figure><\/div><p>\n\n    <p class=\"warning\">\n        <strong>Warning!<\/strong> Reinstalling your VPS operating system will wipe all its data. Before proceeding, create a backup if you wish to preserve its files.    <\/p>\n    \n\n\n\n<\/p><h3 class=\"wp-block-heading\" id=\"h-4-set-up-a-development-environment\">4. Set up a Development Environment<\/h3><p>After preparing the hosting area, set up your Rails development environment. The steps differ depending on your operating system, but we will show you how to do it in Windows.<\/p><p>\n\n\n<div class=\"protip\">\n                    <h4 class=\"title\">Pro Tip<\/h4>\n                    <p>The steps to set up an Ubuntu development environment for Ruby on Rails are similar to those for the hosting area.<\/p>\n                <\/div>\n\n\n\n<\/p><p><strong>Installing A Code Editor or IDE<\/strong><\/p><p>You need a text editor or an integrated development environment (IDE) to write and debug your Rails application&rsquo;s code. You can choose any software you are familiar with.<\/p><p>If unsure, check our <a href=\"\/uk\/tutorials\/best-code-editors\">best code editors<\/a> article. We recommend choosing one with features like syntax highlighter and auto-completion to simplify the development process and help minimize human errors.<\/p><p>In this tutorial, we will use <a href=\"https:\/\/code.visualstudio.com\/download\" target=\"_blank\" rel=\"noreferrer noopener\">Visual Studio Code (VSCode)<\/a>. This free IDE offers various plugins that help improve development efficiency, like the <strong>VSCode rdbg <\/strong>Ruby code debugger.<\/p><p><strong>Installing Ruby on Windows<\/strong><\/p><p>The development area requires the same dependencies as the hosting server. Instead of using commands like on Linux, Windows users must obtain the installer package manually from the <a href=\"https:\/\/rubyinstaller.org\/\" target=\"_blank\" rel=\"noreferrer noopener\">official rubyinstaller website<\/a>. We recommend the newest version of Ruby with devkit.<\/p><p>Double-click on the executable file and complete the Ruby installation. This process will also configure the RubyGem package manager and the WEBrick web server. WEBrick is a Rails development server that allows you to host an application on your local machine for testing.<\/p><p><strong>Installing Rails on Windows<\/strong><\/p><p>The steps of Rails installation in Windows are the same as in other operating systems. Open <strong>Command Prompt<\/strong>,<strong> PowerShell<\/strong>, or<strong> VSCode Terminal <\/strong>as an administrator and run this<strong> gem<\/strong> command:<\/p><pre class=\"wp-block-preformatted\">gem install rails<\/pre><p>This will set up the web framework and its dependencies. To ensure the software is installed correctly, check the Rails version using the following command:<\/p><pre class=\"wp-block-preformatted\">rails -v<\/pre><div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full\"><a href=\"\/uk\/tutorials\/wp-content\/uploads\/sites\/2\/2023\/12\/vscode-terminal-returns-the-installed-rails-version.png\"><img decoding=\"async\" width=\"879\" height=\"56\" src=\"\/tutorials\/wp-content\/uploads\/sites\/2\/2023\/12\/vscode-terminal-returns-the-installed-rails-version.png\" alt=\"VSCode terminal returns the installed Rails version\" class=\"wp-image-99595\" srcset=\"https:\/\/www.hostinger.com\/uk\/tutorials\/wp-content\/uploads\/sites\/51\/2023\/12\/vscode-terminal-returns-the-installed-rails-version.png 879w, https:\/\/www.hostinger.com\/uk\/tutorials\/wp-content\/uploads\/sites\/51\/2023\/12\/vscode-terminal-returns-the-installed-rails-version-300x19.png 300w, https:\/\/www.hostinger.com\/uk\/tutorials\/wp-content\/uploads\/sites\/51\/2023\/12\/vscode-terminal-returns-the-installed-rails-version-150x10.png 150w, https:\/\/www.hostinger.com\/uk\/tutorials\/wp-content\/uploads\/sites\/51\/2023\/12\/vscode-terminal-returns-the-installed-rails-version-768x49.png 768w\" sizes=\"(max-width: 879px) 100vw, 879px\" \/><\/a><\/figure><\/div><p><strong>Installing Git Version Control<\/strong><\/p><p>Git lets you easily push code and files from your local machine to the live environment. While Hostinger VPS supports other methods like <a href=\"\/uk\/tutorials\/how-to-use-sftp-to-safely-transfer-files\/\">SFTP<\/a>, they are less efficient.<\/p><p>Download the latest version from the <a href=\"https:\/\/git-scm.com\/downloads\" target=\"_blank\" rel=\"noreferrer noopener\">official Git website<\/a> and complete the installation. Open the <strong>Git Bash<\/strong> application from the start menu and run the following command to check the version:<\/p><pre class=\"wp-block-preformatted\">git version<\/pre><p>Then, set up a Git repository to host your project code and documentation. Choose a platform that best suits your needs and workflow. For example, the popular options include <a href=\"\/uk\/tutorials\/bitbucket-vs-github\">GitHub and BitBucket<\/a>.<\/p><div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full\"><a href=\"\/uk\/tutorials\/wp-content\/uploads\/sites\/2\/2023\/12\/git-bash-returns-the-installed-git-version-number.png\"><img decoding=\"async\" width=\"871\" height=\"134\" src=\"\/tutorials\/wp-content\/uploads\/sites\/2\/2023\/12\/git-bash-returns-the-installed-git-version-number.png\" alt=\"Git Bash returns the installed Git version number\" class=\"wp-image-99596\" srcset=\"https:\/\/www.hostinger.com\/uk\/tutorials\/wp-content\/uploads\/sites\/51\/2023\/12\/git-bash-returns-the-installed-git-version-number.png 871w, https:\/\/www.hostinger.com\/uk\/tutorials\/wp-content\/uploads\/sites\/51\/2023\/12\/git-bash-returns-the-installed-git-version-number-300x46.png 300w, https:\/\/www.hostinger.com\/uk\/tutorials\/wp-content\/uploads\/sites\/51\/2023\/12\/git-bash-returns-the-installed-git-version-number-150x23.png 150w, https:\/\/www.hostinger.com\/uk\/tutorials\/wp-content\/uploads\/sites\/51\/2023\/12\/git-bash-returns-the-installed-git-version-number-768x118.png 768w\" sizes=\"(max-width: 871px) 100vw, 871px\" \/><\/a><\/figure><\/div><h3 class=\"wp-block-heading\" id=\"h-5-create-your-first-rails-application\">5. Create Your First Rails Application<\/h3><p>To create a Rails application, open your <strong>VSCode terminal<\/strong> by pressing the <strong>Ctrl + `<\/strong> shortcut. Navigate to your project directory using the <strong>cd<\/strong> command:<\/p><pre class=\"wp-block-preformatted\">cd D:\\Project<\/pre><p>Create new Rails project files and folders using the following command and replace <strong>rails_app <\/strong>with your application name:<\/p><pre class=\"wp-block-preformatted\">rails new rails_app<\/pre><p>The application folder comprises several directories, each for different purposes. For example, the <strong>app\/<\/strong> path contains the application&rsquo;s main components, while <strong>config\/<\/strong> houses the configuration files. Check the <a href=\"https:\/\/guides.rubyonrails.org\/getting_started.html\" target=\"_blank\" rel=\"noreferrer noopener\">Rails start guide<\/a> to learn more about the structure.<\/p><p>Navigate to the application&rsquo;s main folder using the<strong> cd <\/strong>command and run the project using the following:<\/p><pre class=\"wp-block-preformatted\">rails server --binding=0.0.0.0<\/pre><p>Enter <strong>localhost:3000 <\/strong>into your web browser. If the Rails welcome screen appears, you can start writing the application&rsquo;s code and push the files to your server using Git commands.<\/p><div class=\"wp-block-image\">\n<figure class=\"aligncenter size-large\"><a href=\"\/uk\/tutorials\/wp-content\/uploads\/sites\/2\/2023\/12\/ruby-on-rails-welcome-screen.png\"><img decoding=\"async\" width=\"1024\" height=\"543\" src=\"\/tutorials\/wp-content\/uploads\/sites\/2\/2023\/12\/ruby-on-rails-welcome-screen-1024x543.png\" alt=\"The Ruby on Rails application welcome screen\" class=\"wp-image-99597\" srcset=\"https:\/\/www.hostinger.com\/uk\/tutorials\/wp-content\/uploads\/sites\/51\/2023\/12\/ruby-on-rails-welcome-screen.png 1024w, https:\/\/www.hostinger.com\/uk\/tutorials\/wp-content\/uploads\/sites\/51\/2023\/12\/ruby-on-rails-welcome-screen-300x159.png 300w, https:\/\/www.hostinger.com\/uk\/tutorials\/wp-content\/uploads\/sites\/51\/2023\/12\/ruby-on-rails-welcome-screen-150x79.png 150w, https:\/\/www.hostinger.com\/uk\/tutorials\/wp-content\/uploads\/sites\/51\/2023\/12\/ruby-on-rails-welcome-screen-768x407.png 768w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/a><\/figure><\/div><p>After moving the files into your VPS, connect to it via SSH. Navigate to the project folder and enter the same command to start the application:<\/p><pre class=\"wp-block-preformatted\">rails server --binding=0.0.0.0<\/pre><p>Visting <strong>vpsipaddress:3000<\/strong> in your web browser should load the application. Press <strong>Ctrl + C <\/strong>in the command-line interface to stop the application. Run the same command to restart it.<\/p><h2 class=\"wp-block-heading\" id=\"h-ruby-on-rails-best-practices\">Ruby on Rails Best Practices<\/h2><p>This section will explore best practices for Ruby on Rails installation to help you streamline the process.<\/p><p><strong>Use Version Management with Ruby Version Manager (RVM)<\/strong><\/p><p>Hosting several applications with different Ruby versions on one server may cause incompatibility issues. RVM addresses this problem by allowing users to manage multiple Ruby installations using a command line interface.<\/p><p>It lets you install, manage, and switch to different versions easily. RVM also allows users to manage isolated environments for gem installations called <strong>gemsets<\/strong>.<\/p><p>Hostinger VPS lets users install RVM to set up a solid environment to host their applications. In addition to ensuring functionality, this command-line tool helps simplify development since users don&rsquo;t need to manage multiple servers.<\/p><p><strong>Enhance Development With Essential Gems and Packages<\/strong><\/p><p>In Rails, gems are additional packages for extending the framework functionality and simplifying tasks. Users can install them using the Bundler gem dependency manager.<\/p><p>To do so, add your desired gem to your project&rsquo;s <strong>gemfile<\/strong> by inserting the following new line:<\/p><pre class=\"wp-block-preformatted\">gem 'gem_name'<\/pre><p>Then, install the package by running the <strong>bundle<\/strong> command:<\/p><pre class=\"wp-block-preformatted\">bundle install gem_name<\/pre><p>There are various gems with different purposes. For example, install <strong>Devise<\/strong> to set up user authentication on your applications. Meanwhile, use <strong>Paperclip<\/strong> or<strong> CarrierWave<\/strong> to enable file uploads.<\/p><p><strong>Use Version Control with Git<\/strong><\/p><p>In software development, a version control system allows developers to track project changes. In addition to providing a restore point for troubleshooting, it also enables continuous integration and deployment (CI\/CD) to automate the process.<\/p><p>Git is a version control system that lets developers streamline their development tasks and improve collaboration. It enables non-linear workflow, allowing them to individually work on a project concurrently.<\/p><p>Developers can use simple <a href=\"\/uk\/tutorials\/basic-git-commands\">Git commands<\/a> to push files to a remote server and create an isolated development branch, improving efficiency. Check out our <a href=\"\/uk\/tutorials\/git-tutorial\">Git tutorial<\/a> to learn more about this tool.<\/p><p><strong>Join the Ruby on Rails Community<\/strong><\/p><p>Ruby is one of the most used server-side programming languages, <a href=\"https:\/\/w3techs.com\/technologies\/history_overview\/programming_language\" target=\"_blank\" rel=\"noreferrer noopener\">more popular than JavaScript<\/a>. Due to its popularity, the Rails framework has a large community of users behind it.<\/p><p>This benefits users, especially beginners, as they can quickly find solutions when encountering difficulties related to the framework. They can ask questions or search for answers on various online forums.<\/p><p>For example, Rails has an <a href=\"https:\/\/discuss.rubyonrails.org\/\" target=\"_blank\" rel=\"noreferrer noopener\">official forum<\/a> with many active users. Moreover, developers can join non-official discussion boards from Rails course providers like <a href=\"https:\/\/gorails.com\/forum\" target=\"_blank\" rel=\"noreferrer noopener\">GoRails<\/a> or other popular platforms like Reddit.<\/p><p><strong>Stay Updated<\/strong><\/p><p>Installing the latest Ruby and Rails version ensures your application applies the latest security patches. Moreover, updates commonly come with bug fixes and new software compatibility to improve your hosting environment stability.<\/p><p>Using the new version of Rails and Ruby also ensures you get continuous support to simplify troubleshooting. To stay updated, subscribe to web development newsletters, participate in forums, and check the <a href=\"https:\/\/rubyonrails.org\/category\/releases\" target=\"_blank\" rel=\"noreferrer noopener\">release notes<\/a>.<\/p><p>If you run multiple applications, use a tool like RVM to simplify the task. For example, you can use this command to list all the available Ruby versions:<\/p><pre class=\"wp-block-preformatted\">rvm list<\/pre><p>\n\n\n<div class=\"protip\">\n                    <h4 class=\"title\">Learn More About Web Application Deployment<\/h4>\n                    <p><br>\n<a href=\"\/uk\/tutorials\/deploy-web-apps-using-kamal\">How to Deploy Web Apps on Linux using Kamal<\/a><br>\n<a href=\"\/uk\/tutorials\/kubernetes-tutorial\">Kubernetes Tutorial<\/a><\/p>\n                <\/div>\n\n\n\n<\/p><h2 class=\"wp-block-heading\" id=\"h-conclusion\">Conclusion<\/h2><p>Ruby on Rails is a popular framework for developing a web application. It provides various libraries, templates, and toolkits that allow developers to add new functionality to their software without coding from scratch.<\/p><p>In this article, we have provided the Ruby on Rails installation guide on Ubuntu:<\/p><ol class=\"wp-block-list\">\n<li><strong>Prepare hosting environment<\/strong>. Connect to your remote VPS via SSH using a superuser account. Install the Ubuntu operating system and update the packages via APT.<\/li>\n\n\n\n<li><strong>Install Ruby<\/strong>. Use APT to install the Ruby, RubyGems, and other dependencies. For example, configure PostgreSQL database, GCC compiler, and NodeJS.<\/li>\n\n\n\n<li><strong>Install Rails<\/strong>. Download and install Ruby on Rails using RubyGems. In addition, install rbenv or RVM if you run multiple Ruby environments.<\/li>\n\n\n\n<li><strong>Set up the development environment. <\/strong>Download a text editor or an IDE like VSCode. Then, set up Ruby and Rails via a command line interface like Command Prompt.<\/li>\n\n\n\n<li><strong>Create and push your application. <\/strong>Run the<strong> rails new<\/strong> command in your IDE&rsquo;s Terminal to start a project. Write your application code and push it using Git or an FTP client.<\/li>\n<\/ol><p>Install the latest version of Ruby and Rails to ensure optimal application performance and stability. To stay updated, regularly check the release notes and join the Rails community, like forums or subreddits.<\/p><p>To improve development efficiency, use the RVM version manager, additional gems, and the Git version control system. Hostinger VPS hosting environment supports all these tools to ensure an optimal web development experience.<\/p><h2 class=\"wp-block-heading\" id=\"h-install-ruby-on-rails-on-ubuntu-faq\">Install Ruby on Rails on Ubuntu FAQ<\/h2><p>In this section, we will answer several questions about installing Ruby on Rails on Ubuntu.&nbsp;<\/p><div class=\"schema-faq wp-block-yoast-faq-block\"><div class=\"schema-faq-section\" id=\"faq-question-1702008358039\"><h3 class=\"schema-faq-question\">How to Download Ruby on Rails on Ubuntu?<\/h3> <p class=\"schema-faq-answer\">To download Rails on Ubuntu, you need RubyGems. It is pre-configured when you install the Ruby programming language. After installing Ruby using Ubuntu&rsquo;s APT manager, download the Rails framework via RubyGems using the<strong> gem install ruby<\/strong> command.<\/p> <\/div> <div class=\"schema-faq-section\" id=\"faq-question-1702008359655\"><h3 class=\"schema-faq-question\">Which IDE Is Best for Ruby on Rails Ubuntu?<\/h3> <p class=\"schema-faq-answer\">If you exclusively use the Ruby on Rails framework, we recommend <a href=\"https:\/\/www.jetbrains.com\/ruby\/\" target=\"_blank\" rel=\"noreferrer noopener\">RubyMine<\/a>. It has various built-in tools that help developers efficiently write and debug Ruby code. If you want a free IDE for developing various applications with different frameworks, we recommend Microsoft VSCode.&nbsp;<\/p> <\/div> <div class=\"schema-faq-section\" id=\"faq-question-1702008360390\"><h3 class=\"schema-faq-question\">Can I Host Ruby on Rails Applications on Hostinger&rsquo;s VPS?<\/h3> <p class=\"schema-faq-answer\">Yes. Hostinger VPS supports all software required for developing and hosting Ruby on Rails Applications. We offer a clean hosting environment that users can easily configure to their needs. Moreover, we provide an Ubuntu 22.04 and Rails template, allowing users to prepare their server easily in one click.&nbsp;<\/p> <\/div> <\/div>\n","protected":false},"excerpt":{"rendered":"<p>The Ruby on Rails framework provides various toolkits that help improve web application development efficiency. It offers various code templates and libraries, allowing developers to easily add new functionalities without writing them from scratch. However, installing Ruby on Rails can be challenging for new developers. Users must first prepare the hosting environment properly and install [&#8230;]<\/p>\n<p><a class=\"btn btn-secondary understrap-read-more-link\" href=\"\/uk\/tutorials\/install-ruby-on-rails-on-ubuntu\">Read More&#8230;<\/a><\/p>\n","protected":false},"author":337,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"rank_math_title":"How to Install Ruby on Rails on Ubuntu in %currentyear% + Tips","rank_math_description":"Check out our guide on how to install Ruby on Rails on Ubuntu: 1. Prepare your Ubuntu server 2. Install Ruby 3. Install Rails on Ubuntu + more.","rank_math_focus_keyword":"install ruby on rails on ubuntu","footnotes":""},"categories":[22642,22640],"tags":[],"class_list":["post-99589","post","type-post","status-publish","format-standard","hentry","category-pre-installed-applications","category-vps"],"hreflangs":[{"locale":"en-US","link":"https:\/\/www.hostinger.com\/tutorials\/install-ruby-on-rails-on-ubuntu","default":0},{"locale":"pt-BR","link":"https:\/\/www.hostinger.com\/br\/tutoriais\/como-instalar-ruby-on-rails-no-ubuntu","default":0},{"locale":"fr-FR","link":"https:\/\/www.hostinger.com\/fr\/tutoriels\/comment-installer-ruby-on-rails-sur-ubuntu","default":0},{"locale":"es-ES","link":"https:\/\/www.hostinger.com\/es\/tutoriales\/instalar-ruby-on-rails-en-ubuntu","default":0},{"locale":"en-UK","link":"https:\/\/www.hostinger.com\/uk\/tutorials\/install-ruby-on-rails-on-ubuntu","default":0},{"locale":"en-MY","link":"https:\/\/www.hostinger.com\/my\/tutorials\/install-ruby-on-rails-on-ubuntu","default":0},{"locale":"en-PH","link":"https:\/\/www.hostinger.com\/ph\/tutorials\/install-ruby-on-rails-on-ubuntu","default":0},{"locale":"es-MX","link":"https:\/\/www.hostinger.com\/mx\/tutoriales\/instalar-ruby-on-rails-en-ubuntu","default":0},{"locale":"es-CO","link":"https:\/\/www.hostinger.com\/co\/tutoriales\/instalar-ruby-on-rails-en-ubuntu","default":0},{"locale":"es-AR","link":"https:\/\/www.hostinger.com\/ar\/tutoriales\/instalar-ruby-on-rails-en-ubuntu","default":0},{"locale":"pt-PT","link":"https:\/\/www.hostinger.com\/pt\/tutoriais\/como-instalar-ruby-on-rails-no-ubuntu","default":0},{"locale":"en-IN","link":"https:\/\/www.hostinger.com\/in\/tutorials\/install-ruby-on-rails-on-ubuntu","default":0},{"locale":"en-CA","link":"https:\/\/www.hostinger.com\/ca\/tutorials\/install-ruby-on-rails-on-ubuntu","default":0},{"locale":"en-AU","link":"https:\/\/www.hostinger.com\/au\/tutorials\/install-ruby-on-rails-on-ubuntu","default":0},{"locale":"en-NG","link":"https:\/\/www.hostinger.com\/ng\/tutorials\/install-ruby-on-rails-on-ubuntu","default":0}],"_links":{"self":[{"href":"https:\/\/www.hostinger.com\/uk\/tutorials\/wp-json\/wp\/v2\/posts\/99589","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.hostinger.com\/uk\/tutorials\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.hostinger.com\/uk\/tutorials\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.hostinger.com\/uk\/tutorials\/wp-json\/wp\/v2\/users\/337"}],"replies":[{"embeddable":true,"href":"https:\/\/www.hostinger.com\/uk\/tutorials\/wp-json\/wp\/v2\/comments?post=99589"}],"version-history":[{"count":10,"href":"https:\/\/www.hostinger.com\/uk\/tutorials\/wp-json\/wp\/v2\/posts\/99589\/revisions"}],"predecessor-version":[{"id":125908,"href":"https:\/\/www.hostinger.com\/uk\/tutorials\/wp-json\/wp\/v2\/posts\/99589\/revisions\/125908"}],"wp:attachment":[{"href":"https:\/\/www.hostinger.com\/uk\/tutorials\/wp-json\/wp\/v2\/media?parent=99589"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.hostinger.com\/uk\/tutorials\/wp-json\/wp\/v2\/categories?post=99589"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.hostinger.com\/uk\/tutorials\/wp-json\/wp\/v2\/tags?post=99589"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}