Installing ownCloud on CentOS7

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
  1. Update the OS Packages

    yum update -y
  2. Now install PHP 7.1 using the following commands

    First, we Install the EPEL and Remi repository packages:
    rpm -Uvh
    yum-config-manager --enable remi-php71

    Install PHP7.1 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


  3. 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
  4. Download ownCloud and extract it using the following command.

    cd /opt && wget


    Extract the downloaded file.

    unzip -d /var/www/html/

    Now change the permissions of owncloud directory.

    chown apache:apache -R /var/www/html/owncloud/
  5. 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> exit
  6. 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 [email protected]
    DocumentRoot "/var/www/html/owncloud/"
    <Directory "/var/www/html/owncloud/">
    DirectoryIndex index.html index.php
    Options FollowSymLinks
    AllowOverride All
    Require all granted
  7. 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
  8. 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:

    Enforcing 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.
    # SELINUXTYPE= can take one of these two values:
    # targeted - Targeted processes are protected,
    # mls - Multi Level Security protection.
  9. Now type your IP address in the URL to complete the ownCloud installation

    http://your IP address:80

    You will have to create admin account for ownCLoud

    Enter the username and password which you want to set.


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

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