How to Install ownCloud on Rocky Linux

ownCloud is a software-suits for creating file-hosting services like Google Drive and DropBox. It's free and open-source file-hosting software that allows you to set up a self-hosted file-hosting on your own server. ownCloud offers the server application (the main component of the ownCloud software suits), and client applications that can be installed on multiple operating systems such as Linux, Windows, macOS, Android, and iOS.

ownCloud is mainly written in PHP, JavaScript, and Go. And allows you easily to sync calendar events, storing archives, images, and any file formats. And also allows you to organize such as tasks, address books, and many more. ownCloud is an extensible application that allows you to install the additional application on top of it.

In this tutorial, we will walk you through the process of installing and configuring an open-source file hosting ownCloud on the Rocky Linux server. This tutorial will provide the completed installations of ownCloud, which includes the LAMP Stack, Redis, configuring SELinux, and Firewalld.

Prerequistes

To begin, you will need the following requirements to complete this tutorial:

  • A Rocky Linux server - This example uses the Rocky Linux 8.x with the hostname 'owncloud-server' and an IP address '192.168.5.100'.
  • A non-root user with sudo/root administrator privileges - or you can use the root user.
  • A domain name or sub-domain pointed to the server IP address - This example uses the domain name 'howtoforge.local'.

Installing Basic Dependencies

In the following step, you will set up repositories and install basic dependencies for ownCloud. You will install the EPEL repository, configure the Redis repository, and install the latest version of Redis v6, then install basic dependencies such as openssl, ImageMagick, and zip tools.

Install the EPEL repository via the dnf command below.

sudo dnf install epel-release

When prompted for confirmation, input y and press ENTER to proceed.

install epel

Next, run the following command to enable the repository for Redis v6. The Rocky Linux repository provides multiple versions of Redis, you should enable the latest for the ownCloud installation.

sudo dnf module reset redis
sudo dnf module enable redis:6

Input y when prompted and press ENTER to proceed.

enable redis v6

Now that repositories are configured, run the following dnf command to install basic package dependencies for ownCloud.

sudo dnf install libsmbclient redis unzip libzip bzip2 openssl rsync ImageMagick

Press y when prompted for the configuration, then press ENTER.

install dependencies

Once the basic package dependencies are installed, run the following systemctl command to start and enable the 'redis' service.

sudo systemctl enable redis
sudo systemctl start redis

The Redis service should now be running and enabled, which means will be automatically run at system boot.

Lastly, verify the Redis service using the following systemctl command. You should see the Redis service running and enabled.

sudo systemctl status redis

check redis

Installing PHP 7.4 Packages and Extensions

The latest version of ownCloud is still required PHP 7.4 for installation and still not yet fully compatible with PHP 8. And for this tutorial, you will install PHP 7.4 via the third-party repository REMI.

You will now set up an additional REMI repository and install PHP 7.4 packages from the REMI repository.

First, run the following command to add the REMI repository for the Rocky Linux 8.x server.

sudo dnf install dnf-utils http://rpms.remirepo.net/enterprise/remi-release-8.rpm

Input y when prompted and press ENTER to proceed.

add remi

Next, run the following command to enable the REMI repository for PHP 7.4 packages. Input y and press ENTER to confirm.

sudo dnf module reset php
sudo dnf module enable php:remi-7.4

enable php 7.4 repo

Now that the REMI repository is configured, run the following dnf command to install PHP 7.4 with additional PHP extensions for ownCloud.

sudo dnf install --enablerepo=remi php php-intl php-mysql php-mbstring \
  php-imagick php-igbinary php-gmp php-bcmath \
  php-curl php-gd php-zip php-imap php-ldap \
  php-bz2 php-ssh2 php-common php-json \
  php-xml php-devel php-apcu php-redis \
  php-smbclient php-pear php-phpseclib

When prompted, input y to confirm, then press ENTER.

install php 7.4

Once PHP packages are installed, run the following command to verify the current version of PHP on your system.

php --version

You should see that PHP 7.4 are installed on your system.

check phpversion

Installing httpd Web Server

The ownCloud file hosting can be run on some popular web servers such as Apache/httpd, Nginx, and Microsoft IIS. In this example, you will use Apache/Httpd for your ownCloud deployment.

So, you will first install Httpd packages to your Rocky Linux server.

The default httpd web server packages are available on the Rocky Linux appstream repository, install it via the dnf command below.

sudo dnf install httpd httpd-devel httpd-tools mod_ssl

When prompted for the configuration, input y and press ENTER to proceed.

install httpd

Once httpd is installed, run the following systemctl command to start and enable the httpd service. And now the httpd web server should be running.

sudo systemctl enable httpd
sudo systemctl start httpd

Verify the status of the httpd web server using the command below.

sudo systemctl status httpd

Once you run the command, the following will be printed on your terminal - the httpd service is currently running and enabled, which means the httpd will automatically be run at system boot.

check httpd

Now that the httpd web server is running, you should now set up the firewalld and allow access to HTTP and HTTPS services.

Run the following command to add HTTP and HTTPS services to the firewalld.

sudo firewall-cmd --add-service=http --permanent
sudo firewall-cmd --add-service=https --permanent

After that, reload the firewalld to apply new changes and verify that HTTP and HTTPS services are added to the firewalld.

sudo firewall-cmd --reload
sudo firewall-cmd --list-services

The following output shows you that the HTTP and HTTPS services are added to the firewalld. And you can now access your httpd installation from outside of your network.

setup firewalld

Now that you have installed PHP 7.4 and httpd web server, you will now verify the installation by creating a PHPINFO file and accessing it via the web browser. This will that both PHP 7.4 and httpd are working and you will get detailed information about your PHP configurations.

Run the following command to create a new PHPINFO file '/var/www/html/info.php'.

cat <<EOF | sudo tee /var/www/html/info.php
<?php
phpinfo();
?>
EOF

Lastly, open the web browser on your computer and visit the server IP address followed by the path '/info.php' (i.e: http://192.168.5.100/info.php).

You should the page like the following screenshot - The PHP 7.4 and httpd web server is working and you will also see detailed information and configurations of PHP on your screen.

phpinfo

Installing and Configuring MariaDB Server

ownCloud supports multiple databases for installation. It supports RDBMS such as MariaDB/MySQL, PostgreSQL, Oracle database, and SQLite (the default installation). For the production, you should run ownCloud with MySQL/MariaDB or PostgreSQL, which is more stable and gives you more performance.

In this step, you will install the MariaDB database server, secure the MariaDB via the 'mysql_secure_installation' tool, and create a new database and user for ownCloud deployment.

The default MariaDB database server is available on the Rocky Linux repository, run the dnf command below to install it.

sudo dnf install mariadb-server

Input y when prompted for the configuration and press ENTER to install.

installing mariadb

Once MariaDB is installed, start and enable the 'mariadb' service via the systemctl command below.

sudo systemctl enable mariadb
sudo systemctl start mariadb

start mariadb

The MariaDB server should now be running, use the following command to verify the service and ensure that the service is running.

sudo systemctl status mariadb

In the following output, you can see the MariaDB database server is running and enabled.

check mariadb

After installing MariaDB, you will next secure your deployment via the 'mysql-secure_installation' command provided by MariaDB packages. This command helps you secure your MariaDB deployment by setting up the root password, deleting the default anonymous user and default database test, disable MariaDB root login remotely.

Execute the following command to start securing MariaDB.

sudo mysql_secure_installation

This will give you some questions about the MariaDB configuration and you should input y to confirm or n for no.

  1. Switch the authentication method for the root user to unix_socket? Input n.
  2. Change the MariaDB root password? Input y to confirm, then input the new password and repeat.
  3. Disallow remote login for the root user? Input y to confirm.
  4. Delete default anonymous user from MariaDB? Input y to remove the anonymous user.
  5. Delete default database test from MariaDB? Input y to delete the database test.
  6. Reload tables privileges? Input y to confirm and MariaDB will be reloading all privileges and applying new changes.

At this point, you have installed and secured the MariaDB installation. Now you will be setting up a new MariaDB database and user for ownCloud. And this can be done via the MariaDB/MySQL shell.

Log in to the MariaDB shell with the root user via the 'mysql' command below.

sudo mysql -u root -p

When asked for the password, input the password for your MariaDB root user.

Now run the following MariaDB queries to create a new database and user for ownCloud. In this example, you will create a new database and user 'owncloud' for the ownCloud installation. Also, be sure to replace the password.

CREATE DATABASE owncloud;
CREATE USER IF NOT EXISTS 'owncloud'@'localhost' IDENTIFIED BY 'owncloudpass';
GRANT ALL PRIVILEGES ON owncloud.* TO 'owncloud'@'localhost' WITH GRANT OPTION;
FLUSH PRIVILEGES;

create database and user

Next, run the following query to verify the privilege of the 'owncloud' user. Then, run the query 'quit' or 'exit' to log out from the MariaDB shell.

SHOW GRANTS FOR 'owncloud'@'localhost';
quit

In the below screenshot, you will see the user 'owncloud' has access and privileges to the database 'owncloud'.

check db privileges

Downloading ownCloud Source Code

After you have installed MariaDB and created the database and user for wonCloud. In the next step, you will download the ownCloud source and set up the installation directory to '/var/www/owncloud'. At the time of this writing, the latest version of ownCloud is v10.11. and you will download its source code.

Move the working directory to '/var/www'.

cd /var/www

Download the latest version of the ownCloud source and the SHA256 file for verifying the source code.

wget https://download.owncloud.com/server/stable/owncloud-complete-latest.tar.bz2
wget https://download.owncloud.com/server/stable/owncloud-complete-latest.tar.bz2.sha256

Now verify the ownCloud source code via the sha256sum command below. If the source code is verified, you should get the output message 'OK'.

sudo sha256sum -c owncloud-complete-latest.tar.bz2.sha256 < owncloud-complete-latest.tar.bz2

Next, extract the ownCloud source code via the tar command below. You should get the new directory '/var/www/owncloud', which will be used as the installation for ownCloud.

sudo tar -xvjf owncloud-complete-latest.tar.bz2

downcloud owncloud

Lastly, change the ownership of the ownCloud installation directory to the user 'apache' via the command below.

sudo chown -R apache:apache /var/www/owncloud

Configuring httpd Virtual Host

You have to create a new httpd virtual host configuration before accessing your wonCloud installation. Also, ensure you have a domain name pointed to your server IP address and generated SSL certificates for that domain.

You will now be creating a new httpd virtual host configuration for ownCloud. Also, you will enable the secure connection HTTPS for the owncloud via SSL certificates from Letsencrypt.

Create a new httpd virtual host configuration for owncloud '/etc/httpd/conf.d/owncloud.conf' via the nano editor below.

sudo nano /etc/httpd/conf.d/owncloud.conf

Add the following configuration to the file and be sure to change the domain and the path of SSL certificates. In this example, you will install owncloud on the sub-directory with the main domain 'howtoforge.local'.

<VirtualHost *:80>
  ServerName howtoforge.local
  Redirect permanent / https://howtoforge.local/
</VirtualHost>

<VirtualHost *:443>
  ServerName howtoforge.local
  DocumentRoot /var/www

  Protocols h2 http:/1.1

  <If "%{HTTP_HOST} == 'www.howtoforge.local'">
    Redirect permanent / https://howtoforge.local/
  </If>
 
  ErrorLog /var/log/httpd/howtoforge.local-error.log
  CustomLog /var/log/httpd/howtoforge.local-access.log combined

  SSLEngine On
  SSLCertificateFile /etc/letsencrypt/live/howtoforge.local/fullchain.pem
  SSLCertificateKeyFile /etc/letsencrypt/live/howtoforge.local/privkey.pem
 
  SSLCipherSuite ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:DHE-RSA-AES128-GCM-SHA256:DHE-RSA-AES256-GCM-SHA384

  SSLProtocol All -SSLv2 -SSLv3 -TLSv1 -TLSv1.1
  SSLCompression off

  Header always set Strict-Transport-Security "max-age=63072000"

  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>
 
</VirtualHost>

Save the file and exit the editor when you are finished.

Next, ru