By Vijay Simha on June 3, 2022
Intermediate

Redmine requires

  1. Ruby
  2. Passenger (NGINX or Apache) - Apache is easier as NGINX may not compile easily
  3. Mysql

Easiest way is to install through APT packages. But the packages are available for Ubuntu Focal (20).


Apdate apt data

sudo apt update
sudo apt upgrade


Install RVM- Ruby Version Manager

Another way to install Ruby on our Ubuntu 22.04 is using another command-line tool called RVM– Ruby Version Manager.

Ruby Version Manager in short RVM, is a software platform developed to manage multiple installations of Ruby on the same device that includes the entire ruby environment including the Ruby interpreter and installed RubyGems. This helps the developers to easily switch between different Ruby versions as per the requirement of different projects.

Install Dependencies:

sudo apt install curl g++ gcc autoconf automake bison libc6-dev libffi-dev libgdbm-dev libncurses5-dev libsqlite3-dev libtool libyaml-dev make pkg-config sqlite3 zlib1g-dev libgmp-dev libreadline-dev libssl-dev ruby-dev libmysqlclient-dev

Install GPG key

gpg --keyserver hkp://pgp.mit.edu --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3 7D2BAF1CF37B13E2069D6956105BD0E739499BDB

In case you are unable to import keys pls check the rvm link RVM: Ruby Version Manager -

Get RVM:

curl -sSL https://get.rvm.io | sudo bash -s stable


Reload profile for accessing RVM. If you logout and login it will be available automatically.

source /etc/profile


RVM is automatically added for all users who are in rvm group.


If not then you have to source the variables as given below.

source /usr/local/rvm/scripts/rvm
echo '[[ -s "/etc/profile.d/rvm.sh" ]] && source "/etc/profile.d/rvm.sh"' >> ~/.bashrc

 

Check this link for multi user rvm installation RVM: Ruby Version Manager - Installing RVM.


Create Redmine System User

Create a Redmine system user that can be used to install Redmine Ruby dependencies via bundler command. Set its home directory to /opt/redmine as this is where we will install Redmine app.

You have to create /opt/redmine directory.

sudo adduser redmine


User can also be added using useradd command.

sudo useradd -r -m -d /opt/redmine -s /usr/bin/bash redmine
passwd redmine


Add redmine to rvm group

sudo usermod -a -G rvm redmine


Add redmine user to sudoers.

sudo usermod -aG sudo redmine


Login to redmine user.

su - redmine


Get Ruby language on Ubuntu 22.04

Finally, we can use RVM to install available Ruby versions, to list them we can use the given command:

rvm list known
rvm install ruby-2.7

Replace “version” in the above in case another version should be installed. Redmine needs 2.7 version.

Redmine 4.2 does not support Ruby 2.7.0 and 2.7.1. Use Ruby 2.7.2 or higher.


Ruby 2.7.2 does not install on ubuntu 22 as the ubuntu support only openssl ver 3.

The following steps will help install ruby with openssl dir param.

rvm get head

wget https://www.openssl.org/source/openssl-1.1.1g.tar.gz
tar zxvf openssl-1.1.1g.tar.gz

cd openssl-1.1.1g
./config --prefix=$HOME/.openssl/openssl-1.1.1g --openssldir=$HOME/.openssl/openssl-1.1.1g

make
make test
make install

rm -rf ~/.openssl/openssl-1.1.1g/certs
ln -s /etc/ssl/certs ~/.openssl/openssl-1.1.1g/certs

Install any ruby version with --with-openssl-dir option.

rvm reinstall ruby-2.7.2 --with-openssl-dir=$HOME/.openssl/openssl-1.1.1g

 

Ruby is installed as part of the above package dependencies. To check the current version of installed Ruby;

ruby -v



Install mysql

sudo apt install mysql-server
sudo systemctl start mysql.service


mysql_secure_installation does not work out of the box unless you change the root password.

Log into mysql

sudo mysql


Set password for root

ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'password';


Secure Mysql installation

mysql_secure_installation


Create Redmine Database and Database User

Login as root user into mysql and create Redmine database and database user.


Replace the names of the database and the database user accordingly.

mysql -u root -p
create database redminedb;
CREATE USER 'redmineuser'@'localhost' IDENTIFIED WITH mysql_native_password BY 'password';
grant all on redminedb.* to 'redmineuser'@'localhost' ;
FLUSH PRIVILEGES;


To install Redmine from the source code, you need install the required build tools and dependencies.

sudo apt install build-essential libxslt1-dev libxml2-dev imagemagick libmagickwand-dev gnupg2 libbison-dev libncurses-dev -y


Install Passenger apache

sudo apt install apache2 libapache2-mod-passenger

Start and enable Apache to run on system boot.

sudo systemctl enable --now apache2


Download and install Redmine

Select the version of Redmine in the following command. Its better to choose 4.x as 5.0 requires Ruby 3.0 

curl -s https://www.redmine.org/releases/redmine-4.2.9.tar.gz | sudo -u redmine tar xz -C /opt/redmine/ --strip-components=1


Configure Redmine

Rename the example files.

su - redmine
cd{.example,}
cp /opt/redmine/public/dispatch.fcgi{.example,}
cp /opt/redmine/config/database.yml{.example,}

Configure Redmine Database Settings

Open the created Redmine database configuration setting and set the Redmine database connection details for MySQL.

Edit the file /opt/redmine/config/database.yml as below.

...
production:
 adapter: mysql2
 database: redminedb
 host: localhost
 username: redmineuser
 password: "P@ssW0rD"
 # Use "utf8" instead of "utfmb4" for MySQL prior to 5.7.7
 encoding: utf8mb4
...

Save and exit the file.


cd /opt/redmine

Install Bundler for managing gem dependencies.

sudo gem install bundler

Next, install the required gems dependencies as redmine user.

su - redmine
bundle config set --local path 'vendor/bundle'
bundle install

Also update the gems;

bundle update

Install updated io-wait and strscan gems;

sudo gem install io-wait strscan

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

You can safely ignore the Ruby warnings.

Configure FileSystem Permissions

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

  1. tmp and tmp/pdf
  2. public and public/plugin_assets
  3. log
  4. 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 Ubuntu 22.04 is now done. Redmine listens on TCP port 3000 by default. Hence, before running the tests, open port 3000/tcp on firewall if it is running.

redmine@ubuntu20:~$ exit
sudo ufw allow 3000/tcp

You can now test Redmine using WEBrick by executing the command below;

su - redmine
cd /opt/redmine
bundle add webrick
bundle install
bundle exec rails server webrick -e production

Sample output;

=> Booting WEBrick
=> Rails 6.1.4.7 application starting in production http://0.0.0.0:3000
=> Run `bin/rails server --help` for more startup options
[2022-03-29 13:48:36] INFO  WEBrick 1.7.0
[2022-03-29 13:48:36] INFO  ruby 3.0.2 (2021-07-07) [x86_64-linux-gnu]
[2022-03-29 13:48:36] INFO  WEBrick::HTTPServer#start: pid=14297 port=3000

Navigate to the browser and enter the address, http://server-IP-or-Hostname:3000. Replace the server-IP-or-Hostname accordingly.

If all is well, you should land on Redmine web user interface.

Install Redmine on Ubuntu 22.04

Configure Apache for Redmine on Ubuntu 22.04

Now that you have confirmed that Redmine is working as expected, proceed to configure Apache to server Redmine.

Change owner for apach2 folder to redmine

sudo chown -R redmine:redmine /etc/apache2


Create Redmine Apache VirtualHost configuration file.

cat > /etc/apache2/sites-available/redmine.conf << 'EOL'
PassengerRuby /usr/local/rvm/wrappers/ruby-2.7.2/ruby
<VirtualHost *:80>
ServerName redmine.kifarunix-demo.com
RailsEnv production
DocumentRoot /opt/redmine/public

<Directory "/opt/redmine/public">
        Allow from all
        Require all granted
</Directory>

ErrorLog ${APACHE_LOG_DIR}/redmine_error.log
       CustomLog ${APACHE_LOG_DIR}/redmine_access.log combined
</VirtualHost>
EOL

The first line in configuration with PassengerRuby directive is required in case there are multiple rubies installed on the system.  


Check Apache configuration for errors.

apachectl configtest
Syntax OK

Ensure that Passenger module is loaded;

apache2ctl -M | grep -i passenger
passenger_module (shared)

If not enabled, run the command below to enable it.

a2enmod passenger

Enable Redmine site.

sudo a2ensite redmine

Disable default site;

sudo a2dissite 000-default.conf

Reload Apache

sudo systemctl restart apache2

Check to ensure that Redmine is now listening on port 3000.

sudo lsof -i :3000
COMMAND   PID     USER   FD   TYPE DEVICE SIZE/OFF NODE NAME
apache2 16419     root    6u  IPv6 225133      0t0  TCP *:3000 (LISTEN)
apache2 16441 www-data    6u  IPv6 225133      0t0  TCP *:3000 (LISTEN)
apache2 16442 www-data    6u  IPv6 225133      0t0  TCP *:3000 (LISTEN)
apache2 16443 www-data    6u  IPv6 225133      0t0  TCP *:3000 (LISTEN)
apache2 16444 www-data    6u  IPv6 225133      0t0  TCP *:3000 (LISTEN)
apache2 16445 www-data    6u  IPv6 225133      0t0  TCP *:3000 (LISTEN)

Access Redmine on Browser

Next, you can now access and sign in to Redmine on browser using the address http://server-IP-address:3000.

Default credentials: admin:admin.


Configure email with AWS SES

Open configuration.yml file. Add under production:

email_delivery:
 delivery_method: :smtp
 smtp_settings:
   enable_starttls_auto: true
   address: "AWS_SMTP_DOMAIN"
   port: 587
   domain: "REDMINE_DOMAIN"
   authentication: :login
   user_name: "YOUR_SMTP_USER"
   password: "YOUR_SMTP_PASSWORD"


Installing plugins

Go to redmine plugin folder

su - redmine
cd /opt/redmine/plugins/


You can either getch from Git or download zip file and unzip the contents in plugin folder with a folder for each plugin.

Go to redmine plugin folder

cd /opt/redmine
bundle install --without development test --no-deployment
bundle exec rake redmine:plugins NAME=[plugin_name] RAILS_ENV=production


Restart apache.

sudo systemctl restart apache2


Plugins to look at

DMSF

Knowledge base

Redmine omniauth

mattermost integration

Custom tables

more previews

Issue Template

Scrum

webhook

lightbox2

event notification

Redmine Checklists plugin from RedmineUP

anteo/redmine_custom_workflows: Allows to create custom workflows for Redmine (github.com)


check The Most Popular Redmine Plugins To Boost Your Productivity (abacusthemes.com)


AWS CLI

Install AWS cli for copying database and files from another location.

Following links can be useful.

Installation - Installing or updating the latest version of the AWS CLI - AWS Command Line Interface (amazon.com)

Copying data from S3 to Ec2 Use Amazon S3 with Amazon EC2 - Amazon Elastic Compute Cloud


Restoring Database and attachments from backup.

To restore database and attachments in Redmine RedmineBackupRestore - Redmine


More articles on Technical



More articles on Technical
Comments

No comments yet.

Add a comment
Ctrl+Enter to add comment