Category Archives: Raspberry Pi

Upgrading ownCloud

My initial ownCloud installation was based on the version 9.1.4 that was the most current one at that time. To keep the installation up-to-date I decided to upgrade the server to version 9.1.6. Instead of doing a manual installation again I could use the raspbian apt-get tool to install the new version. The whole process is pretty simple. I’ll show the steps here.

Add the ownCloud repository

Let’s start by adding the ownCloud apt-get repository to the raspbian repository list.

# cd /etc/apt/sources.list.d
# echo 'deb /' > owncloud.list

Install new version of ownCloud

Now that we have the ownCloud repository defined we can update the package index files and then install the new version with apt-get.

# apt-get update
# apt-get install owncloud

Finalize the installation

To complete the installation run the upgrade command in the ownCloud console (occ).

# cd /var/www/owncloud
# sudo -u www-data php occ upgrade

Set the permissions

OwnCloud documentation recommends to set strict directory permissions after the installation has been finished. I will use the recommended shell script shown below to set the permissions. I will store the script into /root/


printf "Creating possible missing Directories\n"
mkdir -p $ocpath/data
mkdir -p $ocpath/assets
mkdir -p $ocpath/updater

printf "chmod Files and Directories\n"
find ${ocpath}/ -type f -print0 | xargs -0 chmod 0640
find ${ocpath}/ -type d -print0 | xargs -0 chmod 0750

printf "chown Directories\n"
chown -R ${rootuser}:${htgroup} ${ocpath}/
chown -R ${htuser}:${htgroup} ${ocpath}/apps/
chown -R ${htuser}:${htgroup} ${ocpath}/assets/
chown -R ${htuser}:${htgroup} ${ocpath}/config/
chown -R ${htuser}:${htgroup} ${ocpath}/data/
chown -R ${htuser}:${htgroup} ${ocpath}/themes/
chown -R ${htuser}:${htgroup} ${ocpath}/updater/

chmod +x ${ocpath}/occ

printf "chmod/chown .htaccess\n"
if [ -f ${ocpath}/.htaccess ]
chmod 0644 ${ocpath}/.htaccess
chown ${rootuser}:${htgroup} ${ocpath}/.htaccess
if [ -f ${ocpath}/data/.htaccess ]
chmod 0644 ${ocpath}/data/.htaccess
chown ${rootuser}:${htgroup} ${ocpath}/data/.htaccess

Then just make the script executable and run it.

# chmod 755
# ./

Maintenance mode

After installation the ownCloud server is in maintenance mode. If you go to the site you will be greeted accordingly.

Use the occ console to take the server out of the maintenance mode.

# cd /var/www/owncloud
 sudo -u www-data php occ maintenance:mode --off
ownCloud is in maintenance mode - no app have been loaded
Maintenance mode disabled

 Enable apps

As part of the installation previously added apps (like Contacts and Calendar) will be disabled. However, all data is still preserved so we will just need to add the apps again using the ownCloud admin account.

Migrating from SQLite to MySQL

As part of the ownCloud v9.1.6 installation also the MySQL database server was installed. Let’s see if we can migrate our current SQLite database to the more efficient MySQL database.

When the MySQL server was installed a password was set for the root user. We can use the root user for MySQL administration.

The first step is to create a new MySQL database for the ownCloud use. We will also create a dedicated user and password for accessing the ownCloud database.

# mysql -u root -p
Enter password:
mysql> create user oc_user@localhost identified by '<oc_user password>';

mysql> create database owncloud;
mysql> grant all privileges on owncloud.* to oc_user@localhost;
mysql> quit

Next we can use the owncloud console to do the actual migration. We need to specify the new database type (mysql) the database user (oc_user), the host (localhost) and the new database name (owncloud). The –all-apps option will migrate both enabled and disabled apps (by default only the enabled apps will be migrated).

# cd /var/www/owncloud
# sudo -u www-data php occ db:convert-type --all-apps mysql oc_user localhost owncloud

That’s it, the MySQL database is now in use. You can check the database access parameters from the file config/config.php.

# cd /var/www/owncloud
# grep db config/config.php
'dbtype' => 'mysql',
'dbname' => 'owncloud',
'dbhost' => 'localhost',
'dbuser' => 'oc_user',
'dbpassword' => '<oc_user password>',

Upgrading the calendar app

When logging into the upgraded owncloud site with the admin account I’m seeing one warning message at the top of the page:

It looks like the certificate for the calendar app is no longer valid. We can upgrade the apps from the app marketplace. But first we need to disable the apps (from the Enabled page) and then uninstall the apps (from the Not enabled page). I will uninstall only the calendar app.

Then we need to edit the php configuration file /var/www/owncloud/config/config.php and add the line:

'appstoreurl' => '',

Then the Apps page should show a new version (v1.4.2) of the calendar app. Let’s install it. After logging out of the admin account and then logging in again the warning has disappeared.

And all calendar entries seem to be still there. 🙂