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 is about how to install redmine 3.3 on ubuntu 16.04 VPS, you can also follow this tutorial install redmine 3.3 on a dedicate server or ubuntu desktop version.

Install Dependencies

at the terminal, input the bellow commands:

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

Install Ruby and RVM

In this step, we will install the latest RVM version and Ruby 2.3. Redmine 3.3 stable supports Ruby version 2.3, 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:// --recv-keys D39DC0E3

curl -L | bash -s stable --ruby=2.3.0  

Now we 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

Configure the MySQL Database for Redmine

in this step, we'll create a database and database user for redmine.

login to mysql:

mysql -uroot -p  

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 redmine@localhost identified by 'redmine';  
grant all privileges on redmine.* to redmine@localhost identified by 'redmine';  
flush privileges;  

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  

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".

Configure Nginx

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;
  root /var/www/redmine/public;
  passenger_enabled on;
  client_max_body_size      10m; # Max attachemnt size

use '#' to 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:

Description=The NGINX HTTP and reverse proxy server  
ExecStartPre=/opt/nginx/sbin/nginx -t  
ExecReload=/bin/kill -s HUP $MAINPID  
ExecStop=/bin/kill -s QUIT $MAINPID  

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    *               LISTEN      4871/nginx`  

Install Redmine

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

mkdir -p /var/www/  
cd /var/www/  
svn co redmine  
cd redmine  
cp config/configuration.yml.example config/configuration.yml  
cp config/database.yml.example config/database.yml  
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 Configure the MySQL Database For Redmine

  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  
sudo chmod -R 777 tmp/cache  

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 domain you've just deployed.

redmine login url is :http://redmine.domain/login/

default admin info: admin/admin

Truouble Shooting

if you are a non-English speaker, for example you're a Chinese, Japanese or Korean, you may found when you want to save data which is written in your language, redmine will throw out a internal server error 500

you may get this error when you process RAILS_ENV=production bundle exec rake redmine:load_default_data
when you get this error, check nginx's error.log at /opt/nginx/logs/

It will probably shows the following error:

Mysql2::Error: Incorrect string value: '\xCC\x81fir ...' for column 'roles' at row 1: UPDATE merge_request_diffs SET state = 'empty', st_commits = '---\n  

It's a mysql connection encoding problem.

The solution is changing tables' character. Notice: you should change all the tables in redmine database which is a great work. Because redmine database has 55 tables.

So I write a sql file to do this job, all you have to do is login into mysql and import the sql.

download the sql script: download