Build your own cloud storage - GoTechTalk


Saturday, November 24, 2018

Build your own cloud storage

Build your own cloud storage service just like Google Drive or Drop Box functionalities.

OwnCloud is free and open-source, and thereby allowing anyone to install and operate it without charge on a private server. It also supports extensions that allow it to work like Google Drive, with online document editing, calendar and contact synchronisation, and more. Its openness avoids enforced quotas on storage space or the number of connected clients, instead having hard limits (like on storage space or number of users) defined only by the physical capabilities of the server.

  • An Ubuntu 18.04 VPS
  • A non-root user with sudo privileges

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;
  1. $ sudo apt install apache2

Next, disable directory listing on your Apache:

  1. $ a2dismod autoindex
Enable the following Apache modules for OwnCloud to work correctly:
  1. $ sudo a2enmod rewrite
  2. $ sudo a2enmod headers
  3. $ sudo a2enmod env
  4. $ sudo a2enmod dir
  5. $ sudo a2enmod mime
Restart Apache for the changes to take place:
  1. $ sudo systemctl restart apache2

Step 2: Install MariaDB Server

Then install MariaDB server by running the command below:
  1. $ 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:
  1. $ 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:
  1. $ 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.
  1. CREATE DATABASE owncloud;
  2. CREATE USER 'oc_user'@'localhost' IDENTIFIED BY 'PASSWORD';
  3. GRANT ALL ON owncloud.* TO 'oc_user'@'localhost' IDENTIFIED BY 'PASSWORD' WITH GRANT OPTION;
  5. EXIT;

Step 3: Install PHP

OwnCloud supports PHP 7.1 so we need to install it using the commands below:
  1. $ sudo apt-get install software-properties-common
  2. $ sudo add-apt-repository ppa:ondrej/php
  3. $ sudo apt update
  4. $ sudo apt install php7.1
Then we need to install all the related PHP modules using the command below:
  1. $ sudo apt-get install php7.1-cli php7.1-common php7.1-mbstring php7.1-gd php7.1-intl php7.1-xml php7.1-mysql php7.1-zip php7.1-curl php7.1-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:
  1. $ sudo nano /etc/php/7.1/apache2/php.ini
Find the settings below and change their values to correspond the ones we have at the bottom:
  1. file_uploads = On
  2. allow_url_fopen = On
  3. memory_limit = 256M
  4. upload_max_file_size = 100M
Then press CTRL+XY and Enter to save the changes.

Restart Apache:

  1. $ 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:
  1. $ cd /tmp
  2. $ wget
Then, unzip ‘’ file to the current directory:
  1. $ unzip
Move the files to a new owncloud directory under the root folder of your website:
  1. $ 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:
  1. $ sudo chown -R www-data:www-data /var/www/html/owncloud/
  2. $ sudo chmod -R 755 /var/www/html/owncloud/

Step 6: Finalise the Installation

Visit your server URL and to finalize the installation. In our case, we will visit http://serverip/owncloud
Enter your preferred admin username and password as shown below:

Then configure the database by entering the database name, username, and password values that you created above as shown below:
Finally, click on Finish Setup’ at the bottom of the screen.
You Owncloud instance is now setup and you can log in to the admin panel and start uploading files

No comments:

Post a Comment