Install Redmine with Apache and MariaDB on CentOS 8

0
213

This guide will take you through how to install Redmine with Apache and MariaDB on CentOS 8. Redmine is a cross-platform as well as cross-database flexible project management web application.

Redmine has quite a number of features that are described on Redmine features page.

Install Redmine with Apache and MariaDB on CentOS 8

Run System Update

Resynchronize your system packages to their latest versions;

dnf update

Create Redmine System User

In this guide, we will install Redmine on /opt/redmine directory and run it as non-privileged redmine system user. As such, create a redmine user (or any other non-privileged user that Redmine will run as for that case) and assign the /opt/redmine as its home directory.

useradd -r -m -d /opt/redmine redmine

Consult man useradd to learn what the options used above means.

Install Apache HTTP Server

To install Apache HTTP server on CentOS 8, simply execute;

dnf install httpd
systemctl enable httpd --now

Next, since we will be using Apache as our HTTP server, add Apache to Redmine group.

usermod -aG redmine apache

Install MariaDB Database Backend

Redmine supports a number of database back-ends such as PostgreSQL, MySQL/MariaDB, MSSQL. In this demo, we are using MariaDB 10.4.

Follow the link below to install MariaDB or MySQL on CentOS 8.

Install MariaDB 10.4 on CentOS 8

Install MySQL 8 on CentOS 8

Create Redmine Database and Database User

Once the database backend is installed, login and create the database and database user for Redmine. Replace the database name accordingly.

mysql
create database redminedb;

Create and grant the user all privileges on the database created. Replace the database user and password accordingly.

grant all on redminedb.* to [email protected] identified by '[email protected]';

Reload privileges tables and quit.

flush privileges;
quit

Download and Install Redmine

Install Required Dependencies

Begin by installing the dependencies required to build Redmine. First install EPEL and enable the PowerTools repositories.

dnf install epel-release
dnf config-manager --set-enabled PowerTools

Next, proceed to install the dependencies.

dnf install ruby-devel rpm-build libxml2-devel make automake libtool ImageMagick ImageMagick-devel mariadb-devel gcc httpd-devel libcurl-devel gcc-c++

Install Ruby on CentOS 8

Redmine also requires Ruby interpreter which can be installed by executing the command;

dnf install ruby

Note that Redmine version 4.0 can work with any of the Ruby 2.2 (2.2.2 and later), 2.3, 2.4, 2.5, 2.6 versions.

Verify installed version.

ruby -v
ruby 2.5.3p105 (2018-10-18 revision 65156) [x86_64-linux]

Download and Install Redmine

In order to install the latest version of Redmine, navigate to the Download’s page and grab the latest stable release version.

You can simply use wget command to pull latest Redmine tarball, version 4.0.5 as of this writing.

wget http://www.redmine.org/releases/redmine-4.0.5.tar.gz -P /tmp 

Extract the Redemine tarball to Redmine user’s home directory once the download is completes.

sudo -u redmine tar xzf /tmp/redmine-4.0.5.tar.gz -C /opt/redmine/ --strip-components=1

You should now have redmine files under /opt/redmine.

ls /opt/redmine
app           bin     config.ru        db   extra  Gemfile  log      public    README.rdoc  tmp
appveyor.yml  config  CONTRIBUTING.md  doc  files  lib      plugins  Rakefile  test         vendor

Configure Redmine Database Connection Settings

First switch to Redmine’s user account.

su - redmine

Rename the sample Redmine configuration.

cp config/configuration.yml{.example,}

Rename the sample dispatch CGI configuration file under the public folder as shown below;

cp public/dispatch.fcgi{.example,}

Rename the sample the database configuration file.

cp config/database.yml{.example,}

Next, open the database configure file for editing and and configure it to set the Redmine database connection details.

vim config/database.yml

Replace the database name, database user and the password accordingly.

...
production:
  adapter: mysql2
  database: redminedb
  host: localhost
  username: redmineadmin
  password: "[email protected]"
  encoding: utf8
...

Install Ruby Dependencies

Next, install required Ruby dependencies. Note that this step should be executed as Redmine user created above. If you are still logged in as Redmine user, proceed. Otherwise, switch to redmine user.

su - redmine

Install Bundler for managing gem dependencies.

gem install bundler

Once the bundler installation is done, you can now install required gems dependencies.

bundle install --without development test --path vendor/bundle

Generate Secret Session Token

To prevent tempering of the cookies that stores session data, you need to generate a random secret key that Rails uses to encode them.

bundle exec rake generate_secret_token

Create Database Schema Objects

Create Rails database structure by running the command below;

RAILS_ENV=production bundle exec rake db:migrate

Once the database migration is done, insert default configuration data into the database by executing;

RAILS_ENV=production REDMINE_LANG=en bundle exec rake redmine:load_default_data

Configure FileSystem Permissions

Ensure that the following directories are available on Redmine directory, /opt/redmine.

  • tmp and tmp/pdf
  • public and public/plugin_assets
  • log
  • files

If they do not exist, simply create them and ensure that they are owned by the user used to run Redmine.

for i in tmp tmp/pdf public/plugin_assets; do [ -d $i ] || mkdir -p $i; done
chown -R redmine:redmine files log tmp public/plugin_assets
chmod -R 755 /opt/redmine/

Testing Redmine Installation

The setup of Redmine on CentOS 8 is now done. You can test Redmine using WEBrick by executing the command below;

bundle exec rails server webrick -e production
=> Booting WEBrick
=> Rails 5.2.3 application starting in production on http://0.0.0.0:3000
=> Run `rails server -h` for more startup options
[2019-10-28 21:09:33] INFO  WEBrick 1.4.2
[2019-10-28 21:09:33] INFO  ruby 2.5.3 (2018-10-18) [x86_64-linux]
[2019-10-28 21:09:33] INFO  WEBrick::HTTPServer#start: pid=7516 port=3000

You can now access Redmine via the browser using the address, http://Server-IP:3000/.

Before that, open port 3000/tcp on firewalld. Run the commands below as privileged user.

firewall-cmd --add-port=3000/tcp --permanent
firewall-cmd --reload

Once the port is opened, navigate to the browser and access Redmine. You should see a welcome page.

Install Redmine with Apache and MariaDB on CentOS 8

Click sign in and use the credentials, User: admin and Password: admin to login.

Configure Apache for Redmine

Once you have confirmed that Redmine is working fine after the testing, you need to configure Apache HTTP server for Redmine.

Install Apache Passenger (mod_rails)

Phusion Passenger is a web application server that can be used to server Redmine on production environments.

Therefore, switch to Redmine user created above to install the Phusion Passenger Apache module;

su - redmine
gem install passenger --no-rdoc --no-ri

Next, install Passenger Apache module. Replace the version of the Passenger accordingly.

passenger-install-apache2-module

Follow through the installation guide to install Phusion Passenger. When prompted to choose a language, select Ruby and press Enter.

You could as well install Phusion Passenger from the RPM repos but as of this writing, couldn’t find any repos providing it.

Once the module compilation is done, you are provided with how configure the module on Apache,

...
Please edit your Apache configuration file, and add these lines:

   LoadModule passenger_module /opt/redmine/.gem/ruby/gems/passenger-6.0.4/buildout/apache2/mod_passenger.so
   <IfModule mod_passenger.c>
     PassengerRoot /opt/redmine/.gem/ruby/gems/passenger-6.0.4
     PassengerDefaultRuby /usr/bin/ruby
   </IfModule>
...

Before you can press Enter to complete the Module installation and setup, open a new login session as privileged user and edit the Apache configuration file. In this guide, we created a dedicated Passenger Apache module configuration file as;

echo "LoadModule passenger_module /opt/redmine/.gem/ruby/gems/passenger-6.0.4/buildout/apache2/mod_passenger.so" \ > /etc/httpd/conf.modules.d/00-passenger.conf

Create Apache virtual host configuration for Redmine with the following content. Replace the server name accordingly. You can as well change the default port if you want.

Listen 3000
<IfModule mod_passenger.c>
  PassengerRoot /opt/redmine/.gem/ruby/gems/passenger-6.0.4
  PassengerDefaultRuby /usr/bin/ruby
</IfModule>
<VirtualHost *:3000>
    ServerName redmine.kifarunix-demo.com
    DocumentRoot "/opt/redmine/public" 

    CustomLog logs/redmine_access.log combined
    ErrorLog logs/redmine_error_log
    LogLevel warn

    <Directory "/opt/redmine/public">
        Options Indexes ExecCGI FollowSymLinks
        Require all granted
        AllowOverride all
    </Directory>
</VirtualHost>

Verify Apache configuration syntax.

httpd -t
Syntax OK

Next, Press ENTER to complete Passenger Module installation.

Once the installation and setup of Apache Passenger module is complete, restart Apache

systemctl restart httpd

Check if anything is listening on Port 3000.

lsof -i :3000
COMMAND  PID   USER   FD   TYPE DEVICE SIZE/OFF NODE NAME
httpd   2614   root    6u  IPv4 148831      0t0  TCP *:hbci (LISTEN)
httpd   2663 apache    6u  IPv4 148831      0t0  TCP *:hbci (LISTEN)
httpd   2664 apache    6u  IPv4 148831      0t0  TCP *:hbci (LISTEN)
httpd   2665 apache    6u  IPv4 148831      0t0  TCP *:hbci (LISTEN)

That is awesome.

Access Redmine from Browser

Since we have already opened port 3000/tcp on firewallD, you should be able to access Redmine web interface now. Replace the server-IP-or-Hostname accordingly.

http://server-IP-or-Hostname:3000

If you get the error below;

We're sorry, but something went wrong.
The issue has been logged for investigation. Please try again later.
Redmine SELinux errors on CentOS 8

You need to sort your SELinux permissions. Phusion Passenger when not installed from the repositories does not come with SELinux policy modules and thus may not work well with SELinux enabled. To make this simple, just disable SELinux and reboot your system and then access Redmine again on browser.

sed -i 's/=enforcing/=disabled/' /etc/selinux/config
systemctl reboot

Otherwise if you want to keep SELinux running, generate a custom SELinux module for Phusion Passenger for any denied entry in /var/log/audit/audit.log and install it. For example;

audit2allow -a -M passenger

This command generated a policy package that can be installed by running;

semodule -i passenger.pp

Note that in this guide, SELinux is disabled and I haven’t tried this method. It may or may not work. Good luck.

With SELinux issues fixed, login to Redmine using admin for both user and password.

Install Redmine with Apache and MariaDB on CentOS 8

After login, reset the password and proceed to setup your Redmine on CentOS 8.

Install Redmine with Apache and MariaDB on CentOS 8

Once your profile is setup, you can jump to new project.

Install Redmine with Apache and MariaDB on CentOS 8

That marks the end of our guide on how to install Redmine with Apache and MariaDB on CentOS 8. You can now explore this awesome tool.

Reference

Redmine Install

Other CentOS 8 Guides

Install Robo 3T MongoDB GUI Tool on CentOS 8

Install MongoDB Community Edition on CentOS 8

Install and Setup FreeIPA Server on CentOS 8

Install LEMP Stack on CentOS 8

LEAVE A REPLY

Please enter your comment!
Please enter your name here