Skip to content

Instantly share code, notes, and snippets.

@HeikoBornholdt
Forked from tessi/installation.md
Created July 29, 2014 13:10
Show Gist options
  • Save HeikoBornholdt/7b661df04e1ccc875ae4 to your computer and use it in GitHub Desktop.
Save HeikoBornholdt/7b661df04e1ccc875ae4 to your computer and use it in GitHub Desktop.

How to install OpenProject on uberspace.de

Follow those steps to install OpenProject on a fresh uberspace.

Step 1: Install dependencies

First we set-up all dependencies. We use ruby 2.1.2 and install gems in a user directory:

echo "gem: --user-install --no-rdoc --no-ri" > ~/.gemrc
cat <<'__EOF__' >> ~/.bash_profile
export PATH=/package/host/localhost/ruby-2.1.2/bin:$PATH
export PATH=$HOME/.gem/ruby/2.1.0/bin:$PATH
export LANG=en_US.UTF-8
__EOF__
source ~/.bash_profile

Verify that ruby --version gives you 2.1.2.

Step 2: Install OpenProject

Now it's time to install OpenProject:

mkdir apps; cd apps
git clone https://github.com/opf/openproject.git
cd openproject
git checkout stable
cat > config/configuration.yml <<__EOF__
production:
email_delivery:
  delivery_method: :sendmail
  sendmail_settings:
    location: /usr/sbin/sendmail
    arguments: -i
__EOF__
cp config/database.yml.example config/database.yml

Edit the config/database.yml file to use the MySQL credentials as displayed in the file ~/.my.cnf. Name your databases beginning with your uberspace username followed by an underscore and any name you like. For example: tessi_openproject if your uberspace account is "tessi".

Here is an example database.yml file:

# please make sure to replace "tessi" with your uberspace account name
# and change your password - you find it on your uberspace in ~/.my.cnf

production:
  adapter: mysql2
  database: tessi_openproject
  host: localhost
  username: tessi
  password: <secret>
  encoding: utf8

development:
  adapter: mysql2
  database: tessi_openproject
  host: localhost
  username: tessi
  password: <secret>
  encoding: utf8

test:
  adapter: mysql2
  database: tessi_openproject_test
  host: localhost
  username: tessi
  password: <secret>
  encoding: utf8

We continue with setting up ruby gems.

cat > Gemfile.local <<__EOF__
gem 'unicorn'
gem 'rails_12factor'
__EOF__
gem install bundler
bundle install --path ~/.gem --without postgres:sqlite:test

We generate a secret token, which is unique for every installation. It secures OpenProject cookies.

bundle exec rake generate_secret_token

Now we create and prepare the database

bundle exec rake db:create --all
bundle exec rake db:migrate
RAILS_ENV=production bundle exec rake db:seed
RAILS_ENV=production bundle exec rake assets:precompile

Step 3: Start OpenProject server

Find a free port for your OpenProject installation. I use the port 61621 - you need to replace that number with your port in the following files. This is the port your OpenProject server will listen to. The uberspace-apache will redirect all requests to that port.

We set-up daemontools services for a web- and a worker-process. They will (re)start automatically in case the uberspace server needs to restart.

Initialize svc on your uberspace:

test -d ~/service || uberspace-setup-svscan

Create the start script for the web-process:

cat <<__EOF__ > ~/bin/openproject-web
#!/bin/sh
# This is needed to find gems installed with --user-install
export HOME=$HOME
# Include our profile to get Ruby 2.1.2 included in our PATH
. \$HOME/.bash_profile
# Get into the project directory and start the Rails server
cd \$HOME/apps/openproject
exec bundle exec unicorn --port 61621 --env production
__EOF__
chmod +x ~/bin/openproject-web
uberspace-setup-service openproject-web ~/bin/openproject-web

Create the start script for the worker-process:

cat <<__EOF__ > ~/bin/openproject-worker
#!/bin/sh
# This is needed to find gems installed with --user-install
export HOME=$HOME
# we're faster and use the right database in production
export RAILS_ENV=production
# Include our profile to get Ruby 2.1.2 included in our PATH
. \$HOME/.bash_profile
# Get into the project directory and start the Rails server
cd \$HOME/apps/openproject
exec bundle exec rake jobs:work
__EOF__
chmod +x ~/bin/openproject-worker
uberspace-setup-service openproject-worker ~/bin/openproject-worker

We will make your OpenProject installation public with a RewriteRule using a Proxy

cat > ~/html/.htaccess <<__EOF__
RewriteEngine On
RewriteCond %{HTTPS} !=on
RewriteCond %{ENV:HTTPS} !=on
RewriteRule .* https://%{SERVER_NAME}%{REQUEST_URI} [R=301,L]

RewriteRule (.*) http://localhost:61621/$1 [P]
__EOF__

Step 4: You're done

You're done. Open the URL of your uberspace and you should see an OpenProject page waiting for you. You can log in with username admin and password admin. Please, change the default admin password as soon as possible.

If something goes wrong, you find logs at the following places:

~/service/openproject-web/log/main/current
~/service/openproject-worker/log/main/current

You can restart your web-/worker-processes with:

svc -du ~/service/openproject-web
svc -du ~/service/openproject-worker

The -d stands for "down". -u for "up".

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment