Your OwnCloud storage

Just 15 years ago, hard drives on many home computers were no larger than 120 gigabytes. It was difficult even to imagine something you'll need to fill up such volumes. But years went by, the stored volumes of information grew and these old hard drives started to lack enough space to store them. Now hard drives less than 500 GB are perceived by many as small in volume. But it's not the quantity of information that matters, but its quality. For ordinary user it can be pictures, which would be precious as a memory, a graduation work or scientific paper and much more, while for organizations it is a huge pile of various documents.

The question arises - is it possible to store all the information somewhere else to eliminate the probability of loss, for example, in case of failure of a hard drive? There are a lot of options, such as external hard drives, flash drives, optical media (DVD and CD), the market is full of simple NASes (Network Attached Storage, i.e. mini PCs exclusively for storing information) and various cloud services.

Many different companies today provide so-called “cloud storages” for storing personal information, the largest and most known offers are from Yandex, Google, MailRu, DropBox and others. All of them differ in terms of providing free amount of stored information. The main advantages are ease of use and accessibility from anywhere in the world where you can access the Internet.

But can we trust these services? For example, Google's user agreement has the following lines:

“We will share personal information outside of Google if we have a good-faith belief that access, use, preservation, or disclosure of the information is reasonably necessary".

Other services have similar conditions. Among other things, do not forget about cyber-criminals who can steal your data.

Therefore, we will consider the option of using OwnCloud storage, suitable both for personal needs and for organizations.

Checking the Requirements

There are many different ways to install OwnCloud, you can find even readymade images for virtual servers, but we are not looking for easy way, so let’s install it manually.

OwnCloud can be installed on virtually any linux-like operation system, we will use CentOS 7.6.

  • As usual, root access is required;
  • Database - mysql or mariadb 5.5+, oracle 11g, postgresql, sqlite;
  • Apache web server with multi-processing module and mod_php, you can use nginx, but it is not recommended by the developer;
  • Php of versions 5.6, 7.0, 7.1, 7.2 - recommended on the website;
  • Can run on 128mb of ram, but it is strongly recommended to have at least 512mb
  • Client applications are available on almost any modern devices, you can also have access via the web interface using the most popular web browsers.

According to the recommendations, we will use Apache, php 7.2 and PostgreSQL 9.6, because PostgreSQL throws an error on versions 10 and 11. The developers promise to fix this in OwnCloud version 11. Currently, the latest version of OwnCloud is 10.0.10.

The documentation contains recommendations on server properties depending on the number of users. In example, for a database with up to 10TB volume and a maximum of 150 users with moderate load, a dual-coar processor and 16GB of RAM would be enough.

You can visit the official website with documentation to review it on your own.

Initial Configuration

To begin with, we will install PostgreSQL of the latest version, i.e. 9.6, we will install from the site, since the latest version in the repositories is 9.2.

#yum install -y https://download.postgresql.org/pub/repos/yum/9.6/redhat/rhel-7-x86_64/pgdg-redhat96-9.6-3.noarch.rpm
#yum install -y postgresql96 
#yum install -y postgresql96-server

Initialize the database and enable automatic launch:

#/usr/pgsql-9.6/bin/postgresql96-setup initdb
#systemctl enable postgresql-9.6

Before starting the service, edit the /var/lib/pgsql/9.6/data/pg_hba.conf file at the very end and replace the line in the IPv4 local connections section:

host    all     all     127.0.0.1/32     peer

with

host    all     all     127.0.0.1/32     md5

You can use any text editor, vi, for example:

#vi /var/lib/pgsql/9.6/data/pg_hba.conf

Now start the service itself:

#systemctl start postgresql-9.6

Set password for postgres user:

#sudo -i -u postgres psql
postgres=# \password
Enter new password:
Enter it again:
postgres=# \q

We finished with DBMS (database management system), now let's install other packages:

#yum install -y -q epel-release http://rpms.remirepo.net/enterprise/remi-release-7.rpm yum-utils
#yum-config-manager --enable remi-php72
#yum update -y -q
#yum install -y php72 php72-php php72-php-gd php72-php-mbstring php72-php-cli php72-pecl-apcu redis php72-php-pecl-redis php72-php-common php72-php-ldap php72-php-pecl-zip php72-php-xml php72-php-intl php72-php-pgsql unzip
#scl enable php72 bash

If you want to use MySQL, replace php72-php-pgsql package with php72-php-mysqlnd.

Add Apache to autorun and run:

#systemctl enable httpd
#systemctl start httpd

Do not forget about the firewall:

#firewall-cmd --zone=public --remove-service=dhcpv6-client
#firewall-cmd --zone=public --add-service=http
#firewall-cmd --runtime-to-permanent

Going to the server address, we should see more or less the following picture:

Apache works and you can go to the next task.

OwnCloud Installation

Now proceed to the installation of OwnCloud itself. First, download the itself from the official website or use the following commands in the console and check the integrity:

#wget https://download.owncloud.org/community/owncloud-10.0.10.zip
#wget https://download.owncloud.org/community/owncloud-10.0.10.zip.sha256
#sha256sum -c owncloud-10.0.10.zip.sha256 owncloud-10.0.10.zip
owncloud-10.0.10.zip: OK

As we can see, the archive is, let's unpack it and copy to the root of the web server directory (/var/www by default):

#unzip ./owncloud-10.0.10.zip
#cp -r ./owncloud /var/www/
#chown -R apache:apache /var/www/owncloud/

With the last command we changed the group and the owner of the files in the owncloud directory. Now we need to configure Apache web server, create a file:

#touch /etc/httpd/conf.d/owncloud.conf
#vi /etc/httpd/conf.d/owncloud.conf

And write the following in it:

Alias /owncloud "/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>

In this file we have specified that Alias will be used to the main /owncloud address , i.e. to open the owncloud page you need to go to http://{site_address}/owncloud, in addition, AllowOverride directives allows using htaccess files, sets 2 variables and sets the option to allow you to navigate through symbolic links. The DAV module was also disabled. Now we only need to restart Apache:

#systemctl restart httpd

Now go to the site http://{your_ip}/owncloud, where your_ip is the address of your server, and see the following:

We are offered to create a system administrator account, but for some reason the SQLite DBMS will be used. Don't worry! You need to click Storage and Database and you will see a menu where we can select PostgreSQL:

After entering, click “Finish Installation” and wait for a while. If you receive an error about the password to the database - simply replace localhost with 127.0.0.1. This is due to the fact that php tries to connect to ipv6 address. You can also edit the PostgreSQL settings file.

Once the installation is complete, you will be asked to log in again:

After logging in, a secondary window will pop up:

Here we are offered to install client applications and configure basic settings for working with OwnCloud. By the way, you can install OwnCloud from the console:

#yum install -y php72-php-process
#cd /var/www/owncloud/
#sudo -u apache /opt/remi/php72/root/usr/bin/php occ maintenance:install --database "pgsql" --database-name "owncloud" --database-user "postgres" --database-pass "password" --database-host "127.0.0.1" --admin-user "admin" --admin-pass 'password!' --data-dir "/var/www/owncloud/data"

Then in the /var/www/owncloud/config/config.php file you need to change the trusted_domains and overwrite.cli.url parameters to the external address of your server, here's an example:

'trusted_domains' =>
  array (
    0 => '{your_ip}',
  ),
'overwrite.cli.url' => 'http://{your_ip}/owncloud',

This concludes the basic Owncloud server installation. Congratulations!

OwnCloud has an application market, I advise you to look and install the necessary for your use, in this article we will not review them. For more information about the applications, please visit this page.

Client Applications Installation

There are many ways to work with OwnCloud, both through a web browser and through client applications on various devices. First, let's download the application for Windows from this page and install it. After the installation is complete, a connection window will appear. Remember that our OwnCloud is located not at the server address itself, but in the owncloud directory, so specify this address in the address bar:

Then enter the user name and password:

And the final settings:

Now we have added storage, let's check it in the list:

Now let's check out the app for Android mobile devices. Go to the link on the download page or, like us, download an alternative application from another developer, which as we thought was more convinient and had more favorabile feedback than the manufacturer's application. Download and install. At startup, enter the authorization data and server address (remember about the /owncloud directory) to see the server content:

In the settings you can configure the automatic upload of pictures and videos from the device. In general, it is like in other similar applications from other cloud services.

Conclusion

We've got example how quickly and easily you can set up your own cloud storage. Of the most important advantages - full control over the content is carried out only by you. Easy and fast installation, flexibility and free-of-charge basis - all these are huge advantages of OwnCloud. However, this is far from over.

We have reviewed only the basic installation, which does not include optimization, security measures (remember that the website works on http). Here's what we're going to do in the next article.

VPS server for OwnCloud