Installing flarum on netcup shared hosting

To successfully install the forum software flarum on netcups shared hosting, a few unintuitive steps are nesseccary.

Install composer

To have the php composer binary availabe on your ssh command line, you have to download it manually and put it into your PATH environment variable. Since you cannot write to any folders already present in your PATH, you have to extend it.

If you do not already have a file /.profile, go ahead and create it. The following will prepend the path /.local/bin to your existing PATH. You’ll see later, why it is important to prepend it rather than append it.

export PATH=/.local/bin:$PATH

For this script to take effect, you have to restart your terminal session.
Now, download composer into this folder:

cd /.local/bin
curl -sS | php
chmod a+x composer.phar
mv composer.phar composer

Congratulations, you can now use composer globally.

Set another php cli version

For some reason the version of the php cli deviates from the version set in the web control panel and is older. In fact, it is so old that flarum will complain and not even install. That’s because an old binary is referenced in /bin.

/> ls -la /bin/ | grep php
php -> /usr/local/php72/bin/php

Luckily we already added a custom bin folder to our PATH. And now it is important that we prepended it, so it will take precedence over the other entries.

cd /.local/bin
ln -s /usr/local/php80/bin/php php

Restart your terminal session and you will have the new version \o/

Flarum and php open_basedir

Flarums public files reside in the public folder and only that should be delivered by the webserver. This means that the document root of your flarum domain is set to the public/ subfolder.

While this makes perfectly sense, it violates the default value for the open_basedir setting that only allows files to be accessed in and under your document root.

Luckily netcup provides us with a way to change that value. In your web control panel go the php settings for your domain and change the value for open_basedir. For me only one other option was available that enables access to the complete webhosting root.

And there we go, flarum now runs!

If for some reason you don’t see the install screen, you can do it via the command line like this in the folder where you installed flarum:

./flarum install