Install dependencies:
To install the dependencies that redmine needs to work, we execute the following statement. IMPORTANT firstly do apt update and apt upgrade on Ubuntu, before:
$ sudo apt install build-essential ruby-dev libxslt1-dev libmariadb-dev libxml2-dev zlib1g-dev imagemagick libmagickwand-dev curl gnupg2 bison libbison-dev libgdbm-dev libncurses-dev libncurses5-dev libreadline-dev libssl-dev libyaml-dev libsqlite3-dev sqlite3 -y
Install and restart Apache:
$ sudo apt install apache2 libapache2-mod-passenger -y
$ sudo systemctl enable --now apache2
Install, configureand restart MariaDB:
We install the mariadb database server , although we can use any other such as mysql-server , we recommend mariadb in Ubuntu.
$ sudo apt install mariadb-server -y
$ sudo systemctl enable --now mariadb
$ sudo mysql_secure_installation
We will get the following questions:
We introduce the root password.
Switch to unix_socket authentication: N.
Change the root password? N.
Remove anonymous users? Y.
Disallow root login remotely? Y.
Remove the test database and access it? Y.
Reload privilege tables now? Y.
Once the secure installation is complete, we execute the following statements in mysql to create the redmine database in Ubuntu's MariaDB.
$ sudo mysql -u root -p
MariaDB [(none)]> create database redminedb;
MariaDB [(none)]> grant all on redminedb.* to redmine@localhost identified by 'PASSWORD';
MariaDB [(none)]> flush privileges;
MariaDB [(none)]> quit;
Create a redmine user and add the new user to the sudo group:
$ sudo adduser --system --shell /bin/bash --gecos 'Redmine Administrator' --group --home /data/redmine redmine; sudo usermod -a -G rvm redmine
$ sudo adduser redmine sudo
Init a session with the user redmine:
$ su -
$ passwd redmine
$ su redmine
Download the last redmine version, unzip and move to the /opt directory:
$ cd ~
$ wget https://www.redmine.org/releases/redmine-5.0.6.tar.gz
$ tar -zxvf redmine-5.0.6.tar.gz
$ sudo mv redmine-5.0.6 /opt
$ sudo mv /opt/redmine-5.0.6 /opt/redmine
Prepare the configuration files:
$ cp /opt/redmine/config/configuration.yml{.example,}
$ cp /opt/redmine/public/dispatch.fcgi{.example,}
$ cp /opt/redmine/config/database.yml{.example,}
Edit the database configuration file with the following configuration:
$ nano /opt/redmine/config/database.yml
Edit the file with the following parameters:
production:
adapter: mysql2
database: redminedb
host: localhost
username: redmine
password: "PASSWORD"
# Use "utf8" instead of "utfmb4" for MySQL prior to 5.7.7
encoding: utf8mb4
Install Ruby dependencies on Ubuntu:
Follow the following commands in order to install Ruby dependencies on Ubuntu:
$ cd /opt/redmine
$ sudo gem install bundler
$ bundle config set --local path 'vendor/bundle'
$ bundle install
$ bundle update
$ sudo gem install io-wait strscan
$ bundle exec rake generate_secret_token
$ RAILS_ENV=production bundle exec rake db:migrate
Configure Apache for port 80 and domain:
Once we have the domain configured, we will configure a virtual host on Ubuntu, so that Redmine works on port 80 instead of 3000.
$ sudo nano /etc/apache2/sites-available/redmine.conf
We will include the following within the file. Changing the marked parameters, for the ones we have:
<VirtualHost *:80>
ServerName redmine.localhost
RailsEnv production
DocumentRoot /opt/redmine/public
<Directory "/opt/redmine/public">
Allow from all
Require all granted
</Directory>
ErrorLog ${APACHE_LOG_DIR}/redmine_error.log
CustomLog ${APACHE_LOG_DIR}/redmine_access.log combined
</VirtualHost>
Once configured, we activate the necessary Apache components in Ubuntu:
$ apache2ctl -M | grep -i passenger
$ sudo a2ensite redmine
$ a2dissite 000-default.conf
$ sudo systemctl restart apache2