How to Install and Configure OwnCloud on CentOS 8

OwnCloud is an open source project that can be installed on your server to securely store and access files.

Prerequisites

Before we begin with installing ownCloud, you would need either a LAMP or LEMP Stack installed and running on your server or home computer.

To install and configure LAMP Stack, Click here.

Updating your system

Before we begin, we will make sure our system is upto date and install any pending updated

yum update -y

Downloading OwnCloud

You can download the latest version of ownCloud by checking their downloads section.

Download ownCloud and extract it using the following command.

Firest install the wget by using following command.

dnf install wget

cd /tmp 

wget https://download.owncloud.org/community/owncloud-complete-20210326.tar.bz2

Now extract the owcloud tar file to /var/www/html/ directory.

yum install bzip2

tar -xvf owncloud-complete-20210326.tar.bz2 -C /var/www/html/

Set the permissions of owncloud directory so it can be accessible.

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

chmod -R 755 /var/www/html/owncloud

Install PHP

The following command will install Additional PHP Modules which is required for owncloud.

dnf install php-curl php-gd php-intl php-json php-ldap php-mbstring php-mysqlnd php-xml php-zip php-opcache 

Once the installation is complete, start the PHP service and enable it to automatically start on boot by typing

systemctl enable --now php-fpm  

Create a new MySQL database.

mysql -u root -p

mysql> CREATE DATABASE ownclouddb;

mysql> GRANT ALL PRIVILEGES ON ownclouddata.* TO 'ownclouduser'@'localhost' IDENTIFIED BY 'enter your password' WITH GRANT   
OPTION;

mysql> FLUSH PRIVILEGES;

mysql> exit;

Configuring Apache

Open your text editor and create the following Apache configuration file.

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>

Restart the Apache service to activate the changes.

systemctl restart httpd

Set SELinux mode to permissive.

Run the following command.

setenforce 0

And change the mode in file.

vi /etc/selinux/config

# This file controls the state of SELinux on the system.
# SELINUX= can take one of these three values:
# enforcing - SELinux security policy is enforced.
# permissive - SELinux prints warnings instead of enforcing.
# disabled - No SELinux policy is loaded.
  SELINUX=permissive
# SELINUXTYPE= can take one of these two values:
# targeted - Targeted processes are protected,
# mls - Multi Level Security protection.
  SELINUXTYPE=targeted

If SELinux is enabled and running, execute the command below to allow the Apache webserver to write to Owncloud’s directory.

setsebool -P httpd_unified 1

Now type your IP address in the URL to complete the ownCloud installation.

http://server_IP/owncloud

You will have to create admin account for ownCloud

Enter the username and password which you want to set.

ownCloud

Now click on the Storage and database and select MySQL/MariaDB

Fill the database information and click on the Finish setup button.

ownClouddb