Linux

Install Redmine 3 on CentOS 7 with Nginx as web server

 

Redmine is a web application for project management, written entirely using Ruby on Rails, and released under the terms of GPLv2.
Some of its features include:

  • Multiple projects support.
  • Flexible issue tracking system.
  • Documents, news, and files management.
  • Per project wiki.
  • Per project forums.
  • SCM integration.
  • Multiple LDAP authentication support.

Getting started

First of all, there are a lot of dependencies required. On the server, execute the command:

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

Install Ruby

Redmin 3.2.x requires Ruby 2.2. So, first you’ll want to install Ruby Version Manager which allows managing of multiple ruby environments.

# gpg2 --keyserver hkp://keys.gnupg.net --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3
# curl -L https://get.rvm.io | bash -s stable --ruby=2.2.5

The last command will download and execute a BASH script for installing and configuring Ruby 2.2.5.

This will take some time. Once it is complete, execute the following commands for adding rvm to the .bashrc file and reload automatically.
First:

# source /usr/local/rvm/scripts/rvm

Next, edit .bashrc adding the following lines:

[[ -s "/usr/local/rvm/scripts/rvm" ]]
source "/usr/local/rvm/scripts/rvm"

Reload .bashrc.
Next, check Ruby and RVM versions:

# ruby -v

which, in my case, gives the output: ruby 2.2.5p319 (2016-04-26 revision 54774) [x86_64-linux]
and

# rvm -v

which gives the output:rvm 1.28.0 (latest) by Wayne E. Seguin <[email protected]>, Michal Papis <[email protected]> [https://rvm.io/]

Configure MySQL

First, install (if not yet present) MySQL

# rpm -Uvh https://dev.mysql.com/get/mysql57-community-release-el7-9.noarch.rpm
# yum repolist
# yum install mysql-server

Run it:

# systemctl start mysqld

During installation process, MySQL generated a temporary password, which is stored in /var/log/mysqld.log; access it:

# grep 'temporary password' /var/log/mysqld.log

It will return a temporary password, which will be used for logging into mysql shell:

# mysql -u root -p

Next:

mysql> ALTER USER 'root'@'localhost' IDENTIFIED BY 'my_new_strong_password';

Create a new database for Redmine:

mysql> CREATE DATABASE redmine SET utf8;
mysql> CREATE USER 'redmineuser'@localhost' IDENTIFIED BY 'user_strong_password';
mysql> GRANT ALL PRIVILEGES ON redmine.* TO 'redmineuser'@'localhost' IDENTIFIED BY 'user_strong_password';
mysql> FLUSH PRIVILEGES;
mysql> EXIT;

Phusion Passenger and Nginx

Phusion Passenger, as stated in its official website, is an application server that acting as a process manager, reverse proxy and by providing operations tools, enables you to quickly launch and easily maintain Ruby, Node.js, Python and Meteor apps.

Install it with the gem command:

# gem install passenger --no-ri --no-rdoc

Then, execute:

# passenger-install-nginx-module

You will be asked for some information, and then it will install Nginx. The default installation directory is /opt/nginx. Of course, you can change it. In it, edit conf/nginx.conf.

On line 23, paste the following content:
include vhost/*.conf;

Save and close the file. Next, create a vhost directory for Virtual Host configuration files.

# mkdir -p /opt/nginx/conf/vhost

In this directory, create a redmine.conf file. The paste the following into that file:

server {
listen 80;
server_name www.redmine.me;

root /var/www/redmine/public;
passenger_enabled on;
client_max_body_size 10m; # Max attachemnt size

# redirect server error pages to the static page /50x.html
#
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
}

If you want to use Nginx with systemd, create the file /lib/systemd/system/nginx.service, and then paste the following into that file:

[Unit]
Description=The NGINX HTTP and reverse proxy server
After=syslog.target network.target remote-fs.target nss-lookup.target

[Service]
Type=forking
PIDFile=/opt/nginx/logs/nginx.pid
ExecStartPre=/opt/nginx/sbin/nginx -t
ExecStart=/opt/nginx/sbin/nginx
ExecReload=/bin/kill -s HUP $MAINPID
ExecStop=/bin/kill -s QUIT $MAINPID
PrivateTmp=true

[Install]
WantedBy=multi-user.target

After saving and exiting, you can start Nginx:

# systemctl daemon-reload
# systemctl start nginx

Install Redmine

Now, it’s possible to install Redmine in /var/www/

# cd /var/www/
# svn co https://svn.redmine.org/redmine/branches/3.2-stable redmine

In the newly created redmine folder, execute the following commands:

# cp config/configuration.yml.example config/configuration.yml
# cp config/database.yml.example config/database.yml

Next, edit config/database.yml:

production:
adapter: mysql2
database: redmine
host: localhost
username: redmineuser
password: "user_strong_password"
encoding: utf8

Always in redmine directory:

# mkdir -p tmp tmp/pdf public/plugin_assets
# chown -R nobody:nobody files log tmp public/plugin_assets
# chmod -R 775 files log tmp public/plugin_assets

Next, install Bundler to manage gems dependencies:

# gem install bundler

And then:

# bundle install --without development test

Generate a secret token:

# bundle exec rake generate_secret_token

and create database structure:

# RAILS_ENV=production bundle exec rake db:migrate
# RAILS_ENV=production bundle exec rake redmine:load_default_data

After that, restart nginx and visit the domain name with a browser, in which you’ll use a Dashboard (after logging in) for creating and managing projects.

Our work is done!

The post Install Redmine 3 on CentOS 7 with Nginx as web server appeared first on Unixmen.

Advertisements

We use cookies to give you the best online experience. By agreeing you accept the use of cookies in accordance with our privacy policy.