Skip to content

Instantly share code, notes, and snippets.

@DevWurm
Forked from tessi/installation.md
Last active March 3, 2018 13:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save DevWurm/2400b784e788609a4dbb1bbe291deb31 to your computer and use it in GitHub Desktop.
Save DevWurm/2400b784e788609a4dbb1bbe291deb31 to your computer and use it in GitHub Desktop.
Install OpenProject 6 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.2.5 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.2.5/bin:$PATH
export PATH=$HOME/.gem/ruby/2.2.5/bin:$PATH
export PATH=/package/host/localhost/nodejs-6.9.1/bin:$PATH
export PATH=$HOME/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
npm install -g npm@4.0

Verify that ruby --version gives you 2.2.5.

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 -b stable origin/stable/6
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:

cat <<'__EOF__' >> ~/.bash_profile
export SECRET_KEY_BASE=$(RAILS_ENV=production rake secret)
__EOF__
source ~/.bash_profile
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.2.5 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.2.5 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/.

@quazgar
Copy link

quazgar commented Jun 12, 2017

Has anyone had success adapting this to OpenProject 7.0? I only get a nearly empty page which just says "Powered by OpenProject". I replaced the ruby version in the PATH to 2.4, commented out the memcache option for the moment and am using a different port. No errors, only infos displayed in the logs of both openproject-web and openproject-worker.

@2martens
Copy link

The problem seems to be that the public directory is outside the DocumentRoot and therefore not accessible by Apache. In the manual installation example of OpenProject they assume that you set up a virtual server with its own document root inside the public directory but that is not possible for Uberspace. Therefore I assume that you need to tell OpenProject somehow to compile the assets inside the document root and access them there.

@quazgar
Copy link

quazgar commented Feb 28, 2018

I just tried the solution from your website, @2martens. It shows the plain html of the start page, but all other elements are not fetched, they all fail with a 404 error. You can test my current behaviour at https://quazgar2.centaurus.uberspace.de/

@quazgar
Copy link

quazgar commented Mar 3, 2018

Hi, I created a repo wih a script to automate the installation, it can be found here https://github.com/quazgar/openproject_install, feel free to clone and improve it. Disclaimer: Does not work yet for me.

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