How to set up Redmine on Ubuntu 22.04 with Apache

Redmine is a powerful open-source project management and issue tracking tool. Whether you are a small team or large organization, Redmine can help your project management process allowing you to collaborate easily. In this guide, I’ll walk you through how to set up Redmine on Ubuntu 22.04 LTS alongside the Apache web server.


  • A VPS with Ubuntu 22.04 LTS
  • MySQL database
  • Apache web server
  • Domain name
  • SSL from Let’s encrypt (optional, but should have it)

Before getting started, if you plan to use a domain name and an SSL certificate, make sure to point your domain to the server’s IP address.

1- Server setup

First, update the server and enable the firewall with only necessary ports.

apt update && apt upgrade

apt autoremove && apt autoclean
ufw default allow outgoing
ufw default deny incoming
ufw allow 22
ufw allow 80
ufw allow 443
ufw enable
ufw status

Port 22 is the SSH port.

2- Stack installation

At this step, we will install all the dependencies required to run Redmine.

apt install apache2 ruby ruby-dev build-essential libapache2-mod-passenger libmysqlclient-dev mysql-server vim

Enable Apache modules:

a2enmod ssl rewrite headers proxy proxy_http deflate cache proxy_wstunnel http2 proxy_fcgi env expires

Enable Apache and MySQL services at boot.

systemctl enable apache2
systemctl enable mysql

3- Create database

Ubuntu come pre-installed with mysql_secure_installation. Let’s run it to perform the initial setup.


Use a strong PASSWORD.


create database redmine CHARACTER SET utf8mb4;

GRANT ALL PRIVILEGES ON redmine.* TO 'redmine'@'localhost';

flush privileges;

4- Download Redmine

We will download Redmine, which is currently at version 5.0.6, at the time of writing this article.

cd /opt


tar -xvzf redmine-5.0.6.tar.gz
mv redmine-5.0.6 redmine

rm redmine-5.0.6.tar.gz

5- Update database configuration

Next, we will update the database configuration file with the credentials and database we created above.

cd /opt/redmine
cp config/database.yml.example config/database.yml

vim config/database.yml

Update the production part as below:

  adapter: mysql2
  database: redmine
  host: localhost
  username: redmine
  password: "PASSWORD"
  # Use "utf8" instead of "utfmb4" for MySQL prior to 5.7.7
  encoding: utf8mb4

Save the file.

6- Install dependencies and run scripts

We have set up the database, and now we will install Ruby dependencies in the project folder, including running Redmine scripts.

gem install bundler

bundle install

Run the Redmine scripts now:

bundle exec rake generate_secret_token

RAILS_ENV=production bundle exec rake db:migrate

RAILS_ENV=production bundle exec rake redmine:load_default_data

7- Create Apache host

cd /etc/apache2/sites-available/
vim redmine.conf

Copy and paste the following content into the configuration file. Change the domain name.

<VirtualHost *:80>
    ServerName DOMAIN.COM
    RailsEnv production
    DocumentRoot /opt/redmine/public

    <Directory "/opt/redmine/public">
            Allow from all
            Require all granted
            Options -Indexes +FollowSymLinks

    ErrorLog ${APACHE_LOG_DIR}/redmine_error.log

Enable this configuration:

a2dissite 000-default.conf
a2ensite redmine.conf

apachectl -t
systemctl restart apache2

Up until here, you should now have a running Redmine setup. If you want to have SSL in front of your Redmine setup, read on.

8- SSL

We will install Certbot via snap to get a free Let’s Encrypt SSL.

snap install certbot --classic
certbot certonly --webroot -w /opt/redmine/public -d DOAMIN.COM

Note: If you are experiencing issues with SSL, try changing the ownership of the Redmine project directory using the following command: chown -R www-data:www-data /opt/redmine/public.

And lastly, update the Redmine Apache configuration file as shown below:

<VirtualHost *:443>
	ServerName DOMAIN.COM
    RailsEnv production
    DocumentRoot /opt/redmine/public

	SSLProtocol All -SSLv2 -SSLv3 -TLSv1 -TLSv1.1
	SSLHonorCipherOrder On
	Header always set Strict-Transport-Security "max-age=63072000; includeSubDomains; preload"
	Header always set X-Frame-Options DENY
	Header always set X-Content-Type-Options nosniff

	Protocols h2 http/1.1

	<Directory "/opt/redmine/public">
            Allow from all
            Require all granted
            Options -Indexes +FollowSymLinks

	<FilesMatch ".(ico|pdf|flv|jpg|jpeg|png|gif|js|css|swf|ttf|woff)$">
		Header set Cache-Control "max-age=31536000, public"

	ErrorLog ${APACHE_LOG_DIR}/redmine_error.log

	SSLEngine on
	SSLCertificateKeyFile /etc/letsencrypt/live/DOMAIN.COM/privkey.pem
	SSLCertificateFile /etc/letsencrypt/live/DOMAIN.COM/fullchain.pem

Restart Apache:

apachectl -t
systemctl restart apache2

You can now browse your installation with SSL.

To redirect HTTP traffic to HTTPS, add the following to port 80 section in /etc/apache2/sites-available/redmine.conf. Don’t forget to restart Apache afterwards.

RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI}

If everything is in order, HTTP should now redirect to HTTPS.

The default login credentials are admin/admin.

Leave a Reply

Your email address will not be published. Required fields are marked *