How to Install ownCloud 10 on Debian 9

Install PHP

Start with the installation of PHP 7.2

wget -q https://packages.sury.org/php/apt.gpg -O- | sudo apt-key add -

sudo echo "deb https://packages.sury.org/php/ stretch main" | tee /etc/apt/sources.list.d/php.list

output:

[email protected]:~# wget -q https://packages.sury.org/php/apt.gpg -O- | sudo apt-key add -rver.
OK

Update the system

sudo apt-get update

Install PHP along with other modules

sudo apt-get install -y php7.2 php7.2-gd php7.2-curl php7.2-zip php7.2-dom php7.2-xml php7.2-simplexml php7.2-mbstring

output:

[email protected]:~# sudo apt-get install -y php7.2 php7.2-gd php7.2-curl php7.2-zip php7.2-dom php7.2-xml php7.2-simplexml php7.2-mbstring
Reading package lists... Done
Building dependency tree       
Reading state information... Done
Note, selecting 'php7.2-xml' instead of 'php7.2-dom'
Note, selecting 'php7.2-xml' instead of 'php7.2-simplexml'
php7.2 is already the newest version (7.2.13-1+0~20181207100540.13+stretch~1.gbpf57305).

Install Apache2

sudo apt-get install -y apache2 libapache2-mod-php

output:

[email protected]:~# sudo apt-get install -y apache2 libapache2-mod-php
Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following additional packages will be installed:
apache2-bin apache2-data apache2-utils libapache2-mod-php7.2 libapr1 libaprutil1 libaprutil1-dbd-sqlite3 libaprutil1-ldap libargon2-1 liblua5.2-0 libsodium23 php7.2-cli php7.2-common php7.2-json
php7.2-opcache php7.2-readline ssl-cert
Suggested packages:
www-browser apache2-doc apache2-suexec-pristine | apache2-suexec-custom php-pear openssl-blacklist
The following NEW packages will be installed:

Install MySQL

sudo apt-get install -y mysql-server php-mysql

output:

[email protected]:~# sudo apt-get install -y mysql-server php-mysql
Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following package was automatically installed and is no longer required:

Download ownCloud Source

Download latest ownCloud from its official website.

cd /tmp
wget https://download.owncloud.org/community/owncloud-10.0.7.tar.bz2

output:

[email protected]:/tmp# wget https://download.owncloud.org/community/owncloud-10.0.7.tar.bz2
--2019-01-09 07:21:02--  https://download.owncloud.org/community/owncloud-10.0.7.tar.bz2
Resolving download.owncloud.org (download.owncloud.org)... 46.4.80.187, 85.10.210.219, 2a01:4f8:140:6164::3, ...
Connecting to download.owncloud.org (download.owncloud.org)|46.4.80.187|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 39395237 (38M) [application/x-bzip2]

Now extract downloaded archive under website document root and setup appropriate permissions on files and directories.

cd /var/www/html
sudo tar xjf /tmp/owncloud-10.0.7.tar.bz2

output:

[email protected]:/var/www/html# sudo tar xjf /tmp/owncloud-10.0.7.tar.bz2
[email protected]:/var/www/html# ls -al
total 16
drwxr-xr-x  3 root   root       40 Jan  9 07:28 .
drwxr-xr-x  3 root   root       18 Jan  9 07:15 ..
-rw-r--r--  1 root   root    10701 Jan  9 07:15 index.html
drwxr-xr-x 12 nobody nogroup  4096 Feb 19  2018 owncloud

Change ownership & group ownership of the file.

sudo chown -R www-data:www-data owncloud

output:

[email protected]:/var/www/html# sudo chown -R www-data:www-data owncloud

Change the permission of the file.

sudo chmod -R 755 owncloud

output:

[email protected]:/var/www/html# ls -al
total 16
drwxr-xr-x 12 www-data www-data  4096 Feb 19  2018 owncloud

Now,remove the archive file.

sudo rm -f /tmp/owncloud-10.0.7.tar.bz2

output:

[email protected]:/var/www/html# sudo rm -f /tmp/owncloud-10.0.7.tar.bz2

Create MySQL Database and User

let’s create a MySQL database and user account for configuring ownCloud.

mysql -u root -p

output:

[email protected]:/tmp# mysql -u root -p
Enter password: 
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 2
Server version: 10.1.37-MariaDB-0+deb9u1 Debian 9.6

CREATE DATABASE owncloud;

output:

MariaDB [(none)]>  CREATE DATABASE owncloud;
Query OK, 1 row affected (0.00 sec)

GRANT ALL ON owncloud.* to 'owncloud'@'localhost' IDENTIFIED BY '_password_';

outtput:

MariaDB [(none)]> GRANT ALL ON owncloud.* to 'owncloud'@'localhost' IDENTIFIED BY '_password_';
Query OK, 0 rows affected (0.00 sec)

FLUSH PRIVILEGES;

output:

MariaDB [(none)]> FLUSH PRIVILEGES;
Query OK, 0 rows affected (0.00 sec)

Install ownCloud with Web Installer

Now access the ownCloud directory on a web browser as below. Change localhost to your server IP address or domain name.

 http://localhost/owncloud/index.php

Create the admin account and provide the location of data directory and complete the setup.