How to Install Ruby on Rails on Ubuntu 26.04 LTS
Install Ruby with the mise version manager and Rails 8 on Ubuntu 26.04 LTS, following the official Rails guide, then create a first app and reach it from your browser.
This guide installs Ruby and Ruby on Rails 8 on Ubuntu 26.04 LTS using the method the official Rails guides recommend: the mise version manager for Ruby and RubyGems for Rails. The same commands work on Ubuntu 24.04 LTS and 22.04 LTS. At the end you will have a working rails command and a test application you can open in a browser. Ubuntu 14.04 and its Ruby 2.x are long out of support and cannot run current Rails versions.
Requirements
- A server or workstation running Ubuntu 26.04 LTS (or 24.04 / 22.04).
- A regular user with
sudorights, calleddeployhere. Install Ruby as that user, not as root: mise installs everything into the user's home directory. - Rails 8.1 needs Ruby 3.2 or newer. Ubuntu's own
rubypackage is tied to the release and cannot be switched per project, which is why the Rails guide uses a version manager.
Step 1: Install the build dependencies
These packages provide a compiler and the libraries that Ruby and gems with native extensions are built against:
sudo apt update
sudo apt install build-essential rustc libssl-dev libyaml-dev zlib1g-dev libgmp-dev gitStep 2: Install mise
Install mise for your user and activate it in Bash:
curl https://mise.run | sh
echo 'eval "$(~/.local/bin/mise activate)"' >> ~/.bashrc
source ~/.bashrcIf you prefer to read a script before running it, download it with curl -o mise-install.sh https://mise.run, inspect it and run it with sh mise-install.sh.
Step 3: Install Ruby
Install the latest Ruby 3.x release and make it the default for your user:
mise use -g ruby@3On x86-64 and ARM64 Linux, mise downloads a precompiled Ruby by default, so this takes seconds rather than the several minutes a source build needs. Confirm the version:
ruby --versionTo see every version mise can install, or to pin an exact one, use:
mise ls-remote ruby
mise use -g ruby@3.4Ruby 4.0 is the newest stable series and can be installed the same way with ruby@4.0; check that the gems your application depends on support it before switching.
Step 4: Install Rails
Rails is distributed as a gem. Install the latest release and check it:
gem install rails
rails --versionIf the shell reports that rails is not found, open a new terminal session so the updated path is loaded. No sudo is needed, because the gems go into the Ruby that mise manages in your home directory.
Step 5: Create and run a test application
Generate an application called store. By default Rails uses SQLite, so no database server is required to try it out:
rails new store
cd store
bin/rails db:createStart the development server:
bin/rails serverIt runs Puma on http://localhost:3000. On a remote server that address is only reachable from the server itself. The safest way to view it is an SSH tunnel from your own computer:
ssh -L 3000:localhost:3000 deploy@203.0.113.10Then browse to http://localhost:3000; the Rails welcome page confirms that everything works. Alternatively, bind to all interfaces and open the port temporarily:
sudo ufw allow 3000/tcp
bin/rails server -b 0.0.0.0Open http://203.0.113.10:3000, and remove the firewall rule again with sudo ufw delete allow 3000/tcp when you are done. The development server is not meant to face the internet. Stop it with Ctrl+C.
Step 6: Pin Ruby per project
Inside a project directory, set the Ruby version for that project only:
cd ~/store
mise use ruby@3.4This writes a mise.toml file that you can commit. If your projects already use .ruby-version files, tell mise to read them:
mise settings add idiomatic_version_file_enable_tools rubyKeeping things up to date
- New Ruby patch release: run
mise use -g ruby@3again, then reinstall Rails withgem install rails, because gems are installed per Ruby version. - New Rails release for an existing app: change the version in the app's
Gemfileand runbundle update rails, then follow the upgrade notes in the Rails guides. - System libraries: regular
sudo apt upgradecovers OpenSSL and the other libraries Ruby links against.
Frequently asked questions
Do I still need Node.js for Rails?
Not for a default application. New Rails 8 apps serve JavaScript with import maps and assets with Propshaft, neither of which needs a JavaScript runtime. You only need Node.js if you choose a JavaScript bundler when generating the app.
How do I use PostgreSQL or MySQL instead of SQLite?
Install the database server and its development headers (libpq-dev for PostgreSQL), then generate the app with the database option, for example rails new store -d postgresql, and put the credentials in config/database.yml.
Why not install Ruby with apt?
sudo apt install ruby gives you one system-wide Ruby that changes only when you upgrade Ubuntu, and gems then need root or extra path configuration. A version manager keeps Ruby in your home directory and lets each project choose its own version, which is what the official Rails installation guide recommends.
How do I run the app in production?
New Rails 8 applications include configuration for Kamal, which deploys the app as a Docker container to your server. The Getting Started guide walks through a first deployment.