Introduction

Redmine is a powerful and flexible open-source project management tool that provides issue tracking, time tracking, wiki functionality, and version control integration. It is built on Ruby on Rails and supports multiple database backends, including MySQL and PostgreSQL. In this guide, we will walk through the step-by-step process of installing Redmine on Ubuntu 22.04.

Prerequisites

Before we begin, ensure that your system meets the following requirements:

  • A fresh installation of Ubuntu 22.04
  • A non-root user with sudo privileges
  • A functional internet connection
  • A domain name (optional but recommended)

Step 1: Update System Packages

First, update the package list and upgrade existing packages to ensure your system is up to date:

sudo apt update && sudo apt upgrade -y

Step 2: Install Required Dependencies

Redmine requires several dependencies, including Ruby, Bundler, and a database server. We will install these packages first.

sudo apt install -y curl gnupg2 git-core libmysqlclient-dev imagemagick libmagickwand-dev libpq-dev build-essential libssl-dev libreadline-dev zlib1g-dev

Step 3: Install Ruby

Ubuntu 22.04 does not include the latest Ruby version by default, so we will install Ruby using rbenv.

git clone https://github.com/rbenv/rbenv.git ~/.rbenv
cd ~/.rbenv && src/configure && make -C src
echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.bashrc
source ~/.bashrc

git clone https://github.com/rbenv/ruby-build.git ~/.rbenv/plugins/ruby-build
echo 'export PATH="$HOME/.rbenv/plugins/ruby-build/bin:$PATH"' >> ~/.bashrc
source ~/.bashrc

Now install Ruby:

rbenv install 3.2.0  # Use the latest stable version
rbenv global 3.2.0
ruby -v  # Verify installation

Step 4: Install Database Server

Redmine supports MySQL and PostgreSQL. In this guide, we will use MySQL.

sudo apt install -y mysql-server

Secure the MySQL installation:

sudo mysql_secure_installation

Create a Redmine database and user:

sudo mysql -u root -p

Inside the MySQL shell, run the following commands:

CREATE DATABASE redmine CHARACTER SET utf8mb4;
CREATE USER 'redmine'@'localhost' IDENTIFIED BY 'strongpassword';
GRANT ALL PRIVILEGES ON redmine.* TO 'redmine'@'localhost';
FLUSH PRIVILEGES;
EXIT;

Step 5: Install Redmine

Download and extract the latest stable version of Redmine:

cd /var/www/
wget https://www.redmine.org/releases/redmine-5.0.0.tar.gz
sudo tar -xvf redmine-5.0.0.tar.gz
sudo mv redmine-5.0.0 redmine
cd redmine

Configure the database connection:

cp config/database.yml.example config/database.yml
nano config/database.yml

Modify the MySQL section as follows:

production:
  adapter: mysql2
  database: redmine
  host: localhost
  username: redmine
  password: "strongpassword"
  encoding: utf8mb4

Step 6: Install Bundler and Dependencies

Run the following commands to install Bundler and required gems:

gem install bundler
bundle install --without development test

Step 7: Set Up the Database

Run the following commands to initialize the database:

bundle exec rake db:migrate RAILS_ENV=production
bundle exec rake redmine:load_default_data RAILS_ENV=production

Step 8: Set Up File Permissions

Ensure Redmine has the correct permissions:

sudo mkdir -p tmp tmp/pdf public/plugin_assets
sudo chown -R www-data:www-data files log tmp public/plugin_assets
sudo chmod -R 755 files log tmp public/plugin_assets

Step 9: Start Redmine

You can start Redmine using the built-in WEBrick server:

bundle exec rails server -e production

Alternatively, configure Redmine to run with Passenger and Apache or Nginx for production use.

Step 10: Access Redmine

Open your web browser and navigate to:

http://your-server-ip:3000

Log in with the default credentials:

  • Username: admin
  • Password: admin

Conclusion

You have successfully installed Redmine on Ubuntu 22.04. For production environments, consider setting up a reverse proxy with Nginx or Apache, enabling SSL, and configuring automatic backups. Redmine is now ready to manage your projects effectively!