How to Install Redmine 3.2 with Nginx on Ubuntu 16.04

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.2 installation with Nginx web server and MySQL database server on Ubuntu 16.04 (64 Bit) operating system.

Prerequisites

  • Ubuntu 16.04 - 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 sudo 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.2. Redmine 3.2 stable supports Ruby version 2.2, 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.2.5

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. Please use a secure password on your server!

Step 4 - Install Phusion Passenger and Nginx

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

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

Paste the configuration line below at the file:

include vhost/*.conf;

Save and exit.

Next, create a new 'vhost' directory for the virtual host configuration.

mkdir -p /opt/nginx/conf/vhost

Go to the vhost directory and create a redmine virtual host configuration file with vim:

cd /opt/nginx/conf/vhost/
vim redmine.conf

Paste virtualhost configuration below:

    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;
        }
    }

Save and exit.

Next, we will configure Nginx to be started with systemd. Go to the systemd directory and create a 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 the 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 start page

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

The default user and password is 'admin'.

Redmine Login

Create new sample project.

Create a new project in Redmine

Sample Project Page.

Redmine sample project

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 and Mac OS. It supports different databases like MySQL, PostgreSQL, Microsoft SQL Server and SQLite. Redmine is easy to install and configure, we can use Apache or Nginx as web server. Redmine is very powerful and has many features like multi-language support, file management, wiki and a REST API. Redmine is one of the best OpenSource solutions to build your own project management with issue tracking.

Share this page:

26 Comment(s)

Add comment

Please register in our forum first to comment.

Comments

By: Israel

Very helpfull¡¡

Now, How do i have to configure nginx to SSL with redmine?? 

Thank you¡¡

By: Meow Meow

You can Google for ssl implementation.

By: Raouf Ben Hassine

Hello,

Thank you for this guide.

Do I execute all commands as root? the first command is sudo su. After, you don't specify if one should run the commands from his user account or as root (sudo su) though sometimes the commands are preceeded with sudo.

 

Thanks

By: joshuafr

Great article!

You should append the

include vhost/*.conf;

must be included in the http section, and not at the end of the nginx.conf file.

 

By: Eugenio Cunha

Great article!

Thanks

By: Divakar Rajagopalan

Very Helpful Guide. Thank You.

While installing on Ubuntu 16.4.0 LTS i faced some problem in step 4. When trying  passenger-install-nginx-module , I was getting command not found.

$ cd /

$ find -name passenger-install-nginx-module

$ rvmsudo [path found in previous command]/passenger-install-nginx-module

hope this is helpful. please update the guide.

By: wchoule

access "localhost" but just see next page...

Welcome to nginx!

If you see this page, the nginx web server is successfully installed and working. Further configuration is required.

For online documentation and support please refer to nginx.org. Commercial support is available at nginx.com.

Thank you for using nginx.

----------------------------------------------------------------------------------

what's wrong? please....

By: Tsetso

We're sorry, but something went wrong.

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

By: Vlad Marchuk

Not work after reboot For "create database redmine;" try use: "CREATE DATABASE redmine CHARACTER SET utf8;"

By: p1ter

Please help. 

I have "Welcome to nginx!" too =-( 

Thank you very much

By: Chris

in the redmin.conf, place a ; at the end of the "redmine.me" (or offcourse your own domain

By: brewok

Hi,

How to install redmine with apache ?

By: Vinod

After successfully installed above all command i am unable to browse redmine

i am getting below message

Welcome to nginx!

If you see this page, the nginx web server is successfully installed and working. Further configuration is required.

For online documentation and support please refer to nginx.org.Commercial support is available at nginx.com.

Thank you for using nginx.

By: Digitalgg

https://www.phusionpassenger.com/library/install/nginx/install/oss/jessie/ <--- use this to install passenger on existing nginx! :)

By: vinod

Please help me to configure e-mail notification

By: jl

I have that problem of getting the nginx default page too and I don't know even what to google for. redmine.conf points to the right directory and I would expect this to work or at least give a different kind of error message. Did anyone else find a sulution for this?

By: waveduke

For everyone who is having troubles with the nginx configuration when installing redmine into a subdirectory on your localhost machine:The path where all your web projects are: /var/www/

The path where redmine is installed: /var/www/redmine

nginx.conf:

server {

        listen       80;

        server_name  localhost;

 

        location / {

            root   html;

            index  index.html index.htm;

        }

 

        # Redmine

        location ~ ^/redmine(/.*|$) {

            alias /var/www/redmine/public$1; 

            passenger_base_uri /redmine;

            passenger_app_root /var/www/redmine;

            passenger_document_root /var/www/redmine/public;

            passenger_enabled on;

 

        }

 

        #error_page  404              /404.html;

 

        # redirect server error pages to the static page /50x.html

        #

        error_page   500 502 503 504  /50x.html;

        location = /50x.html {

            root   html;

        }

}

 

Now you can access Redmine on http://localhost/redmine

 

Hope that helps...

By: taesung

i don't see index.html in /var/www/redmine/public/

so accese error occured 403 fobbiden.

how do i get index.html of redmine.  please help me..

By: joaoocb

Hello,

It's importante to set user as www-data in nginx.conf file. You should also add "passenger_user_switching off;", "passenger_default_user www-data;" and "passenger_default_group www-data" to the http section. This way, user www-data will start nginx worker process and passenger processes avoiding Permission Denied errors.

By: med

 Hi,

I followed the steps described above on my VPS (Ubuntu 17.04 x64). I had a problem in step 4 (systemctl start nginx). The displayed error is as follows:

Job for nginx.service failed because the control process exited with error code.

See "systemctl status nginx.service" and "journalctl -x" for details.

If you can help me please

 

By: NootNoot

med:  I got the same error, due to Apache running.  Use systemctl stop httpd.service to stop Apache, then systemctl disable httpd.service to prevent it from starting at boot.  Use systemctl enable nginx.service to set nginx to start at boot.

By: Brian Blaze

Just to mention that at this point I get an error 

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

[email protected]:~$ curl -sSL https://get.rvm.io | sudo bash -s stable --ruby=2.3.3

Downloading https://github.com/rvm/rvm/archive/1.29.2.tar.gz

Downloading https://github.com/rvm/rvm/releases/download/1.29.2/1.29.2.tar.gz.asc

Found PGP signature at: 'https://github.com/rvm/rvm/releases/download/1.29.2/1.29.2.tar.gz.asc',

but no GPG software exists to validate it, skipping.

 

Upgrading the RVM installation in /usr/local/rvm/

Upgrade of RVM in /usr/local/rvm/ is complete.

 

# blaze,

#

#   Thank you for using RVM!

#   We sincerely hope that RVM helps to make your life easier and more enjoyable!!!

#

# ~Wayne, Michal & team.

 

In case of problems: https://rvm.io/help and https://twitter.com/rvm_io

 

Upgrade Notes:

 

  * No new notes to display.

 

bash: line 880: __rvm_print_headline: command not found

 

The problem is discussed here : https://github.com/rvm/rvm/issues/4068

By: ThongLe

Dear all,

I set up step by step as guide but can't restart nginx, so can you help me? 

[email protected]:/home/thong# systemctl status nginx.service

? nginx.service - The NGINX HTTP and reverse proxy server

   Loaded: loaded (/lib/systemd/system/nginx.service; disabled; vendor preset: e

   Active: failed (Result: exit-code) since Thu 2017-09-07 20:11:54 PDT; 11s ago

  Process: 1323 ExecStartPre=/opt/nginx/sbin/nginx -t (code=exited, status=1/FAI

 

Sep 07 20:11:54 ubuntu systemd[1]: Stopped The NGINX HTTP and reverse proxy serv

Sep 07 20:11:54 ubuntu systemd[1]: Starting The NGINX HTTP and reverse proxy ser

Sep 07 20:11:54 ubuntu nginx[1323]: nginx: [emerg] unknown directive "erver" in 

Sep 07 20:11:54 ubuntu nginx[1323]: nginx: configuration file /opt/nginx/conf/ng

Sep 07 20:11:54 ubuntu systemd[1]: nginx.service: Control process exited, code=e

Sep 07 20:11:54 ubuntu systemd[1]: Failed to start The NGINX HTTP and reverse pr

Sep 07 20:11:54 ubuntu systemd[1]: nginx.service: Unit entered failed state.

Sep 07 20:11:54 ubuntu systemd[1]: nginx.service: Failed with result 'exit-code'

By: Elwood

It's easy the error message says

nginx: [emerg] unknown directive "erver" in 

so you typed "erver" instead of "server" in the nginx configuration file.

By: saeed

Hi, I've installed 3.4 on ubuntu 18.04.

every thing looks fine but I get 500 error on account and setting pages. how can I fix?

By: Troy

Is there a particular way to upgrade to a new version of redmine after this install or can you just follow the Redmine instructions?

http://www.redmine.org/projects/redmine/wiki/RedmineUpgrade