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.
-
root@FREEDOMANDCOURAGE:/etc# groupadd openproject
-
root@FREEDOMANDCOURAGE:/etc# useradd –create-home –gid openproject openproject
-
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.
-
CREATE DATABASE openproject CHARACTER SET utf8;
-
CREATE USER ‘openproject’@‘localhost’ IDENTIFIED BY ‘your password here’;
-
GRANT ALL PRIVILEGES ON openproject.* TO ‘openproject’@‘localhost’;
-
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.
-
root@FREEDOMANDCOURAGE:/etc/apt# apt-get update
-
root@FREEDOMANDCOURAGE:/etc/apt# apt-get install build-essential
-
root@FREEDOMANDCOURAGE:/etc/apt# apt-get install -y libssl-dev libreadline-dev zlib1g-dev
-
root@FREEDOMANDCOURAGE:/etc/apt# apt-get install libmysqlclient-dev
-
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.
-
root@FREEDOMANDCOURAGE:/etc# su openproject –login
-
openproject@FREEDOMANDCOURAGE:~$ git clone https://github.com/sstephenson/rbenv.git ~/.rbenv
-
openproject@FREEDOMANDCOURAGE:~$ echo ‘export PATH=”$HOME/.rbenv/bin:$PATH”‘ >> ~/.profile
-
openproject@FREEDOMANDCOURAGE:~$ echo ‘eval “$(rbenv init -)”‘ >> ~/.profile
-
openproject@FREEDOMANDCOURAGE:~$ source ~/.profile
-
openproject@FREEDOMANDCOURAGE:~$ git clone https://github.com/sstephenson/ruby-build.git ~/.rbenv/plugins/ruby-build
-
openproject@FREEDOMANDCOURAGE:~$ rbenv install 2.4.1
-
openproject@FREEDOMANDCOURAGE:~$ rbenv rehash
-
openproject@FREEDOMANDCOURAGE:~$ rbenv global 2.4.1
-
openproject@FREEDOMANDCOURAGE:~$ ruby –version
-
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.
-
openproject@FREEDOMANDCOURAGE:~$ cd ~
-
openproject@FREEDOMANDCOURAGE:~$ git clone https://github.com/opf/openproject-ce.git –branch stable/7 –depth 1
-
openproject@FREEDOMANDCOURAGE:~$ cd openproject-ce
-
openproject@FREEDOMANDCOURAGE:~/openproject-ce$ gem install bundler
-
openproject@FREEDOMANDCOURAGE:~/openproject-ce$ bundle install –deployment –without postgres sqlite development test therubyracer docker
-
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:
-
production:
-
adapter: mysql2
-
database: openproject
-
host: localhost
-
username: openproject
-
password: your password
-
encoding: utf8
-
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:
-
default:
-
# Outgoing emails configuration (see examples above)
-
email_delivery_method: :smtp
-
smtp_address: smtp.gmail.com
-
smtp_port: 587
-
smtp_domain: localhost
-
smtp_authentication: plain
-
smtp_user_name: “esantanche@gmail.com”
-
smtp_password: “your password here”
-
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.
-
openproject@FREEDOMANDCOURAGE:~/openproject-ce/config$ cd ~/openproject-ce
-
openproject@FREEDOMANDCOURAGE:~/openproject-ce$ RAILS_ENV=“production” ./bin/rake db:create
-
openproject@FREEDOMANDCOURAGE:~/openproject-ce$ RAILS_ENV=“production” ./bin/rake db:migrate
-
openproject@FREEDOMANDCOURAGE:~/openproject-ce$ RAILS_ENV=“production” ./bin/rake db:seed
-
openproject@FREEDOMANDCOURAGE:~/openproject-ce$ RAILS_ENV=“production” ./bin/rake assets:precompile
-
openproject@FREEDOMANDCOURAGE:~/openproject-ce$ echo “export SECRET_KEY_BASE=$(./bin/rake secret)“ >> ~/.profile
-
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:
-
# openproject
-
-
# this is to redirect http requests to https ones
-
server {
-
listen 80;
-
server_name openproject.emanuelesantanche.com;
-
return 301 https://$server_name$request_uri;
-
}
-
-
upstream app_server {
-
server 127.0.0.1:3000 fail_timeout=0;
-
}
-
-
server {
-
#listen 80;
-
listen 443 ssl;
-
-
server_name openproject.emanuelesantanche.com;
-
root /home/openproject/openproject-ce/public;
-
-
ssl_certificate /etc/letsencrypt/live/openproject.emanuelesantanche.com/cert.pem;
-
ssl_certificate_key /etc/letsencrypt/live/openproject.emanuelesantanche.com/privkey.pem;
-
-
location / {
-
try_files $uri/index.html $uri.html $uri @app;
-
}
-
-
location @app {
-
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
-
proxy_set_header Host $http_host;
-
proxy_redirect off;
-
proxy_pass http://app_server;
-
}
-
}
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:
-
root@FREEDOMANDCOURAGE:~# su openproject –login
-
openproject@FREEDOMANDCOURAGE:~$ cd ~/openproject-ce
-
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:
-
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.