How to Install Redmine on CentOS 7

Install Redmine on CentOS 7

In this article, we will have explained the necessary steps to install and configure Redmine on CentOS 7. Before continuing with this tutorial, make sure you are logged in as a user with sudo privileges. All the commands in this tutorial should be run as a non-root user.

Redmine is one of the most popular open source project management and issue tracking software tools. It is cross-platform and cross-database and built on top of the Ruby on Rails framework. Redmine includes support for multiple projects, wikis, issue tracking system, forums, calendars, email notifications, and much more.

Install Redmine on CentOS

Step 1. The first command will update the package lists to ensure you get the latest version and dependencies.

sudo yum install epel-release
sudo yum update

Step 2. Install Dependency.

Install the packages required for building Redmine and Ruby from source:

yum install curl zlib-devel curl-devel openssl-devel httpd-devel apr-devel apr-util-devel mysql-devel ftp wget ImageMagick-devel gcc-c++ patch readline readline-devel zlib libyaml-devel libffi-devel make bzip2 autoconf automake libtool bison subversion sqlite-devel

Step 3. Install MariaDB.

Redmine supports MySQL/MariaDB, Microsoft SQL Server, SQLite 3 and PostgreSQL. In this tutorial we’ll use MariaDB as a database back-end:

yum install mariadb-server

When the installation is complete, run the following command to secure your installation:

mysql_secure_installation

Then, we need to create a database for our Redmine installation:

$ mysql -uroot -p
MariaDB [(none)]> CREATE DATABASE redmine CHARACTER SET utf8;
MariaDB [(none)]> GRANT ALL PRIVILEGES ON redmine.* TO 'redmine'@'localhost' IDENTIFIED BY 'redmine_passwd';
MariaDB [(none)]> FLUSH PRIVILEGES;
MariaDB [(none)]> \q

Step 4. Creating New System User.

Create a new system user for Redmine:

sudo adduser --home /opt/redmine --shell /bin/bash --gecos 'Redmine application' redmine
sudo install -d -m 755 -o redmine -g redmine /opt/redmine

Switch to the new redmine user:

sudo su - redmine

Step 5. Install Ruby using RVM.

The version of Ruby in the CentOS repositories is pretty outdated and not supported by Redmine. We’ll install Ruby using RVM:

curl -sSL https://rvm.io/mpapis.asc | gpg --import -
curl -sSL https://get.rvm.io | bash -s stable --ruby

To start using RVM run the following commands:

source ~/.rvm/scripts/rvm
rvm --default use ruby

Step 6. Install Redmine.

Download the Redmine archive with the following curl command:

curl -L http://www.redmine.org/releases/redmine-4.0.4.tar.gz -o redmine.tar.gz

Once the download is completed extract the archive:

tar -xvf redmine.tar.gz

Configure database settings:

cp /opt/redmine/redmine-4.0.1/config/database.yml.example /opt/redmine/redmine-4.0.4/config/database.yml

Open the file with your text editor:

nano /opt/redmine/redmine-4.0.4/config/database.yml
production:
  adapter: mysql2
  database: redmine
  host: localhost
  username: redmine
  password: "redmine_passwd"
  encoding: utf8

Step 7. Install Gems.

Next step, install gems using following command:

cd /opt/redmine/redmine
echo "gem 'puma'" >> Gemfile.local
echo "gem: --no-ri --no-rdoc" >> ~/.gemrc 
gem install bundler
bundle install --without development test postgresql sqlite

Prepare the database:

rake generate_secret_token
RAILS_ENV=production rake db:migrate
RAILS_ENV=production REDMINE_LANG=en rake redmine:load_default_data

Step 8. Puma configuration.

Create a new configuration file as follows:

nano ./redmine/config/puma.rb
#!/usr/bin/env puma

application_path = '/opt/redmine/redmine'
directory application_path
environment 'production'
daemonize true
pidfile "#{application_path}/tmp/pids/puma.pid"
state_path "#{application_path}/tmp/pids/puma.state"
stdout_redirect "#{application_path}/log/puma.stdout.log", "#{application_path}/log/puma.stderr.log"
bind "tcp://0.0.0.0:9000"

Start the puma server with:

cd /opt/redmine/redmine/ && bundle exec puma --config config/puma.rb

The output should be similar to the following:

Puma starting in single mode...
* Version 3.11.2 (ruby 2.4.1-p111), codename: Love Song
* Min threads: 0, max threads: 16
* Environment: production
* Daemonizing...

Step 9. Access Redmine.

Finally your can start your browser and access your new Redmine installation at: http://IP_ADDRESS:9000

Congratulation, you have learned how to install and configure Redmine on CentOS 7. If you have any question, please leave a comment below.