Debian<\/a> 12 and want to set up Ruby on Rails for your development projects, this guide will walk you through the installation process step-by-step.<\/p>\n\n\n\nStep 1: Update System Packages<\/h4>\n\n\n\n Before installing any new software, it’s crucial to ensure that your system packages are up to date. Open a terminal and execute the following commands to update the package repository and installed packages:<\/p>\n\n\n\n
$ sudo apt update\n$ sudo apt upgrade<\/code><\/pre>\n\n\n\nThis will update the package lists and upgrade all installed packages to their latest versions.<\/p>\n\n\n\n
Step 2: Install Ruby<\/h4>\n\n\n\n Debian 12 ships with Ruby, but it’s recommended to install the Ruby version manager (rbenv<\/code>) to manage your Ruby installations. rbenv<\/code> allows you to install and switch between multiple Ruby versions effortlessly.<\/p>\n\n\n\nStart by installing the necessary dependencies for rbenv<\/code> and ruby-build<\/code> (a plugin for rbenv<\/code> that simplifies the installation of Ruby versions):<\/p>\n\n\n\n$ sudo apt install rbenv ruby-build<\/code><\/pre>\n\n\n\nAfter installation, add rbenv<\/code> to your shell session by appending the following lines to your ~\/.bashrc<\/code> or ~\/.zshrc<\/code> file:<\/p>\n\n\n\n$ export PATH="$HOME\/.rbenv\/bin:$PATH"\n$ eval "$(rbenv init -)"<\/code><\/pre>\n\n\n\nThen, reload your shell configuration:<\/p>\n\n\n\n
$ source ~\/.bashrc # or ~\/.zshrc if you use Zsh<\/code><\/pre>\n\n\n\nNow, you can install a specific version of Ruby. To install the latest stable version, use:<\/p>\n\n\n\n
$ rbenv install 3.1.0 # Replace with the desired Ruby version (e.g., 3.1.0)<\/code><\/pre>\n\n\n\nSet this version as the global default:<\/p>\n\n\n\n
$ rbenv global 3.1.0<\/code><\/pre>\n\n\n\nVerify that Ruby is installed correctly:<\/p>\n\n\n\n
$ ruby -v<\/code><\/pre>\n\n\n\nStep 3: Install Node.js<\/h4>\n\n\n\n Rails requires a JavaScript runtime for asset compilation. Install Node.js and npm (Node Package Manager) using the following command:<\/p>\n\n\n\n
$ sudo apt install nodejs npm<\/code><\/pre>\n\n\n\nVerify the installation:<\/p>\n\n\n\n
$ node -v\n$ npm -v<\/code><\/pre>\n\n\n\nStep 4: Install Rails<\/h4>\n\n\n\n With Ruby and Node.js installed, you can now install Rails using the gem<\/code> package manager:<\/p>\n\n\n\n$ gem install rails<\/code><\/pre>\n\n\n\nThis command installs the latest stable version of Rails.<\/p>\n\n\n\n
Step 5: Verify Rails Installation<\/h4>\n\n\n\n After installation, verify that Rails has been installed correctly by checking its version:<\/p>\n\n\n\n
$ rails -v<\/code><\/pre>\n\n\n\nYou should see the Rails version number printed to the terminal.<\/p>\n\n\n\n
Step 6: Set Up a New Rails Application<\/h4>\n\n\n\n To create a new Rails application, navigate to your desired directory and use the following command:<\/p>\n\n\n\n
$ rails new myapp<\/code><\/pre>\n\n\n\nReplace myapp<\/code> with your preferred application name. This command creates a new Rails application with default settings.<\/p>\n\n\n\nStep 7: Start the Rails Server<\/h4>\n\n\n\n Navigate into your newly created Rails application directory:<\/p>\n\n\n\n
$ cd myapp<\/code><\/pre>\n\n\n\nStart the Rails server to see your application in action:<\/p>\n\n\n\n
$ rails server<\/code><\/pre>\n\n\n\nBy default, the Rails server will start on http:\/\/localhost:3000<\/code>. Open your web browser and visit this URL to see the default Rails welcome page.<\/p>\n\n\n\nConclusion<\/h4>\n\n\n\n You’ve successfully installed Ruby on Rails on your Debian 12 system and created a new Rails application. From here, you can explore the vast capabilities of Rails and start developing your web projects with ease.<\/p>\n\n\n\n
If you encounter any issues or need further customization, refer to the Ruby on Rails Guides<\/a> for comprehensive documentation and tutorials.<\/p>\n","protected":false},"excerpt":{"rendered":"Ruby on Rails, often simply called Rails, is a popular web application framework that provides a robust environment for building dynamic web applications. If you’re using Debian 12 and want…<\/p>\n","protected":false},"author":1,"featured_media":14289,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[2,23,9,25,27,28,16,18],"tags":[183,193,354,424,433,982,531,573,591],"yoast_head":"\n
How to Install Ruby On Rails on Debian 12 Linux Systems<\/title>\n \n \n \n \n \n \n \n \n \n \n \n \n \n\t \n\t \n\t \n \n \n \n \n \n\t \n\t \n\t \n