in Blog-en, IT-en

Installing Owncloud 9 on Debian 8 (with Apache2 & MySQL)

This is a memo on how to install Owncloud 9 in Debian 8. Since the latest version of owncloud’s fork, nextcloud, is available, you may look at it as an alternative. I prefered to go with Owncloud since they provide Debian packages.

Note: Since the initial writing of this memo (which was started in August 2016 and remained un-pusblished until now), I changed my mind on my web server configuration: I switched from the Apache2 web server to Nginx, deleted the Owncloud instance and installed Pydio. I will no longer maintain this post.

This post mainly follows this following how-to:

Install owncloud

As per the instructions on Owncloud’s website (see Debian), I did the following:

Add the repository key to apt

wget -nv -O Release.key

sudo apt-key add - < Release.key

Add the repository to your APT sources.list file

sudo sh -c "echo 'deb /' >> /etc/apt/sources.list.d/owncloud.list"

Update and install

sudo aptitude update

sudo aptitude install owncloud

Activate SSL

This is extracted from the “manual installation guide“.

a2enmod ssl

sudo a2enmod ssl

sudo a2ensite default-ssl

sudo service apache2 restart

Create a MySQL table (optional)

By default Owncloud will run with an SQLite database. If you wish however to use an MySQL database (probably faster), you need to install it on your machine and create a table for owncloud.

MySQL server was installed through the package at the beginning.

sudo mysql --defaults-file=/etc/mysql/debian.cnf
create database pydiodb;
create user pydiouser@localhost identified by 'pydiopassword';
grant all on pydiodb.* to pydiouser@localhost;

Configure Apache

Make the Owncloud directory accessible to apache:

sudo chown www-data:www-data /var/www/owncloud/

Modify the “owncloud.conf” template available in the “sites-available” directory of apache

sudo nano /etc/apache2/sites-available/owncloud.conf

Create a symbolic link to activate the file in “sites-enabled”

sudo ln -s /etc/apache2/sites-available/owncloud.conf /etc/apache2/sites-enabled/owncloud.conf

Run the initial owncloud installation wizard

Refer to:

Change files permissions

Use the script “Owncloud permissions” to address the permissions of the files in the Owncloud install directory.

The script is the following:


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


  • ocpath variable = path to your ownCloud directory
  • htuser variable = your http user (in this case www-data)
  • htgroup variable = your http group (in this case www-data)

Modify the script, make it executable, and run it.

nano owncloudpermissions
 chmod +x owncloudpermissions
 sudo ./owncloudpermissions

Activate Mod_rewrite

sudo a2enmod rewrite

Restart Apache.

sudo service apache2 restart

You should now be fully set and ready to use Owncloud!



Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.