Image

In this guide, we set up the Redmine application on a VPS server running the Centos 7 operating system. The task is to get a ready-made server with a working application and clear settings if necessary. We will need to install the database, additional packages, Ruby and set up the Nginx web server. In this guide, we are installing as root, if you have a normal one, use the sudo command.

The preconfigured server configuration is available on the order form.
Version 4.2.8

1. Installing the MariaDB Database

yum update
yum install epel-release
vi /etc/yum.repos.d/MariaDB.repo

Copy the configuration below:

# MariaDB 10.9 CentOS repository list
# http://downloads.mariadb.org/mariadb/repositories/

[mariadb]
name = MariaDB
baseurl = http://yum.mariadb.org/10.9/centos7-amd64
gpgkey=https://yum.mariadb.org/RPM-GPG-KEY-MariaDB
gpgcheck=1

Let's install the service:

yum install MariaDB-client MariaDB-server
systemctl enable mariadb.service
systemctl restart mariadb.service

Create a new database and user

mysql
mysql> CREATE DATABASE redmine CHARACTER SET utf8;
mysql> GRANT ALL ON redmine.* TO 'redmine'@'localhost' IDENTIFIED BY 'You_pasw0Rd-967';
mysql> EXIT;

2. Installing required packages

yum install curl gpg gcc gcc-c++ make patch autoconf automake bison libffi-devel libtool
yum install readline-devel sqlite-devel zlib-devel openssl-devel readline glibc-headers glibc-devel
yum install mariadb-devel zlib libyaml-devel bzip2 ImageMagick ImageMagick-devel
yum install yum-utils pygpgme
yum-config-manager --add-repo https://oss-binaries.phusionpassenger.com/yum/definitions/el-passenger.repo
yum install nginx passenger passenger-devel nginx-mod-http-passenger

Let's add a user:

useradd -m -U -r -d /opt/redmine redmine
usermod -a -G redmine nginx
chmod 750 /opt/redmine

3. Redmine installation

su - redmine
$gpg --keyserver keyserver.ubuntu.com --recv-key 409B6B1796C275462A1703113804BB82D39DC0E3 7D2BAF1CF37B13E2069D6956105BD0E739499BDB
$curl -sSL https://get.rvm.io | bash -s stable
$source /opt/redmine/.rvm/scripts/rvm
$rvm install 2.7
$rvm --default use 2.7
$wget http://www.redmine.org/releases/redmine-4.2.8.tar.gz
$tar -xvf redmine-4.2.8.tar.gz
$cp /opt/redmine/redmine-4.2.8/config/database.yml.example /opt/redmine/redmine-4.2.8/config/database.yml

Let's edit the file according to the user created in the database:

$vi /opt/redmine/redmine-4.2.8/config/database.yml

production:
adapter: mysql2
database: redmine
host: localhost
username: redmine
password: "You_pasw0Rd-967"
encoding: utf8

Save the file and install the required packages:

$cd ~/redmine-4.2.8
$gem install bundler
$bundle install --without development test postgresql sqlite
$bundle exec rake generate_secret_token
$RAILS_ENV=production bundle exec rake db:migrate
$exit

5. Setting up Nginx 

Open the file and paste the configuration there:

#vi /etc/nginx/conf.d/example.com.conf

passenger_root /usr/share/ruby/vendor_ruby/phusion_passenger/locations.ini;
passenger_ruby /opt/redmine/.rvm/gems/default/wrappers/ruby;
passenger_instance_registry_dir /var/run/passenger-instreg;

server {
listen 80;
server_name example.com www.example.com;
root /opt/redmine/redmine-4.2.8/public;

# log files
access_log /var/log/nginx/example.com.access.log;
error_log /var/log/nginx/example.com.error.log;
passenger_enabled on;
passenger_min_instances 1;
client_max_body_size 10m;
}

Save the file and comment out the duplicate lines in the default nginx module file:

vi /etc/nginx/conf.d/passenger.conf

#passenger_root /usr/share/ruby/vendor_ruby/phusion_passenger/locations.ini;
#passenger_ruby /usr/bin/ruby;
#passenger_instance_registry_dir /var/run/passenger-instreg;

Check the configuration with the command 

nginx -t

nginx: the configuration file /etc/nginx/nginx.conf syntax is ok

nginx: configuration file /etc/nginx/nginx.conf test is successful

systemctl restart nginx
systemctl enable nginx

Done, below we have given the nginx configuration for working with an SSL certificate, if available, use it and specify your domain in the file. In our case, we used the IP address. 

5.1 Setting up Nginx with an SSL certificate 

/etc/nginx/conf.d/example.com.conf

passenger_root /usr/share/ruby/vendor_ruby/phusion_passenger/locations.ini;
passenger_ruby /opt/redmine/.rvm/gems/default/wrappers/ruby;
passenger_instance_registry_dir /var/run/passenger-instreg;

# Redirect HTTP -> HTTPS

server {
listen 80;
server_name www.example.com example.com;

include snippets/letsencrypt.conf;
return 301 https://example.com$request_uri;

}

# Redirect WWW -> NON WWW

server {
listen 443 ssl http2;
server_name www.example.com;

ssl_certificate /etc/ssl/example.com/fullchain.pem;
ssl_certificate_key /etc/ssl/example.com/privkey.pem;
ssl_trusted_certificate /etc/ssl/example.com/chain.pem;
include snippets/ssl.conf;
return 301 https://example.com$request_uri;

}

server {

listen 443 ssl http2;
server_name example.com;
root /opt/redmine/redmine-4.2.8/public;

# SSL parameters

ssl_certificate /etc/ssl/example.com/fullchain.pem;
ssl_certificate_key /etc/ssl/example.com/privkey.pem;
ssl_trusted_certificate /etc/ssl/example.com/chain.pem;
include snippets/ssl.conf;
include snippets/letsencrypt.conf;

# log files
access_log /var/log/nginx/example.com.access.log;
error_log /var/log/nginx/example.com.error.log;

passenger_enabled on;
passenger_min_instances 1;
client_max_body_size 10m;

}

Restart the service to apply the settings:

systemctl restart nginx

Redmine installation completed successfully.




No Comments Yet