Skip to content

Instantly share code, notes, and snippets.

@tessi
Last active July 30, 2020 11:52
Show Gist options
  • Save tessi/466308e59e117d9fb34e to your computer and use it in GitHub Desktop.
Save tessi/466308e59e117d9fb34e to your computer and use it in GitHub Desktop.
Install OpenProject on uberspace.de

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 PATH=/package/host/localhost/nodejs-0.10.33/bin:$PATH
export LANG=en_US.UTF-8
__EOF__
cat > ~/.npmrc <<__EOF__
prefix = $HOME
umask = 077
__EOF__
cat > ~/.bowerrc <<__EOF__
{
  "interactive": false
}
__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
rails_cache_store: :memcache
__EOF__
cp config/database.yml.example config/database.yml

Edit the config/database.yml file to use your uberspace MySQL credentials. Copy the username and passwort from the ~/.my.cnf file. 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: <your uberspace name>_openproject
  host: localhost
  username: <your uberspace name>
  password: <secret>
  encoding: utf8

development:
  adapter: mysql2
  database: <your uberspace name>_openproject
  host: localhost
  username: <your uberspace name>
  password: <secret>
  encoding: utf8

We continue with setting up ruby gems.

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

We generate a secret token, and create/prepare the database:

RAILS_ENV=production bundle exec rake generate_secret_token db:create db:migrate db:seed

.. and prepare and bundle the assets

npm install -g bower
npm install
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.

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

Consider reading https://www.openproject.org/download/manual-installation/.

@tessi
Copy link
Author

tessi commented Dec 29, 2014

I've migrated this guide to an automated script.

https://gist.github.com/tessi/c429a4c34cefb6c69ee7#file-readme-md

@DevWurm
Copy link

DevWurm commented Feb 19, 2017

Awesome! Thank you very much.
I forked it and updated the guide to work with version 6 of OpenProject:
https://gist.github.com/DevWurm/2400b784e788609a4dbb1bbe291deb31

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