Install Redmine on Rocky Linux 8

2
348

This guide will take you through how to install Redmine on Rocky Linux 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 on Rocky Linux 8

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 system user (or any other non-privileged system 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 Rocky Linux 8, simply execute;

dnf install httpd

Start and enable Apache HTTP server to run on system boot;

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.5.

Follow the link below to install MariaDB Rocky Linux 8.

Install MariaDB 10.x on Rocky Linux 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 -u root -p
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 on Rocky Linux 8

Install Required Dependencies

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

dnf install epel-release -y
dnf config-manager --set-enabled powertools

Next, proceed to install the dependencies.

dnf install ruby-devel rpm-build wget libxml2-devel vim make openssl-devel automake libtool ImageMagick ImageMagick-devel MariaDB-devel gcc httpd-devel libcurl-devel gcc-c++ -y

Install Ruby on Rocky Linux 8

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

dnf install ruby -y

Note that Redmine version 4.2 supports Ruby 2.4, 2.5, 2.6, 2.7.

Verify installed version.

ruby -v
ruby 2.5.9p229 (2021-04-05 revision 67939) [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.2.2 as of this writing.

wget https://www.redmine.org/releases/redmine-4.2.2.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.2.2.tar.gz -C /opt/redmine/ --strip-components=1

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

ls /opt/redmine

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]"
  # Use "utf8" instead of "utfmb4" for MySQL prior to 5.7.7
  encoding: utf8mb4
...

Save and exit the file.

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 config set --local without 'development test'
bundle install

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 Rocky Linux 8 is now done. You can test Redmine using WEBrick by executing the command below;

While still logged in as redmine user, run the command below.

bundle exec rails server webrick -e production
=> Booting WEBrick
=> Rails 5.2.6 application starting in production on http://0.0.0.0:3000
=> Run `rails server -h` for more startup options
[2021-08-10 22:20:59] INFO  WEBrick 1.4.2.1
[2021-08-10 22:20:59] INFO  ruby 2.5.9 (2021-04-05) [x86_64-linux]
[2021-08-10 22:20:59] INFO  WEBrick::HTTPServer#start: pid=32550 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.

redmine webrick

Click sign in and use the credentials:

  • Useradmin
  • Password: admin

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,

--------------------------------------------
Almost there!

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

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

After you restart Apache, you are ready to deploy any number of web
applications on Apache, with a minimum amount of configuration!

Press ENTER when you are done editing.

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.10/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.

cat > /etc/httpd/conf.d/redmine.conf << 'EOL'
Listen 3000
<IfModule mod_passenger.c>
  PassengerRoot /opt/redmine/.gem/ruby/gems/passenger-6.0.10
  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>
EOL

Verify Apache configuration syntax.

httpd -t
Syntax OK

Next, Press ENTER to complete Passenger Module installation.

--------------------------------------------

Validating installation...

 * Checking whether this Passenger install is in PATH... (!)

   Please add /opt/redmine/.gem/ruby/gems/passenger-6.0.10/bin to PATH.
   Otherwise you will get "command not found" errors upon running
   any Passenger commands.
   
   Learn more at about PATH at:
   
     https://www.phusionpassenger.com/library/indepth/environment_variables.html#the-path-environment-variable

 * Checking whether there are no other Passenger installations... (!)

   You are currently validating against Phusion Passenger(R) 6.0.10, located in:
   
     /opt/redmine/.gem/ruby/gems/passenger-6.0.10/bin/passenger
   
   Besides this Passenger installation, the following other
   Passenger installations have also been detected:
   
     /opt/redmine/bin/passenger
   
   Please uninstall these other Passenger installations to avoid
   confusion or conflicts.

 * Checking whether Apache is installed... ✓
 * Checking whether the Passenger module is correctly configured in Apache... ✓

Detected 0 error(s), 2 warning(s).
Press ENTER to continue.

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   17410   root    8u  IPv6  37210      0t0  TCP *:hbci (LISTEN)
httpd   17450 apache    8u  IPv6  37210      0t0  TCP *:hbci (LISTEN)
httpd   17451 apache    8u  IPv6  37210      0t0  TCP *:hbci (LISTEN)
httpd   17452 apache    8u  IPv6  37210      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.
phusion selinux 3

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.

setenforce 0
sed -i 's/=enforcing/=disabled/' /etc/selinux/config

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;

dnf install policycoreutils-python-utils
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.

You are prompted to reset the password. Do reset and proceed to login to Redmine web interface.

After login, reset the password and proceed to setup your Redmine profile on Rocky Linux 8.

redmine dashboard 2

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

project

That marks the end of our guide on how to install Redmine on Rocky Linux 8. You can now explore this awesome tool.

Read more on how to use Redmine User Guide.

Reference

Redmine Install

Other Rocky Linux tutorials

Install Webmin on Rocky Linux 8

Install and Configure SNMP on Rocky Linux 8

Install Apache Maven on Rocky Linux 8

Install and Configure NFS Server on Rocky Linux 8

2 COMMENTS

LEAVE A REPLY

Please enter your comment!
Please enter your name here