Installing ownCloud on CentOS 7

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

OwnCloud 10.0.7 requires the following installed and running.

PHP 7.0 or above with the following extension (XML, curl, ctype, JSON, iconv, intl, mcrypt, PDO, Phar, GD Graphics Library version 2.0.x+, DOM, openssl, bz2, Zlib and Zip.) MySQL 5.5 or above version, Apache web server 2.0

Update the OS Packages

yum update -y

Now install PHP 7.2 using the following commands.

First, we Install the EPEL and Remi repository packages.

yum install epel-release yum-utils -y

yum install http://rpms.remirepo.net/enterprise/remi-release-7.rpm

yum-config-manager --enable remi-php72

Install PHP7.2 and required PHP extension which is required for owncloud using the following command.

yum install php php-mysqlnd php-pecl-zip php-xml php-mbstring php-gd php-mcrypt php-pear php-pspell php-pdo php-xml php-intl php-zip php-zlib

Extension

Open the PHP configuration file and increase the upload file size.

vi /etc/php.ini

Change post_max_size to 256 MB and upload_max_filesize to 256MB and save the file

We can set the post_max_size and upload_max_filesize as per the need

Restart the httpd service after the change

systemctl restart httpd.service

Download ownCloud and extract it using the following command.

cd /opt && wget https://download.owncloud.org/community/owncloud-10.0.7.zip

Download_owncloud

Extract the downloaded file.

unzip -d /var/www/html/ owncloud-10.0.7.zip

Now change the permissions of owncloud directory.

chown apache:apache -R /var/www/html/owncloud/
chmod +R 755 /var/www/html/owncloud

Create a new MySQL database.

mysql -u root -p
mysql> CREATE DATABASE ownclouddb;
mysql> GRANT ALL PRIVILEGES ON ownclouddb.* TO 'ownclouduser'@'localhost' IDENTIFIED BY 'enter your password' WITH GRANT OPTION;
mysql> FLUSH PRIVILEGES;
mysql> exit

Create a new virtual host in Apache.

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

And, paste the following lines and enter your server IP address and save the file.

<VirtualHost YOUR_SERVER_IP:80>
ServerAdmin webmaster@yourdomain.com
DocumentRoot "/var/www/html/owncloud/"
<Directory "/var/www/html/owncloud/">
DirectoryIndex index.html index.php
Options FollowSymLinks
AllowOverride All
Require all granted
</Directory>
</VirtualHost>

Create a new ownCloud ownClouddata directory outside of the document root and change the permission of it.

mkdir -p /opt/data
chown apache:apache -R /opt/ownClouddata/

Restart the Apache web server for the changes to take effect.

systemctl restart httpd.service

Open the port in firewall using following command.

firewall-cmd --zone=public --add-port=80/tcp --permanent
firewall-cmd --reload

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

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

http://server_IP

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