Installing Redmine 4.1 on Ubuntu 20.04

Redmine

How to Install Redmine 4.1 on Ubuntu 19.04/20.04

Dependencies

sudo apt install build-essential libmysqlclient-dev libmysqlclient-dev imagemagick libmagickwand-dev  libmagickcore-dev

Install Apache2 & Passenger

Install PGP key and add HTTPS support for APT

sudo apt-get install -y dirmngr gnupg

sudo apt-key adv –keyserver hkp://keyserver.ubuntu.com:80 –recv-keys 561F9B9CAC40B2F7

```
sudo apt-get install -y apt-transport-https ca-certificates

Add APT repository

sudo sh -c 'echo deb https://oss-binaries.phusionpassenger.com/apt/passenger focal main > /etc/apt/sources.list.d/passenger.list'
sudo apt-get update

Install Passenger + Apache module

sudo apt-get install apache2 apache2-dev libapache2-mod-passenger

Install MySQL

sudo apt-get install mysql-server mysql-client 
sudo mysql_secure_installation

Create Database

sudo mysql

CREATE DATABASE redmine CHARACTER SET utf8mb4;
CREATE USER 'redmineuser'@'%' IDENTIFIED WITH mysql_native_password BY 'password';
GRANT ALL ON redmine.* TO 'redmineuser'@'%';
FLUSH PRIVILEGES;
EXIT;

Download Redmine 4.0 Stable

cd /opt
sudo git clone -b 4.1-stable --single-branch https://github.com/redmine/redmine.git
cd /opt/redmine

Setup Redmine DB Configuration

sudo cp /opt/redmine/config/database.yml.example /opt/redmine/config/database.yml
sudo nano /opt/redmine/config/database.yml
/opt/redmine/config/database.yml
production:
adapter: mysql2
database: redmine
host: localhost
username: redmine
password: "{change-with-strong-password}"
encoding: utf8

Install Ruby

sudo apt-add-repository ppa:brightbox/ruby-ng
sudo apt-get update

Install the packages:

sudo apt-get install ruby2.6 ruby2.6-dev

Install Gems

sudo gem install bundler
cd /opt/redmine
sudo bundle config set --local without 'development test postgresql sqlite'
sudo bundle install

Generate Keys and Migrate the Database

Run the following command to generate keys and migrate the database:

cd /opt/redmine/
sudo bundle exec rake generate_secret_token
sudo RAILS_ENV=production bundle exec rake db:migrate

Make changes to web configuration

sudo nano /etc/apache2/mods-available/passenger.conf
<IfModule mod_passenger.c>
 PassengerDefaultUser www-data
 PassengerRoot /usr/lib/ruby/vendor_ruby/phusion_passenger/locations.ini
 PassengerDefaultRuby /usr/bin/ruby
</IfModule>
sudo nano /etc/apache2/sites-available/redmine.conf
<VirtualHost *:80>
     ServerAdmin admin@example.com
     ServerName example.com
     ServerAlias www.example.com
     DocumentRoot /var/www/html/redmine
     PassengerAppRoot /opt/redmine

     <Directory /var/www/html/redmine>
         RailsBaseURI /redmine
     </Directory>

     ErrorLog ${APACHE_LOG_DIR}/error.log
     CustomLog ${APACHE_LOG_DIR}/access.log combined

</VirtualHost>

Create Link and set folder permission

sudo ln -s /opt/redmine/public /var/www/html/redmine
sudo chown -R www-data:www-data /opt/redmine
sudo chown -R www-data:www-data /var/www/html/redmine

Activate Redmine

 sudo a2ensite redmine
 sudo a2enmod passenger
 sudo a2enmod rewrite
 sudo systemctl restart apache2
  • Go to http://example.com ( replace example.com with your server address)
  • Log in with admin/admin and set your new password.