Skip to content

Instantly share code, notes, and snippets.

@jesk
Forked from tessi/installation.md
Last active December 18, 2016 05:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jesk/4a9358690087dcc78a59 to your computer and use it in GitHub Desktop.
Save jesk/4a9358690087dcc78a59 to your computer and use it in GitHub Desktop.
Install OpenProject 4 on Uberspace

How to install OpenProject on uberspace.de

Step 1: Install dependencies

First we set-up all dependencies. We use ruby 2.1.4 and install gems using rvm.

cd
gpg --keyserver hkp://keys.gnupg.net --recv-keys D39DC0E3
\curl -sSL https://get.rvm.io | bash -s stable
source $HOME/.rvm/scripts/rvm
rvm autolibs disable
rvm install 2.1.4 # Compile and install ruby-2.1.4
rvm use --default 2.1.4
gem install bundler
cat <<'__EOF__' >> ~/.bash_profile
export LANG=en_US.UTF-8
source ~/.bash_profile
__EOF__

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

We continue with setting up ruby gems. Hint: Keep the '--without'-flag - otherwise you get errors e.g. when installing the gem 'pg' ("Can't find the 'libpq-fe.h header").

RAILS_ENV=production bundle install --without postgres:sqlite:test

We then install all npm packages, then all dependencies of OpenProject using the package manager bower:

npm install
bower install

Step 3: Configure Database and OpenProject

cat > config/configuration.yml <<__EOF__
production:
  email_delivery_method: sendmail

rails_cache_store: :memcache
__EOF__
cp config/database.yml.example config/database.yml

Edit the config/database.yml file to use the MySQL username and password 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 "yourname".

Here is an example database.yml file:

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

production:
  adapter: mysql2
  database: yourname_openproject
  host: localhost
  username: yourname
  password: <secret>
  encoding: utf8

development:
  adapter: mysql2
  database: yourname_openproject
  host: localhost
  username: yourname
  password: <secret>
  encoding: utf8

test:
  adapter: mysql2
  database: yourname_openproject_test
  host: localhost
  username: yourname
  password: <secret>
  encoding: utf8

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

RAILS_ENV=production bundle exec rake generate_secret_token

Now we create and prepare the database

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

Step 4: Setup OpenProject service

Next we create daemontools services for a web- and a worker-process. They will (re)start the OpenProject Server automatically in case the uberspace server needs to restart.

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.

Initialize svc on your uberspace:

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

Create the start script for the web-process (replace yourname with your uberspace user name):

cat <<  __EOF__ > ~/bin/openproject-web
#!/bin/bash
export HOME=/home/yourname
export RAILS_ENV=production
# This is needed to find gems installed with --user-install
export USER=yourname
# activate rvm
. $HOME/.bash_profile
. ~/.rvm/scripts/rvm
. ~/.rvm/scripts/rvm use 2.1.4
# Get into the project directory and start the Rails server
cd $HOME/apps/openproject
exec $HOME/.rvm/gems/ruby-2.1.4@global/bin/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 (once more replace yourname with your uberspace user name):

cat <<__EOF__ > ~/bin/openproject-worker
#!/bin/bash
export HOME=/home/yourname
export RAILS_ENV=production
# This is needed to find gems installed with --user-install
export USER=yourname
# activate rvm
. $HOME/.bash_profile
. ~/.rvm/scripts/rvm
. ~/.rvm/scripts/rvm use 2.1.4
# Get into the project directory and start the Rails server
cd $HOME/apps/openproject
exec $HOME/.rvm/gems/ruby-2.1.4@global/bin/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 (yourname.yourhost.uberspace.de) and you should see an OpenProject page waiting for you. If you want to serve it at a subdomain (e.g. openproject.yourname.yourhost.uberspace.de) precede the RewriteRule with the following line:

RewriteCond %{HTTP_HOST} ^openproject\. [NC]

You can log in with username admin and password admin. Please change the default admin password as soon as possible.

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

Troubles, Feedback

If you have troubles installing OpenProject:

@tessi
Copy link

tessi commented Dec 29, 2014

Hi @jesk, thanks for the update!

By the way, I've built an automated script out of a mixture of our guides. Look here: https://gist.github.com/tessi/c429a4c34cefb6c69ee7#file-readme-md

@azrdev
Copy link

azrdev commented Aug 11, 2015

is there a reason you compile & install ruby yourself, instead of relying on their installation in /package/host/localhost/ruby*?

@biolauri
Copy link

@azrdev: Uberspace supported own ruby installations in /package/host/localhost/ruby* not at the time, this How To was written, so you had to do this by yourself. As you mentioned, you can now rely perfectly on their instalations!

I did a knew approach and wrote my instructions down to share it. It works with latest OpenProject version and integrates with Memcached. I hope, this helps! :)

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