/etc OSBN/Ubuntuusers Planet XING / LinkedIn / Amazon

Install OwnCloud on a managed web server

When it is necessary to share files between multiple devices and persons OwnCloud is a good alternative for Dropbox.

The open-source software that also supports WebDAV can also be installed on a managed web server – for this purpose the project offers a installation script which is transfered to the server using FTP: [right-click and save as!]

Fehlerhafte PHP-Konfiguration
Fehlerhafte PHP-Konfiguration

Depending on the configuration of the web server there might be some pitfalls. For example, my web server uses PHP 5.2 by default – OwnCloud forceful needs PHP 5.3 or higher to work. Beyond that a special function called “PHP magic quotes” needs to be disabled to run OwnCloud properly.

The installation script aborted with an appropriate error message. In my case editing the .htaccess configuration file did it:

#Use PHP 5.3 and set some PHP flags
AddHandler php53-cgi .php
php_flag magic_quotes_gpc off
...

The first code line is a characteristic of my hoster – it forces the web server to use PHP 5.3. The second line disables the “PHP magic quotes” function.

After pressing the F5 button the error messages disappeared and the installation assistant asked for a folder name wherein OwnClound shall be installed. It seems to be important that this directory does not exist, yet – if it already exists the assistant aborts with an unlink() error. Beyond that some files were missing and so the installation was corrupt.

After completing the installation clicking the “Finish” button forwarded to the administration interface of the new OwnCloud installation – or more specifically to the following script: /index.php/post-setup-check. On that page I saw the same two error messages regarding PHP errors again. So the new .htaccess configuration file needed to be modified again (see above). Pressing the F5 again after customizing the configuration file made the message disappear.

Authentification using WebDAV was a way more tricky. Like Baikal OwnCloud also uses SabreDAV for authentification – and this library doesn’t work on all managed web servers as expected; but this seems to be a problem of the software configuration made by the hoster.

You have the same problem if you’re having issues with connecting to your OwnCloud installation using the official client – all requests are dropped because of invalid log-in data. On a blog I found a workaround for this issue.

First of all you need to modify the .htaccess configuration file by adding the following line (ideally at the beginning):

RewriteRule .* - [env=REMOTE_USER:%{HTTP:Authorization},last]

After that you’re searching for the following source code in the /lib/base.php script:

//set http auth headers for apache+php-cgi work around if variable gets renamed by apache
if (isset($_SERVER['REDIRECT_HTTP_AUTHORIZATION']) && preg_match('/Basics+(.*)$/i', $_SERVER['REDIRECT_HTTP_AUTHORIZATION'], $matches))
{
list($name, $password) = explode(':', base64_decode($matches[1]));
$_SERVER['PHP_AUTH_USER'] = strip_tags($name);
$_SERVER['PHP_AUTH_PW'] = strip_tags($password);
}

Add the following if case:

if (isset($_SERVER['REDIRECT_REMOTE_USER']) && preg_match('/Basics+(.*)$/i', $_SERVER['REDIRECT_REMOTE_USER'], $matches))
{
list($name, $password) = explode(':', base64_decode($matches[1]));
$_SERVER['PHP_AUTH_USER'] = strip_tags($name);
$_SERVER['PHP_AUTH_PW'] = strip_tags($password);
}

Thanks a lot for sharing this workaround, Boris Schäfer! 🙂

Synchronisation mit Owncloud
Synchronisation mit Owncloud

After this customization using the official OwnCloud or other WebDAV clients works like a charm.

By the way: The WebDAV client integrated in Windows 7 isn’t able to connect to OwnCloud systems. In accordance with results of a short internet research the reason for this issue is that this WebDAV client isn’t able to authentificate using Basic authentification. I haven’t checked if this also applies to older or newer versions of the Windows WebDAV client.

Sharing is caring

Leave a Reply

Your email address will not be published. Required fields are marked *