Redmine installation on Ubuntu 16.04

This manual will help you to install a fresh Redmine version from sources to the Ubuntu server.

1. Installing RVM (Ruby Version Manager)

$ sudo su
# apt-get install mysql-server libmysqlclient-dev git-core subversion imagemagick libmagickwand-dev libcurl4-openssl-dev 
# gpg --keyserver hkp://keys.gnupg.net --recv-keys D39DC0E3
# curl -L https://get.rvm.io | bash -s stable --ruby=2.3
Now, you should load the RVM
# source /usr/local/rvm/scripts/rvm
# echo '[[ -s "/usr/local/rvm/scripts/rvm" ]] && source "/usr/local/rvm/scripts/rvm"' >> ~/.bashrc

2. Installing Phusion Passenger and Nginx

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

Configuring Nginx

# systemctl stop nginx
# curl https://raw.githubusercontent.com/makevoid/nginx-passenger-ubuntu/master/nginx/nginx.service > /lib/systemd/system/nginx.service
# systemctl daemon-reload
# systemctl enable nginx
# nano /opt/nginx/conf/nginx.conf

Replace server section for port 80

server {
  listen  80;
  server_name [your_server_domain_name] # redmine.com;
  root /var/data/redmine/public;
  passenger_enabled on;
  client_max_body_size      10m; # Max attachemnt size
}

Restart nginx

# systemctl stop nginx
# systemctl start nginx

Setting a secure connection (HTTPS) in Nginx

Using HTTPS may provide better information privacy. Here we give an instruction how to create a self-signed SSL certificate for Nginx in Ubuntu 16.04. This self-signed certificate will encrypt communication between your server and any users.

In order to be able to perform the setting, you need a non-root user with sudo privileges.

To create a self-signed key and certificate pair with OpenSSL, use this command:

$ sudo openssl req -x509 -nodes -days 365 -newkey rsa:2048 -keyout /etc/ssl/private/nginx-selfsigned.key -out /etc/ssl/certs/nginx-selfsigned.crt
  • openssl: basic OpenSSL tool for creating and managing keys, certificates etc.
  • req: request X.509 certificate signing; creates a new X.509 certificate
  • -x509: creates a self-signed certificate instead of generating a certificate signing request
  • -nodes: skips the option to secure the new certificate with a passphrase. Nginx should read the file without user intervention at server startup. A passphrase would prevent this, as you would have to enter it after every restart.
  • -days 365: certificate validity period
  • -newkey rsa:2048: to generate the new certificate and the new key simultaneously. Key needs to be created along with the certificate. (The rsa:2048 results in an RSA key that is 2048 bits long.)

-keyout: path for the generated private key file

-out: path for the generated certificate file

During the process, you will have to type answers of some questions. These would be like the shown below:

Country Name (2 letter code) [AU]:
State or Province Name (full name) [Some-State]:
Locality Name (eg, city) []:
Organization Name (eg, company) [Internet Widgits Pty Ltd]:
Organizational Unit Name (eg, section) []:
Common Name (e.g. server FQDN or YOUR name) []:
Email Address []:

The most important question is Common Name (e.g. server FQDN or YOUR name), where you type the server domain name or public IP Address.

3. Installing Redmine

# mkdir /var/data
# cd /var/data/
# svn co http://svn.redmine.org/redmine/branches/3.4-stable redmine
# cd /var/data/redmine

Database configuration

# nano config/database.yml

Add following lines

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

development:
  adapter: mysql2
  database: redmine 
  host: localhost
  username: redmine
  password: redmine
  encoding: utf8

4. Plugins installation

Unarchive plugins to /plugins/ folder
# cd /var/data/redmine
# gem install bundler --no-ri --no-rdoc
# bundle install

5. Configuring redmine

Setup redmine folder permissions

# cd /var/data/redmine
# mkdir public/plugin_assets
# chown -R www-data:www-data files log tmp public/plugin_assets config.ru
# chmod -R 755 files log tmp public/plugin_assets

Create database

# mysql -u root -p

Execute following lines to MySQL

CREATE DATABASE redmine character SET utf8;
CREATE user 'redmine'@'localhost' IDENTIFIED BY 'redmine';
GRANT ALL privileges ON redmine.* TO 'redmine'@'localhost';
exit

Migrate database

# cd /var/data/redmine
# bundle exec rake db:migrate
# bundle exec rake redmine:plugins

If you want to, you can download some default data (statuses, workflows, trackers) to be able to start to work with your Redmine right after the first login. To do this, run the following command:

# bundle exec rake redmine:load_default_data RAILS_ENV=production

It will ask you about preferable language and then download some default package of data to your Redmine.

Generate session store

# bundle exec rake generate_secret_token 

Start web server

# service nginx start

Restart Redmine

# touch /var/data/redmine/tmp/restart.txt
Was this article helpful? Yes  No
832 from 877 found this helpful