Notes on deploying Redmine 4.2 on CentOS 7.
CentOS 7 and Redmine 4.2 are both EOL. For new environments, use Rocky/AlmaLinux 9, Redmine 5.x/6.x, and a supported Ruby. This post mainly serves as a reference for legacy environments.
Environment
CentOS 7.x.
Set the hostname:
hostnamectl set-hostname redmine
I disabled SELinux and the firewall in the lab to save time. Don’t do that in production; allow 80/443 and the database port as needed:
sed -i 's/SELINUX=enforcing/SELINUX=disabled/g' /etc/selinux/config
systemctl disable firewalld --now
Installing Ruby
Redmine has specific Ruby version requirements, as shown in the table below:
| Redmine version | Supported Ruby versions | Rails version used |
|---|---|---|
| 4.2 | Ruby 2.41, 2.51, 2.6, 2.72 | Rails 5.2 |
| 4.1 | Ruby 2.31, 2.41, 2.51, 2.6 | Rails 5.2 |
Install Ruby
Add the EPEL repository:
yum install epel-release -y
Add the SCLo repositories:
yum -y install centos-release-scl-rh centos-release-scl
Configure the SCLo repositories:
sed -i -e "s/\]$/\]\npriority=10/g" /etc/yum.repos.d/CentOS-SCLo-scl.repo
sed -i -e "s/\]$/\]\npriority=10/g" /etc/yum.repos.d/CentOS-SCLo-scl-rh.repo
sed -i -e "s/enabled=1/enabled=0/g" /etc/yum.repos.d/CentOS-SCLo-scl.repo
sed -i -e "s/enabled=1/enabled=0/g" /etc/yum.repos.d/CentOS-SCLo-scl-rh.repo
Install Ruby:
yum --enablerepo=centos-sclo-rh -y install rh-ruby24 rh-ruby24-ruby-devel
Reload the environment:
scl enable rh-ruby24 bash
Verify:
ruby -v
Add the Ruby environment:
vi /etc/profile.d/rh-ruby24.sh
Contents:
#!/bin/bash
source /opt/rh/rh-ruby24/enable
export X_SCLS="`scl enable rh-ruby24 'echo $X_SCLS'`"
Installing and Configuring MySQL
Create and edit /etc/yum.repos.d/mysql-57-ce.repo with the following contents:
[mysql-57]
name = mysql-57
baseurl = https://mirror.tuna.tsinghua.edu.cn/mysql/yum/mysql57-community-el7/
enabled = 1
gpgcheck = 0
gpgcheck=0skips GPG verification for convenience. In production, import the MySQL GPG key and enablegpgcheck.
Install MySQL
yum install -y mysql-community-client mysql-community-server mysql-community-devel
Start MySQL and retrieve its temporary password:
systemctl start mysqld
grep "password" /var/log/mysqld.log
Log in with the temporary password and change it:
mysql -uroot -p
ALTER USER 'root'@'localhost' IDENTIFIED BY "examplePass!23@";
FLUSH PRIVILEGES;
Create the Redmine database and grant access:
CREATE DATABASE redmine CHARACTER SET utf8mb4;
CREATE USER 'redmine'@'localhost' IDENTIFIED BY '<redmine-db-password>';
GRANT ALL PRIVILEGES ON redmine.* TO 'redmine'@'localhost';
FLUSH PRIVILEGES;
Installing Redmine
Install httpd:
yum -y install httpd httpd-devel libcurl-devel
Install Redmine dependencies:
sudo yum -y install ImageMagick ImageMagick-devel git libxml2-devel libxslt-devel gcc bzip2 openssl-devel zlib-devel gdbm-devel ncurses-devel autoconf automake bison gcc-c++ libffi-devel libtool patch readline-devel sqlite-devel glibc-headers glibc-devel libyaml-devel libicu-devel libidn-devel subversion
Add the user:
useradd redmine
su - redmine
Install bundler:
gem install bundler passenger
Grant execute permission:
sudo chmod o+x "/home/redmine"
Install the module:
passenger-install-apache2-module
Configuration
Download Redmine:
wget -c https://www.redmine.org/attachments/download/28862/redmine-4.2.4.tar.gz
Extract:
tar -xf redmine-4.2.4.tar.gz
Rename:
mv redmine-4.2.4 redmine
Configure Redmine:
cd redmine
cp config/configuration.yml.example config/configuration.yml
cp config/database.yml.example config/database.yml
Edit the database configuration file:
vi config/database.yml
Change the contents to:
production:
adapter: mysql2
database: redmine
host: localhost
username: redmine
password: "<redmine-db-password>"
# Use "utf8" instead of "utfmb4" for MySQL prior to 5.7.7
encoding: utf8mb4
Install the application:
bundle install --without development test
Generate a secret token:
bundle exec rake generate_secret_token
Load the schema into the database:
RAILS_ENV=production bundle exec rake db:migrate
Load the default data into the database:
RAILS_ENV=production bundle exec rake redmine:load_default_data
Create directories and set permissions:
mkdir -p tmp tmp/pdf public/plugin_assets
chown -R redmine:redmine files log tmp public/plugin_assets
chmod -R 755 files log tmp public/plugin_assets
Test that it is reachable:
bundle exec rails server webrick -e production
To configure SVN and other settings in Redmine, edit config/configuration.yml and change the contents to:
scm_subversion_command: "/usr/bin/svn"
attachments_storage_path: "/home/redmine/redmine/files"
config.logger = ...is not valid syntax forconfiguration.yml. To change logging, put it inconfig/additional_environment.rb.
Add the module. Use the three configuration lines printed at the end of passenger-install-apache2-module for the paths and version:
echo "LoadModule passenger_module /home/redmine/.gem/ruby/gems/passenger-6.0.12/buildout/apache2/mod_passenger.so" | sudo tee -a /etc/httpd/conf.modules.d/00-base.conf
Create and edit /etc/httpd/conf.d/redmine.conf with the following contents:
<VirtualHost *:80>
ServerName redmine.example.com
DocumentRoot /home/redmine/redmine/public
PassengerRoot /home/redmine/.gem/ruby/gems/passenger-6.0.12/
PassengerDefaultRuby /opt/rh/rh-ruby24/root/usr/bin/ruby
PassengerUser redmine
<Directory /home/redmine/redmine/public>
Options -MultiViews
Require all granted
</Directory>
</VirtualHost>
Remove the default configuration files:
rm -f /etc/httpd/conf.d/autoindex.conf
rm -f /etc/httpd/conf.d/userdir.conf
rm -f /etc/httpd/conf.d/welcome.conf
Start httpd and enable it at boot:
systemctl enable --now httpd
Verification
Open in a browser:
http://<server-ip>/login
The default username and password are admin/admin. Change them right after logging in.
Comments