Owncloud

From Segfault
Jump to navigation Jump to search

Prerequisites

We need at least[1] the following:

  • webserver
  • php5 (>= 5.3), php5-gd, php-xml-parser, php5-intl, php5-curl
  • php5-sqlite (>= 3) or php5-mysql or php5-pgsql

A webserver should be already installed, let's install the rest:

apt-get install php5 php5-gd php-xml-parser php5-intl php5-sqlite php5-mysql php5-curl curl
yum install php-fpm php-gd php-xml php-intl php-mysqlnd 

The webserver should be somewhat secured.[2] For Lighttpd something like the following should do:

$HTTP["url"] =~ "^/owncloud/data/" {
        url.access-deny = ("")
}

$HTTP["url"] =~ "^/owncloud($|/)" {
       dir-listing.activate = "disable"
}

Installation

Source

Although there a packages available[3] for various operating systems, let's try to install manually[1]:

$ wget http://download.owncloud.org/community/owncloud-5.0.7.tar.bz2{,.md5}
$ md5sum -c owncloud*.tar.bz2.md5 < owncloud*.tar.bz2
-: OK

Extract into document root:

tar -C /var/www/ -xvjf owncloud*.tar.bz2
cd /var/www/owncloud && rm -f AUTHORS COPYING* README

Create missing directories & adjust permissions:

mkdir -m0770 -p apps config data
chmod g+w apps config data
sudo chown :www-data apps config data

When installing from a development repository:[4]

git clone git://github.com/owncloud/core.git owncloud-core-git
git clone git://github.com/owncloud/apps.git owncloud-apps-git
git clone git://github.com/owncloud/3rdparty.git owncloud-3rdparty-git

Add some applications to it:[5]

git clone https://github.com/owncloud/calendar.git owncloud-calendar-git
git clone https://github.com/owncloud/contacts.git owncloud-contacts-git
git clone https://github.com/owncloud/notes.git owncloud-notes-git

Extract a tagged version into document root:

VERSION=v6.0.1
cd owncloud-core-git
git archive --format=tar --prefix=owncloud/ $VERSION | tar -C /var/www -xvf -

The applications:

for d in 3rdparty apps calendar contacts notes; do
cd ../owncloud-"$d"-git
git archive --format=tar --prefix=$d/ $VERSION | tar -C /var/www/owncloud -xvf -

Careful! Not every application might provide tagged releases! Use HEAD instead of $VERSION instead. Not every application might have caught up the the same tag as core!

cd /var/www/owncloud
mkdir -m0770 data
chmod -R o-rwx config/ data/ apps/
sudo chown -R www-data:www-data config/ data/ apps/

Now point the browser to the installation directory and a small setup routine should start.

Packages

When using Debian packages[6] the upgrade process needs a little help too:

$ grep ^deb /etc/apt/sources.list.d/owncloud.list 
deb http://download.opensuse.org/repositories/isv:/ownCloud:/community/Debian_8.0/ /
deb http://download.opensuse.org/repositories/isv:/ownCloud:/desktop/Debian_8.0/   /

Add the repository keys:

curl -L http://download.opensuse.org/repositories/isv:ownCloud:community/Debian_8.0/Release.key | sudo apt-key add -
curl -L http://download.opensuse.org/repositories/isv:ownCloud:desktop/Debian_8.0/Release.key   | sudo apt-key add -

Update & install:

$ sudo apt-get update
$ sudo apt-get install owncloud

Note: there's an extra repository for the owncloud-client!

The last Debian upgrade moved some files around because Owncloud was stored on encrypted storage, i.e. not on /var/www/owncloud. Here's how to fix this:

mkdir -p /encrypted/owncloud/config
sudo mv /var/www/owncloud/data   /encrypted/owncloud/data
sudo mv /var/www/owncloud/config/config.php /encrypted/owncloud/config/

ln -s /encrypted/owncloud/data /var/www/owncloud/data
ln -s /encrypted/owncloud/config/config.php /var/www/owncloud/config/config.php

Once the files are in place, apt-get upgrade should work just fine. Sometimes the update process might get stuck[7] and the following message is printed:

This ownCloud instance is currently being updated, which may take a while.

Try again with:

$ cd /var/www/owncloud
$ sudo -u www-data php ./occ upgrade
Turned on maintenance mode
Checked database schema update
Updated database
Turned off maintenance mode
Update successful

Maintenance mode should now be disabled:

$ sudo grep maintenance config/config.php 
  'maintenance' => false,

Configuration

File uploads may be limited[8] by the webserver and PHP. In php.ini, the following should help:

upload_max_filesize  = 1024M
post_max_size        = 1280M            # Should be somewhat bigger than upload_max_filesize
; max_execution_time =   300
; max_input_time     =   300
; memory_limit       =  512M

Memory caching

To enable APCu[9], add the following to ../owncloud/config/config.php:[10]

'memcache.local' => '\OC\Memcache\APCu',

Cron

Activate Cron Jobs in your OC configuration:

  1. Login as "admin" to the OC WebUI
  2. Click on "Admin" → "Cron" and select "Cron" to "Use system's cron service to call the cron.php file every 15 minutes"

We have to create a system cron job too:

*/15  * * * *   www-data /usr/bin/php -f /var/www/owncloud/cron.php

Note: the following error may be encountered:

> It was not possible to execute the cronjob via CLI. The following technical errors have appeared:
> PHP is configured to populate raw post data. Since PHP 5.6 this will lead to PHP throwing notices for
> perfectly valid code.
> To fix this issue set always_populate_raw_post_data to -1 in your php.ini

Fix the php.ini as suggested until this gets fixed:

$ grep -r always_populate_raw_post_data /etc/php5/
/etc/php5/cli/php.ini:always_populate_raw_post_data = -1
/etc/php5/fpm/php.ini:always_populate_raw_post_data = -1

Usage

  • Install ownCloud for Andoid. Upon the first start, put the following into the "Server address" field:
https://owncloud.example.org:PORT/cloud

The protocol, the port and the /cloud part may be omitted if the ownCloud installation has been installed differently.

Update

This is for updates between point releases, e.g. 6.0.3 to 6.0.4. The update process, in short:

export DOCROOT=/var/www/owncloud
sudo chown -R bob:users $DOCROOT

VERSION=v6.0.4
cd owncloud-core-git
git archive --format=tar $VERSION | tar -C $DOCROOT -xvf -

Update the applications, assuming their git repositories are named owncloud-APP-git:

cd ..
for d in 3rdparty apps calendar contacts notes; do
   cd owncloud-"$d"-git && pwd && git pull && git clean -dfx && \
   git archive --format=tar --prefix=$d/ $VERSION | tar -C $DOCROOT -xf - && cd ..
done

Careful! Not every application might provide tagged releases! Use HEAD instead of $VERSION instead. Not every application might have caught up the the same tag as core!

cd $DOCROOT
chmod 0750 apps/ config/ data
chmod -R o-rwx apps/ config/ data/
sudo chown -R www-data:www-data apps/ config/ data/

Point a webbrowser to the OwnCloud URL and some update mechanism gets triggered, completing the update.

Upgrade

Upgrading is to upgrade to a new major release, e.g. 6.0.4 to 7.0.1.

Caveats:

 PHP Fatal error:  Cannot redeclare class OC_Config in ../owncloud/lib/config.php on line 41

As recommended in the documentation[15], upgrading between major releases should involve deleting the whole OwnCloud installation, leaving intact user data and then redeploying a fresh release.

cd $DOCROOT
ls | grep -vE 'data|config' | xargs sudo rm -r

Now deploy Owncloud again:

cd ../owncloud-git
git archive --format=tar $VERSION | tar -C $DOCROOT -xvf -

cd ../owncloud-apps-git/
git archive --format=tar --prefix=apps/     $VERSION | tar -C $DOCROOT -xvf -

cd ../owncloud-3rdparty-git/
git archive --format=tar --prefix=3rdparty/ $VERSION | tar -C $DOCROOT -xvf -

Remove clutter, fix ownerships & permissions:

cd $DOCROOT
rm -rf AUTHORS CONTRIBUTING.md COPYING* README* issue_template.md tests
chmod -R o-rwx apps/ config/ data/
sudo chown -R www-data:www-data apps/ config/ data/

Point a webbrowser to the OwnCloud URL and some update mechanism gets triggered, completing the upgrade.

Links


References