Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Install OpenProject (latest) with Memcached on Uberspace

Install OpenProject (latest) with Memcached on Uberspace

Thanks to @tessi and @jesk for their gists:

Some advantages to these gists:

  • Use Memcached as cache server
  • Works with latest version of OpenProject (6.1 and newer)
  • Removed unnecessary instructions

Prerequisites

daemontools

If not already done, we initialize the daemontools first:

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

node.js

The latest versions of node.js are already preinstalled on theserver. You just have to add it to your $PATH. We use version 6, as it's the latest LTS release.

cat <<__EOF__ > ~/.bash_profile
export PATH=/package/host/localhost/nodejs-6/bin:$PATH
__EOF__

source ~/.bash_profile

npm

We use npm (and have to update it with the global option), so we need to give it a config to not make our home directory visible to other users on the server:

cat > ~/.npmrc <<__EOF__
prefix = $HOME
umask = 077
__EOF__

Updating to the latest version

The current version of npm distributed on Uberspaces is a bit old and has a fatal bug, so we need to install our own:

npm install npm@latest -g

Tell the shell to use our installed version instead of the one from Uberspace. We have to do this, because the first occurence within $PATH locations is used, so we need to add our own installation at the beginning:

cat <<__EOF__ > ~/.bash_profile
# Reread home directory for newer version of npm
export PATH=$HOME/bin:$PATH
__EOF__

Installing Memcached

Uberspace is a shared hosting service, so a global Memcached is a security risk. We need to install our own memcached (thanks to Florian Schmidt instructions; updated according to some instructions from Uberspace via Twitter:

toast arm https://memcached.org/files/memcached-1.4.33.tar.gz

Memcached daemon

And to manage it with the damontools, we have to set up its run file:

mkdir ~/etc/memcached
mkdir ~/etc/memcached/run-memcached
cd ~/etc/memcached/run-memcached/

cat <<__EOF__ > run
exec memcached -s $HOME/memcached.socket 2>&1
__EOF__

chmod +x run

And the logging daemon:

mkdir ~/etc/memcached/run-memcached/log
cd ~/etc/memcached/run-memcached/log/

cat <<__EOF__ > run
exec multilog t ./main
__EOF__

chmod +x run

Finally, we link the run script to start the daemon:

ln -s ~/etc/memcached/run-memcached ~/service/run-memcached

OpenProject

Installation

Please read the official installation instructions first!

I prefer to install OpenProject within ~/ror/openproject, but you may change this to any directory within your user directory (but not within /var/www/virtual/!).

mkdir ~/ror/openproject
cd ~/ror/openproject

Clone the OpenProject Community Edition git repository from GitHub (branch stable/6 is the current release branch with version 6.1 and so on):

git clone https://github.com/opf/openproject-ce.git --branch stable/6 --depth 1
cd openproject-ce/

Install OpenProject with all dependencies:

RAILS_ENV=production bundle install --without postgres sqlite development test therubyracer docker
npm install

Configuration

Copy the example configuration files (you have to edit them both after this step):

cp config/database.yml.example config/database.yml
cp config/configuration.yml.example config/configuration.yml

config/database.yml

In the database configuration file, you have to add your username, password (get it from your .my.cnf). Your database has to be prefixed with your username, following an underscore. For example (change %username with your username and %password with your password):

production:
  adapter: mysql2
  database: %username_openproject
  host: localhost
  username: %username
  password: %password
  encoding: utf8

You should do this for all environments (production, development, test).

config/configuration.yml

The email_delivery_method is sendmail, rails_cache_store :memcache and you have the cache_memcache_server should point to your memcached.socket file used in the Memcached installation (e.g. "/home/%username/memcached.socket"). All entries beginning with smtp_ should be commented out.

A minimal configuration file looks like (you can use this instead of copying the example file):

default: 
  email_delivery_method: sendmail
  rails_cache_store: :memcache
  cache_memcache_server: "/home/%username/memcached.socket"

config/environments/production.rb

You have to tell ruby to serve the static files itself: Change config.public_file_server.enabled = false to true!

Database initialization

Run last installation steps and seed sample data:

RAILS_ENV=production bundle exec rake db:create
RAILS_ENV=production bundle exec rake db:migrate
RAILS_ENV=production LOCALE=de bundle exec rake db:seed

With the last command (db:seed), you get a demo project and some useful status strings. With LOCALE, you can change the language of these (e.g. LOCALE=fr for French or without for english). Just ignore this step and you have no sample data.

OpenProject daemons

First of all, choose a port between 61000 and 65535 (OpenProject use its own server, so we have to redirect the traffic to this port) and then test, if it's not already in use (the command returns nothing, if it's free):

netstat -tulpen | grep %port

Change %port with your selected port number.

Add the run script for your daemons (change username with your username!):

mkdir ~/etc/openproject
mkdir ~/etc/openproject/run-openproject-web
cd ~/etc/openproject/run-openproject-web/

cat << __EOF__ > run
#!/bin/sh

# These environment variables are sometimes needed by the running daemons
export USER=username
export HOME=/home/username
 
# Include the user-specific profile
. $HOME/.bash_profile
 
# Now let's go!
export RAILS_ENV="production"
export OPENPROJECT_PATH="$HOME/ror/openproject/openproject-ce"
 
cd $OPENPROJECT_PATH/

__EOF__

chmod +x run

And, once again, the logging:

mkdir log

cat <<__EOF__ > log/run
exec multilog t ./main
__EOF__

chmod +x log/run

Copy all files for the worker daemon:

cd ..
cp -r run-openproject-web/ run-openproject-worker/

Add the actual commands to both run scripts:

cat <<__EOF__ > run-openproject-web/run
# Generate secret key for cookies
export SECRET_KEY_BASE=$(rake secret)

exec bundle exec unicorn --port %port --env production 2>&1
__EOF__

cat <<__EOF__ > run-openproject-worker/run
exec bundle exec rake jobs:work 2>&1
__EOF__

Link the run scripts to start the daemons (and OpenProject):

ln -s ~/etc/openproject/run-openproject-web ~/service/run-openproject-web
ln -s ~/etc/openproject/run-openproject-worker ~/service/run-openproject-worker

Redirection of all traffic to OpenProject

Add an .htaccess file to your document root for a RewriteRule with Proxy. Change the directory, if you want to access it within a subdirectory.

cd ~/html

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

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

You did it!

Just open the url of your uberspace (e.g. username.server.uberspace.de) or domain, where you added your redirect .htaccess and immediately change your admin password! Your current username and password is admin.

Now, you have to configure your installation to fit your needs. Some things you may change in the system configuration:

  • General
  • Hostname (the example may work)
  • Protocol (you should set it to HTTPS)
  • Authentication
  • login required (check for private installations)
  • self registration (deactivate for private installations)
  • Notifications
  • mail from

Please be aware that if you set/change a password for a user within the admin panel, it will be sent in clear text via email!

Logging

You can use zcat -f ~/service/run-openproject-web/log/main/* | tai64nlocal | less to see the logging of the OpenProject web service. With svc -du ~/service/run-openproject-web, you can start and stop the service immidiately to reload configuration.

@biolauri

This comment has been minimized.

Copy link
Owner Author

@biolauri biolauri commented Jan 14, 2017

Just want to add how to update your OpenProject installation (as the official upgrade manual lacks some information). As OpenProject 6.1 changed the Ruby version and did some advances to the MySql configuration file, you have to do some required changes, if you upgrade from a version prior to 6.1 (see the official ugrade manual).
Note: As the Installation Guide is only tested for OpenProject 6.1 and higher, it's the same for these update hints.

Updates

  1. Change to the directory, you installed OpenProject (e.g. cd ~/ror/openproject/openproject-ce)
  2. Get the latest changes via git:
    git fetch && git checkout stable/6
    git pull
    OpenProject 6.x is being released under the branch stable/6.
  3. Install new dependencies:
    RAILS_ENV=production bundle install --without postgres sqlite development test therubyracer docker
    npm install
  4. Update database:
    RAILS_ENV=production bundle exec rake db:migrate
    RAILS_ENV=production LOCALE=de bundle exec rake db:seed
    You can change the language with the LOCALE-variable.
  5. Restart OpenProject:
    touch tmp/restart.txt
    svc -du ~/service/run-openproject-web
@Tschoepler

This comment has been minimized.

Copy link

@Tschoepler Tschoepler commented Mar 29, 2017

Hi,

thanks for this great manual! Unfortunately I get stuck at the very end and can't seem to fix the issue. Maybe you had this problem yourself and can help me? Any tip is much appreciated.

The services start fine and the port rediretion works also. Now when I open the domain I only get the <div id="footer"> rendered. Hence, the browser just shows "Powered by OpenProject".

However the <div id="wrapper"> and its content is actually output and visible in the source but CSS defines display = none;.

Also the console outputs these three errors:

ReferenceError: OpenProject is not defined[Learn More]  tsp4.adhara.uberspace.de:26:7
ReferenceError: jQuery is not defined[Learn More]  tsp4.adhara.uberspace.de:38:9
ReferenceError: jQuery is not defined[Learn More]  tsp4.adhara.uberspace.de:453:1
@quazgar

This comment has been minimized.

Copy link

@quazgar quazgar commented Jun 6, 2017

The .bash_profile command should probably be (note the >> and the escaped dollar $ sign):

cat <<__EOF__ >> ~/.bash_profile
export PATH=/package/host/localhost/nodejs-6/bin:\$PATH
__EOF__

Note that you can probably get the original ~/.bash_profile from /etc/skel/.bash_profile.

Edit: Shouldn't this also be the case for modifying run-openproject-web/run and the ...-log sister script?

@SebastianHuter

This comment has been minimized.

Copy link

@SebastianHuter SebastianHuter commented May 4, 2018

Hey @Tschoepler - I have the same problem. It only shows "Powered by OpenProject". Did you find any solution for this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.