How to Install OwnCloud in Debian 10

Owncloud is a market-leading online file sharing system that lets you back up and shares your files with ease. If you are not a fan of DropBox or Google Drive, then OwnCloud is a cool alternative.

In this article, we walk you through the installation of OwnCloud in Debian 10.

Step 1: Install LAMP Stack on Debian

Since OwnCloud runs on the browser and the back-end too by storing data on the database, we need to first install the LAMP stack. LAMP is a popular free and open-source hosting stack used by developers for hosting their web applications. It stands for Linux, Apache, MariaDB / MySQL, and PHP.

First, let’s update system repositories.

$ sudo apt update && sudo apt upgrade
Update Debian System Packages
Update Debian System Packages

Next, install the Apache web server and MariaDB database server by running the command.

$ sudo apt install apache2 mariadb-server mariadb-client
Install Apache and MariaDB
Install Apache and MariaDB

After the installation is complete, proceed and install PHP 7.2. At the time of penning down this guide, PHP 7.3 is not yet supported, so our best shot is using PHP 7.2.

So, enable the PHP repository as shown.

$ sudo wget -O /etc/apt/trusted.gpg.d/php.gpg  https://packages.sury.org/php/apt.gpg
$ sudo echo "deb https://packages.sury.org/php/ $(lsb_release -sc) main" > /etc/apt/sources.list.d/php.list

Once you are done creating the repository for PHP, update your system packages & repositories for the new PHP repository to take effect.

$ sudo apt update

Now install PHP and the required dependencies as shown.

$ sudo apt install php7.2 libapache2-mod-php7.2 php7.2-{mysql,intl,curl,json,gd,xml,mb,zip}
Install PHP in Debian
Install PHP in Debian

Once installed, check the PHP version using the command.

$ php -v

Also, verify that the Apache webserver is running by running the command.

$ systemctl status apache2

If Apache is up and running, you should get output similar to the one shown below, indicating that it is ‘active’.

Check Apache Status in Debian
Check Apache Status in Debian

If Apache is not started, start and enable it on boot by running the commands.

$ systemctl start apache2
$ systemctl enable apache2

Step 2: Create a Database for OwnCloud Files

The next step will be to create a database to handle OwnCloud’s files during and after the installation.

Login to the MariaDB server.

$ mysql -u root -p

Once logged in, create a database for OwnCloud.

MariaDB [(none)]> CREATE DATABASE owncloud;

Create a user for the OwnCloud database and grant all privileges to the user.

MariaDB [(none)]> GRANT ALL ON owncloud.* TO 'owncloud_user'@'localhost' IDENTIFIED BY 'StrongP@ssword';

Finally, flush privileges and exit.

MariaDB [(none)]> FLUSH PRIVILEGES;
MariaDB [(none)]> EXIT;
Create OwnCloud Database
Create OwnCloud Database

Step 3: Install OwnCloud in Debian

By default, OwnCloud is not included in Debian 10 repositories. Nevertheless, OwnCloud maintains a repository for each distribution. The repository for Debian 10 has not yet been released, and therefore, we will use the repository of Debian 9.

First, install the PGP signing key.

$ sudo curl https://download.owncloud.org/download/repositories/10.2.1/Debian_9.0/Release.key | apt-key add -

Once the signing key is installed, go ahead and enable OwnCloud’s repository.

$ sudo echo 'deb http://download.owncloud.org/download/repositories/10.2.1/Debian_9.0/ /' > /etc/apt/sources.list.d/owncloud.list

Once again update your system to resynchronize the system packages and install Owncloud.

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

Step 4: Configure Apache for OwnCloud

Upon installation, OwnCloud stores its files in the /var/www/owncloud directory. We, therefore, need to configure our web server to serve OwnCloud’s files.

So, create a virtual host file for Owncloud as shown.

$ sudo vim /etc/apache2/sites-available/owncloud.conf

Add the configuration below and save.

Alias / "/var/www/owncloud/"

<Directory /var/www/owncloud/>
  Options +FollowSymlinks
  AllowOverride All

 <IfModule mod_dav.c>
  Dav off
 </IfModule>

 SetEnv HOME /var/www/owncloud
 SetEnv HTTP_HOME /var/www/owncloud

</Directory>

To enable the OwnCloud site, just as you would any virtual host run the command:

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

Next, enable additional Apache modules that are required by OwnCloud and restart the Apache webserver to reload the configuration and effect the changes.

$ sudo a2enmod rewrite mime unique_id
$ sudo systemctl restart apache2

Step 5: Finalizing OwnCloud Installation

To complete OwnCloud setup, browse your server’sIP address as shown below:

http://server-ip

The welcome interface will greet you as shown. You will be required to provide the username and password.

Create Owncloud Admin Account
Create Owncloud Admin Account

Next, click on the ‘Storage and database’ and provide the database details such as database user, database name and password.

Add OwnCloud Database Settings
Add OwnCloud Database Settings

Finally, click on ‘Finish Setup’.

Finish OwnCloud Setup
Finish OwnCloud Setup

This takes you to the login page. Enter your username and password and hit ENTER.

Owncloud Admin Login
Owncloud Admin Login

Initially, you will get a pop-up with information about OwnCloud’s Desktop, Android and iOS app that you can install on your devices. This allows you to access your data on the go.

OwnCloud Device Apps
OwnCloud Device Apps

Here’s the dashboard.

OwnCloud Dashboard Window
OwnCloud Dashboard Window

And we have finally come to the end of this tutorial. You can now save and share your files with ease using OwnCloud. Thanks for taking the time.

If you read this far, tweet to the author to show them you care. Tweet a thanks
James Kiarie
This is James, a certified Linux administrator and a tech enthusiast who loves keeping in touch with emerging trends in the tech world. When I'm not running commands on the terminal, I'm taking listening to some cool music. taking a casual stroll or watching a nice movie.

Each tutorial at TecMint is created by a team of experienced Linux system administrators so that it meets our high-quality standards.

Join the TecMint Weekly Newsletter (More Than 156,129 Linux Enthusiasts Have Subscribed)
Was this article helpful? Please add a comment or buy me a coffee to show your appreciation.

2 thoughts on “How to Install OwnCloud in Debian 10”

  1. I went through this WONDERFUL tutorial on how to set up your own cloud.
    I got to the initial configuration screen and can’t get by!

    1. User : Creating an admin account seems easy enough, so I pick a name and a password.
    2. Data folder : I would like the data to be stored in /media/sd, this is valid and property mounted. Is that OK?
    3. Database user : root, database password: (the password), database name: owncloud, localhost : (server ip address:5432).

    I get this error:
    ‘Error while trying to create admin user:
    failed to connect to the database: An exception occured in driver: SQLSTATE[HY000][2002] Connection refused

    Any help would be greatly appreciated

    Reply

Got something to say? Join the discussion.

Thank you for taking the time to share your thoughts with us. We appreciate your decision to leave a comment and value your contribution to the discussion. It's important to note that we moderate all comments in accordance with our comment policy to ensure a respectful and constructive conversation.

Rest assured that your email address will remain private and will not be published or shared with anyone. We prioritize the privacy and security of our users.