[HOWTO] install own cloud on ubuntu

We can create your own self-hosted cloud storage services by installing the open source software – OwnCloud on your Ubuntu 18.04 server. OwnCloud provides similar functionalities like DropBox, OneDrive and Google Drive.

Having a cloud storage service is inevitable in today’s world where information is very vital in every business. You can use the cloud to create backups for your most important pieces of information. You can then restore information from your backup in case a disaster (e.g. flooding, fires, earthquakes) strikes.

Offsite backups hosted on the cloud are the most effective. A regular backup performed on a nearby external hard disc or memory card is not enough because it can be damaged together with your main storage.

OwnCloud offers a great solution for protecting your data on the cloud while making collaboration easier. In this guide, we will show you how to integrate a self-hosted OwnCloud storage service on your Ubuntu 18.04 server.

Step 1: Install Apache

You need to install Apache on your Ubuntu Server for OwnCloud to work, if you haven’t done so, type the command below;

Next, disable directory listing on your Apache:

$ a2dismod autoindex

Enable the following Apache modules for OwnCloud to work correctly:

$ sudo a2enmod rewrite
$ sudo a2enmod headers
$ sudo a2enmod env
$ sudo a2enmod dir
$ sudo a2enmod mime

Restart Apache for the changes to take place:

$ sudo systemctl restart apache2

Step 2: Install MariaDB Server

Then install MariaDB server by running the command below:

$ sudo apt-get install mariadb-server mariadb-client

By default, MariaDB installation is not secure; we need to run the command below to make it safe:

$ sudo mysql_secure_installation

This will allow us to;

Set a strong password for the root user of our MariaDB,
remove anonymous users
disallow root login and
remove test databases

Then login to your MariaDB server using the command below to create a database:

$ sudo mysql -u root -p

Enter your password when prompted.

Create OwnCloud database user and password by typing the commands below. Replace ‘PASSWORD’ with a strong value.


Step 3: Install PHP

OwnCloud supports PHP 7.1 so we need to install it using the commands below:

sudo apt-get install software-properties-common
sudo add-apt-repository ppa:ondrej/php
sudo apt update
sudo apt install php7.1

Then we need to install all the related PHP modules using the command below:

sudo apt-get install php7.2-cli php7.2-common php7.2-mbstring php7.2-gd php7.2-intl php7.2-xml php7.2-mysql php7.2-zip php7.2-curl php7.2-xmlrpc

The default PHP settings may limit the way OwnCloud works, so we need to adjust some default values.

Open the default ‘php.ini’ file by typing the command below:

$ sudo nano /etc/php/7.2/apache2/php.ini

Find the settings below and change their values to correspond the ones we have at the bottom:

file_uploads = On
allow_url_fopen = On
memory_limit = 256M
upload_max_file_size = 100M

Then press CTRL+X, Y and Enter to save the changes.

Restart Apache:

$ sudo systemctl restart apache2

Step 4: Download the latest OwnCloud release

CD to the ‘tmp’ directory and download the latest release of Owncloud using the commands below:

$ cd /tmp
$ wget https://download.owncloud.org/community/owncloud-10.0.10.zip

Then, unzip ‘owncloud-10.0.10.zip’ file to the current directory:

$ unzip owncloud-10.0.10.zip

Move the files to a new owncloud directory under the root folder of your website:

$ sudo mv owncloud /var/www/html/owncloud/

Step 5: Set directory and file permissions

In order for Owncloud to function correctly, we need to set the following directory permissions/ownership:

$ sudo chown -R www-data:www-data /var/www/html/owncloud/
$ sudo chmod -R 755 /var/www/html/owncloud/

Step 6: Finalize the Installation

Visit your server URL and to finalize the installation. In our case, we will visit http://ipadress/owncloud

Enter your preferred admin username and password as shown below:

sudo apt-get install php7.0-cli php7.0-common php7.0-mbstring php7.0-gd php7.0-intl php7.0-xml php7.0-mysql php7.0-zip php7.0-curl php7.0-xmlrpc