Installing Open Project on Debian 8 server


I’m going to install Open Project on a VPS (Virtual Private Server).

What is Open Project?

Open Project is an open source application you can use to manage projects. It’s used for software projects.

It supports Agile methodology, bug tracking and time tracking.

I’ll use it to manage projects meant to build applications for my clients.

I’ll describe here the procedure I followed to install Open Project on the Virtual Private Server where I run my own website and many others.

What do I need to perform the installation?

Of course a server. My VPS runs linux debian version 8.

A web server as well. In my case I have nginx already installed and running. I use it instead of Apache for better performance. Nginx’s version is 1.6.2.

A database. My server runs a mysql instance. Its version is 5.5.2.

Other products will be installed.

Where did I find information about the installation procedure?

I used this procedure: Manual installation of OpenProject 7.0 with Apache on Ubuntu 14.04. LTS

Since the procedure uses Apache, I had to find about how to configure nginx.

I found these instructions: Install OpenProject on Ubuntu 12.04 with nginx

Creating user and group

I need to create an user that will be running Open Project. This user will belong to a special group created on purpose for Open Project.

Here I create the user openproject and the group of the same name. I also assign a password to the user.

  1. root@FREEDOMANDCOURAGE:/etc# groupadd openproject
  2. root@FREEDOMANDCOURAGE:/etc# useradd --create-home --gid openproject openproject
  3. root@FREEDOMANDCOURAGE:/etc# passwd openproject

Creating the database

Open Project needs a database where to store information.

The database to create has name openproject. I create as well a myswl user of same name. Open Project will use it to access the database.

  1. CREATE DATABASE openproject CHARACTER SET utf8;
  2. CREATE USER 'openproject'@'localhost' IDENTIFIED BY 'your password here';
  3. GRANT ALL PRIVILEGES ON openproject.* TO 'openproject'@'localhost';
  4. FLUSH PRIVILEGES;

Installing needed packages

For Open Project to work, I have to install many needed packages.

Consider that the installation of bower may not be needed.

Node.js, which provides the command npm, was already present on my server.

  1. root@FREEDOMANDCOURAGE:/etc/apt# apt-get update
  2. root@FREEDOMANDCOURAGE:/etc/apt# apt-get install build-essential
  3. root@FREEDOMANDCOURAGE:/etc/apt# apt-get install -y libssl-dev libreadline-dev zlib1g-dev
  4. root@FREEDOMANDCOURAGE:/etc/apt# apt-get install libmysqlclient-dev
  5. root@FREEDOMANDCOURAGE:/etc/apt# npm install -g bower

Ruby on rails

Open Project is based on Ruby on Rails.

I’ll use rbenv to install a specific version of Ruby on Rails. Rbenv will be installed in the folder .rbenv under the home folder of the user openproject.

Ruby-build is a plugin to be used by rbenv to install Ruby on Rails.

The final “ruby –version” command shows that Ruby has been installed.

I had to increase my server’s memory for the installation to work. It needs 1Gb of memory and 512Mb of swap.

  1. root@FREEDOMANDCOURAGE:/etc# su openproject --login
  2. openproject@FREEDOMANDCOURAGE:~$ git clone https://github.com/sstephenson/rbenv.git ~/.rbenv
  3. openproject@FREEDOMANDCOURAGE:~$ echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.profile
  4. openproject@FREEDOMANDCOURAGE:~$ echo 'eval "$(rbenv init -)"' >> ~/.profile
  5. openproject@FREEDOMANDCOURAGE:~$ source ~/.profile
  6. openproject@FREEDOMANDCOURAGE:~$ git clone https://github.com/sstephenson/ruby-build.git ~/.rbenv/plugins/ruby-build
  7. openproject@FREEDOMANDCOURAGE:~$ rbenv install 2.4.1
  8. openproject@FREEDOMANDCOURAGE:~$ rbenv rehash
  9. openproject@FREEDOMANDCOURAGE:~$ rbenv global 2.4.1
  10. openproject@FREEDOMANDCOURAGE:~$ ruby --version
  11. ruby 2.4.1p111 (2017-03-22 revision 58053) [x86_64-linux]

Open Project

Now I’ll install Open Project itself.

These are the commands I gave to install Open Project.

  1. openproject@FREEDOMANDCOURAGE:~$ cd ~
  2. openproject@FREEDOMANDCOURAGE:~$ git clone https://github.com/opf/openproject-ce.git --branch stable/7 --depth 1
  3. openproject@FREEDOMANDCOURAGE:~$ cd openproject-ce
  4. openproject@FREEDOMANDCOURAGE:~/openproject-ce$ gem install bundler
  5. openproject@FREEDOMANDCOURAGE:~/openproject-ce$ bundle install --deployment --without postgres sqlite development test therubyracer docker
  6. openproject@FREEDOMANDCOURAGE:~/openproject-ce$ npm install

Configuring Open Project

Two files need to be configured.

They are located in the folder /home/openproject/openproject-ce/config and their names are database.yml and configuration.yml.

The file database.yml configures the access to the database. You have to specify the name of the database, the user Open Project uses to access mysql and the password.

This information goes to the ‘production’ section.

The file database.yml will look like this:

  1. production:
  2.    adapter: mysql2
  3.    database: openproject
  4.    host: localhost
  5.    username: openproject
  6.    password: your password
  7.    encoding: utf8
  8.    variables:

The file configuration.yml needs some settings so that Open Project can send emails.

This heavily depends on the smtp service you use to send emails from your server. In this case I’m using Google GMail.

This is the smtp section in configuration.yml:

  1. default:
  2.   # Outgoing emails configuration (see examples above)
  3.   email_delivery_method: :smtp
  4.   smtp_address: smtp.gmail.com
  5.   smtp_port: 587
  6.   smtp_domain: localhost
  7.   smtp_authentication: plain
  8.   smtp_user_name: "esantanche@gmail.com"
  9.   smtp_password: "your password here"
  10.   smtp_enable_starttls_auto: true

To create database.yml and configuration.yml I used database.yml.example and configuration.yml.example. You find these files in the same folder as the one where database.yml and configuration.yml are located.

Completing Open Project installation

Now that Open Project knows about the database it has to use, I can proceed to create the tables and anything else Open Project needs inside the database.

This is what I’m going to do know. During this phase I had to increase the server’s memory to 1Gb.

  1. openproject@FREEDOMANDCOURAGE:~/openproject-ce/config$ cd ~/openproject-ce
  2. openproject@FREEDOMANDCOURAGE:~/openproject-ce$ RAILS_ENV="production" ./bin/rake db:create
  3. openproject@FREEDOMANDCOURAGE:~/openproject-ce$ RAILS_ENV="production" ./bin/rake db:migrate
  4. openproject@FREEDOMANDCOURAGE:~/openproject-ce$ RAILS_ENV="production" ./bin/rake db:seed
  5. openproject@FREEDOMANDCOURAGE:~/openproject-ce$ RAILS_ENV="production" ./bin/rake assets:precompile
  6. openproject@FREEDOMANDCOURAGE:~/openproject-ce$ echo "export SECRET_KEY_BASE=$(./bin/rake secret)" >> ~/.profile
  7. openproject@FREEDOMANDCOURAGE:~/openproject-ce$ source ~/.profile

Configuring nginx

To access the application I need to configure the webserver, in my case nginx.

My job is simplified because I’m not installing Passenger, which is an application server that sits between the web server and ruby on rails. It’s purpose is to improve performances for installation with a lot of users. It’s not my case.

Nginx will connect directly to the Ruby on Rails server.

This is nginx configuration for Open Project:

  1. # openproject  
  2.  
  3.     # this is to redirect http requests to https ones
  4.     server {
  5.         listen         80;
  6.         server_name    openproject.emanuelesantanche.com;
  7.         return         301 https://$server_name$request_uri;
  8.     }
  9.  
  10.     upstream app_server {
  11.         server 127.0.0.1:3000 fail_timeout=0;
  12.     }
  13.  
  14.     server {
  15.         #listen 80;
  16.         listen 443 ssl;
  17.  
  18.         server_name openproject.emanuelesantanche.com;
  19.         root /home/openproject/openproject-ce/public;
  20.  
  21.         ssl_certificate /etc/letsencrypt/live/openproject.emanuelesantanche.com/cert.pem;
  22.         ssl_certificate_key /etc/letsencrypt/live/openproject.emanuelesantanche.com/privkey.pem;
  23.  
  24.         location / {
  25.                try_files $uri/index.html $uri.html $uri @app;    
  26.         }
  27.  
  28.         location @app {
  29.                 proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
  30.                 proxy_set_header Host $http_host;
  31.                 proxy_redirect off;
  32.                 proxy_pass http://app_server;
  33.         }
  34.     }

The configuration has been modified to use https with certificates provided by Let’s Encrypt.

Starting Ruby on Rails

For the application to work, I have to start Ruby on Rails. It will listen on the port 3000.

Nginx will communicate with it on the same port. You can see the port reference in nginx configuration.

To start Ruby on Rails I do:

  1. root@FREEDOMANDCOURAGE:~# su openproject --login                                      
  2. openproject@FREEDOMANDCOURAGE:~$ cd ~/openproject-ce                                        
  3. openproject@FREEDOMANDCOURAGE:~/openproject-ce$ bundler exec rails server -e production -d

Does it work?

Now I’m ready to test it!

Nginx is configured to serve the application at the url openproject.emanuelesantanche.com.

I went to my hosting provider’s control panel to configure the subdomain openproject.

It’s also possible, just for a quick test, to associate the server’s ip address to openproject.emanuelesantanche.com in your local hosts file.

I just open a browser at openproject.emanuelesantanche.com.

It works!

Running jobs

Ruby on Rails needs to run some jobs periodically. A line in crontab will do it.

Here it is:

  1. 48 * * * * PATH=/home/openproject/.rbenv/shims:$PATH; cd /home/openproject/openproject-ce; RAILS_ENV="production" ./bin/rake -q jobs:workoff >/dev/null 2>&1

In this case the crontab job gets executed once an hour. According to documentation, it should be run every minute.

Leave a comment

Your email address will not be published. Required fields are marked *