There is a new revision of this tutorial available for Ubuntu 16.04 (Xenial Xerus).

How to Install Redmine 3 with Nginx on Ubuntu 15.10

Redmine is an open source project management and issue tracking tool based on the Ruby on Rails Framework. It is web-based, so you can use it from any client platform that provides a web browser. It is well suited for multi-language teams as it contains translations for 42 languages. You can track multiple projects in one installation, it has an integrated support for news, document management, file management, a support wiki. You can connect it with other applications by LDAP authentication and the REST API.

This tutorial covers the Redmine 3 installation with Nginx as the web server and MySQL as the database on Ubuntu 15.10 (64 Bit) operating system.

Prerequisites

  • Ubuntu 15.10 - 64 bit.
  • Root privileges.

Step 1 - Install Dependencies

Redmine has a lot of dependencies but we can install them easily with apt. The first step is to become the root user and then update your Ubuntu repository. All further steps in this tutorial get executed as root user, that's why I use "sudo su" instead of prepending suo to each command.

sudo su
apt-get update

Install the dependencies of Redmine with the apt command below:

apt-get install mysql-server mysql-client libmysqlclient-dev imagemagick libmagickwand-dev libcurl4-openssl-dev git-core subversion

The installer will ask for a new MySQl root password, enter a new and secure MySQL password there.

Step 2 - Install Ruby and RVM

In this step, we will install the latest RVM version and Ruby 2.0. Redmine 3.2 stable supports Ruby version 2.0, so we can use it here. RMV (Ruby Version Manager) is a handy command line tool that allows you to install, manage and work with multiple Ruby environments.

gpg --keyserver hkp://keys.gnupg.net --recv-keys D39DC0E3
curl -L https://get.rvm.io | bash -s stable --ruby=2.0.0

Now we have to reload RVM and add it to .bashrc for automatic reloading:

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

Step 3 - Configure the MySQL Database for Redmine

We will create a database and database user for the Redmine installation. Log in to the MySQL shell with the root user and your password:

mysql -u root -p
TYPE YOUR PASSWORD

Next, create a new database called "redmine" and a new user with the name 'redmine' with password 'redmine' (use a better password on your install, this one is just an example), and then grant the privilages for the user 'redmine' to the 'redmine' database.

create database redmine;
create user [email protected] identified by 'redmine';
grant all privileges on redmine.* to [email protected] identified by 'redmine';
flush privileges;
q\

The database and user are created.

Step 4 - Install Phusion Passenger and Nginx

Phusion Passenger is a web- and app server that can be integrated with the Apache and Nginx web servers. It supports multiple languages: Ruby, Python, and Nodejs. It's easy to use and fast.

In this part, we will install Phusion Passenger and integrate it with Nginx. Redmine will run under the Nginx web server. Install Passenger with the gem command and then install the passenger-nginx-module.

gem install passenger --no-ri --no-rdoc
passenger-install-nginx-module

The command will ask you about the language that shall be supported, select Ruby and Python here.

You will be asked about the Nginx installation, select "Yes: download, compile and install Nginx for me. (recommended)".

Finally, you will be asked about the Nginx installation directory, use the default '/opt/nginx/' and press "Enter".

Step 5 - Configure Nginx

Go to the installation directory and edit the nginx.conf file with an editor, I'll use the vim editor here.

cd /opt/nginx/conf/
vim nginx.conf

In the server directive, change the server name to your desired domain nameand add the root web directory:

server {
  .......
  listen  80;
  server_name www.redmine.me;
  root /var/www/redmine/public;
  passenger_enabled on;
  client_max_body_size      10m; # Max attachemnt size
  ........
}

Comment out the lines below:

#location / {
#    root   html;
#    index  index.html index.htm;
#}

Save the file and exit.

Next we will configure Nginx for systemd. Go to the systemd directory and create new service file 'nginx.service'.

cd /lib/systemd/system/
vim nginx.service

Paste Nginx script for systemd below:

[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

Save the file and exit.

Reload the systemd services and try to start Nginx with systemctl command:

systemctl daemon-reload
systemctl start nginx

If you want to check Nginx, check the open port 80 with netstat:

netstat -plntu | grep nginx

tcp        0      0 0.0.0.0:80              0.0.0.0:*               LISTEN      4871/nginx

Step 6 - Install Redmine

Make new directory for the Redmine installation, I will use the directory '/var/www/' here.

mkdir -p /var/www/

Go to the '/var/www/' directory and download redmine with the svn command:

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

Enter the redmine directory and copy the configuration file and database configuration file:

cd redmine
cp config/configuration.yml.example config/configuration.yml
cp config/database.yml.example config/database.yml

Then edit the database.yml file with vim:

vim config/database.yml

On the production line, fill in the details for the database, database user and password. Use the database details that you created in chapter 3.

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

Save the file and exit the editor.

In the redmine directory, create a new directory and change the owner to www-data:

mkdir -p tmp tmp/pdf public/plugin_assets
sudo chown -R www-data:www-data files log tmp public/plugin_assets
sudo chmod -R 775 files log tmp public/plugin_assets

Then install bundler and the gem dependencies for Redmine:

gem install bundler
bundle install --without development test

Now generate the secret token and then generate the database:

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

Restart Nginx and visit the redmine domain with a web browser:

systemctl restart nginx

Visit redmine installation, in my case: www.redmine.me

Redmine home.

Login to the admin page: www.redmine.me/login

The default user and password is 'admin'.

Redmine Login page.

Create new sample project.

Create a new project in Redmine.

Sample Project Page.

Redmine sample project page.

The installation of Redmine with Nginx and MySQL has been finished successfully.

Conclusion

Redmine is a web-based application for project management and issue tracking. Redmine is a cross-platform app, so we can run it on Windows, Linux or Mac OS. It supports many different databases like MySQL, PostgreSQL, Microsoft SQL Server and SQLite. Redmine is easy to install and configure, we can use Apache or Nginx as the web server. Redmine is very powerful and has many features like multi-language support, file management, wiki, REST API etc. Redmine is one of the best OpenSource solutions to build your own project management with issue tracking.

Share this page:

9 Comment(s)

Add comment

Comments

From: Carlos

I have this error 

[email protected]:~# 

[email protected]:~# gem install passenger --no-ri --no-rdoc

ERROR:  Error installing passenger:

rack requires Ruby version >= 2.2.2.

[email protected]:~# 

Thanks for your help

 

From: mavis

Try this to solve it-

https://github.com/rvm/rvm/issues/3583

From: Kernel Training

Thanks for sharing this. You explained very clearly how to install in step by step. It was very useful for me.

From: Robert Yae

 This instruction saved my days.

I appreciate you for your time and generous help.

I used server name www.redmine3.com in NginX. After I finished all the steps, I can't get my www.redmine3.com webpage.

Any advise?

Thanks,

Robert

From: Engel

Hi I have this error:

 systemctl status nginx.service

? nginx.service - The NGINX HTTP and reverse proxy server   Loaded: loaded (/lib/systemd/system/nginx.service; disabled; vendor preset: enabled)   Active: failed (Result: exit-code) since dom 2016-03-13 17:32:45 VET; 8s ago  Process: 3100 ExecStart=/opt/nginx/sbin/nginx (code=exited, status=1/FAILURE)  Process: 3097 ExecStartPre=/opt/nginx/sbin/nginx -t (code=exited, status=0/SUCCESS)mar 13 17:32:42 engel-VirtualBox nginx[3100]: nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)mar 13 17:32:43 engel-VirtualBox nginx[3100]: nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)mar 13 17:32:43 engel-VirtualBox nginx[3100]: nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)mar 13 17:32:44 engel-VirtualBox nginx[3100]: nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)mar 13 17:32:44 engel-VirtualBox nginx[3100]: nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)mar 13 17:32:45 engel-VirtualBox nginx[3100]: nginx: [emerg] still could not bind()mar 13 17:32:45 engel-VirtualBox systemd[1]: nginx.service: Control process exited, code=exited status=1mar 13 17:32:45 engel-VirtualBox systemd[1]: Failed to start The NGINX HTTP and reverse proxy server.mar 13 17:32:45 engel-VirtualBox systemd[1]: nginx.service: Unit entered failed state.mar 13 17:32:45 engel-VirtualBox systemd[1]: nginx.service: Failed with result 'exit-code'.

From: Bob

Great set of instructions! I just finished installing Redmine onto Ubuntu 16.04 using these steps. I've installed Redmine into many Ubuntu versions, as far back as 9.04, and this was the most complete, accurate, problem-free tutorial I've ever used.

I did run into one hiccup. When I did the step "bundle install --without development test", there was a warning to not do that as root and that if I did, bad things could happen.. So I did ctrl-C and tried that step as a normal user. That didn't work, so I went back and did it as root. Despite the warning, it all worked fine.

From: NK

I follow step and result:

 

We're sorry, but something went wrong.

We've been notified about this issue and we'll take a look at it shortly.

From: Kumar Nikhil

sir please post the document of how to install redmine 3 with apache on centos 6... it's urgent

From: amit

on running command "bundle exec rake generate_secret_token" i am getting error

"/usr/local/rvm/gems/ruby-2.3.0/gems/htmlentities-4.3.1/lib/htmlentities/mappings/expanded.rb:465: warning: key "inodot" is duplicated and overwritten on line 466"

while installing ruby 2.0.0 i was given warning that 2.0.0 is no longer suppoerted so i installed the 2.3 version

please advice