Storage Ubuntu

Install OwnCloud on Ubuntu 18.04

OwnCloud is an open source self-hosted file sharing server. It has a built in web based UI. The web UI is user friendly and very easy to use. OwnCloud also has native apps for Ubuntu, Windows, macOS desktop operating systems. OwnCloud has apps for Android and iPhone.  Overall, it’s a great piece of software. In this article, I will show you how to install OwnCloud on Ubuntu 18.04 LTS. So, let’s get started.

Adding OwnCloud Package Repository:

OwnCloud is not available in the official package repository of Ubuntu 18.04 LTS. But we can easily add the official OwnCloud package repository on Ubuntu 18.04 LTS and install OwnCloud using the APT package manager.

First, download the GPG key of the OwnCloud package repository with the following command:

$ wget -nv https://download.owncloud.org/download/repositories/production/Ubuntu_18.04
/Release.key -O Release.key

The GPG key should be downloaded.

Now, add the GPG key to the APT package manager with the following command:

$ sudo apt-key add - < Release.key

Now, add the official package repository of OwnCloud on your Ubuntu machine with the following command:

$ echo 'deb http://download.owncloud.org/download/repositories/production/Ubuntu_18.04/
/'
| sudo tee /etc/apt/sources.list.d/owncloud.list

The official OwnCloud package repository should be added.

Now, update the APT package repository cache with the following command:

$ sudo apt update

The APT package repository cache should be updated.

Installing and Configuring Apache and MySQL for OwnCloud:

OwnCloud is a PHP based web application that runs on the Apache web server. OwnCloud also needs a database. I will use MariaDB/MySQL in this article.

You can install Apache 2 web server, MariaDB database server, PHP and some of the required PHP libraries with the following command:

$ sudo apt install apache2 libapache2-mod-php mariadb-server mariadb-client php-bz2
php-mysql php-curl php-gd php-imagick php-intl php-mbstring php-xml php-zip

Now, press y and then press <Enter>.

The required packages are being downloaded.

All the required packages should be installed at this point.

Now, enable Apache 2 mod_rewrite module with the following command:

$ sudo a2enmod rewrite

Apache 2 mod_rewrite should be enabled.

Now, you have to create a MariaDB user and a database for OwnCloud. To do that, login to the MariaDB console as root with the following command:

$ sudo mysql -u root -p

Now, type in your MariaDB root password and press <Enter>.

You should be logged into the MariaDB console.

Now, run the following command to create a new database owncloud:

MariaDB [(none)]> create database owncloud;

owncloud database should be created.

Now, run the following command to create a MariaDB user owncloud with the login password PASSWORD (I will set it to owncloud):

MariaDB [(none)]> create user 'owncloud'@'localhost' identified by 'PASSWORD';

The user owncloud should be created.

Now, run the following command to grant all the privileges on the owncloud database to the user owncloud:

MariaDB [(none)]> grant all privileges on owncloud.* to 'owncloud'@'localhost';

All the privileges are granted.

Now, exit out of the MariaDB console with the following command:

MariaDB [(none)]> exit

OwnCloud web application will be installed on the /var/www/owncloud directory. So you have to change the DocumentRoot of your Apache 2 web server to point to /var/www/owncloud.

To do that, open the default Apache 2 site configuration file with the following command:

$ sudo nano /etc/apache2/sites-enabled/000-default.conf

Now, find the DocumentRoot line and make sure it is set to /var/www/owncloud as marked in the screenshot below.

Installing OwnCloud:

Now, you can install OwnCloud with the following command:

$ sudo apt install owncloud-files

OwnCloud package is being downloaded.

OwnCloud package should be installed.

Now, run the following command to restart Apache 2 web server for the configuration changes to take effect.

$ sudo systemctl restart apache2

Configuring OwnCloud:

Now, you have to access OwnCloud from a web browser in order to configure OwnCloud.

First, run the following command to find the IP address of your Ubuntu machine.

$ ip a

As you can see, the IP address in my case is 192.168.21.128. It will be different for you. So, make sure you replace it with yours where necessary.

Now, open a web browser and visit http://192.168.21.128. You should see the following page. Here, you have to create a OwnCloud admin account, configure where OwnCloud should save its data and configure the database.

Now, type in the details of your OwnCloud admin account. The default data folder is /var/www/owncloud/data. If you want, you can change it to some other directory mounted on your Ubuntu machine. I will leave the default.

Now, scroll down a little bit and type in your MariaDB database credentials. Once you’re done, click on Finish setup.

Now, you should be able to log in to your OwnCloud account. Just type in the login username and password and click on the forward icon as marked in the screenshot below.

Click on the x icon to close the popup window.

You should see the OwnCloud dashboard. From here you can manage your files, upload new files and do other administrative tasks.

So, that’s how you install OwnCloud on Ubuntu 18.04 LTS. Thanks for reading this article.

About the author

Shahriar Shovon

Shahriar Shovon

Freelancer & Linux System Administrator. Also loves Web API development with Node.js and JavaScript. I was born in Bangladesh. I am currently studying Electronics and Communication Engineering at Khulna University of Engineering & Technology (KUET), one of the demanding public engineering universities of Bangladesh.