Knowledgebase

How to Install ownCloud on CentOS 7 Print

  • 0

ownCloud is an open-source file hosting, file sync, and content collaboration web application that lets users store and share personal content on a private server. ownCloud's cross-platform compatibility allows you to access your files anywhere, and because it runs on your private server, it eliminates any need for third-party cloud hosting services.

Similar to cloud hosting services like Dropbox, Google Drive, OneDrive, and many others, ownCloud allows you to store files and share them with anyone on the Internet. To create your own cloud hosting platform with ownCloud, your server must have the necessary software to start the installation.

Prerequisites

  • Deploy a CentOS server instance on Rcs
  • A sudo user account with root access
  • An active domain name pointed to your server
  • LAMP (Linux, Apache, MySQL, PHP) installed on your server

To run, ownCloud requires a fully functioning web server, a database server, and PHP to support the in-browser graphical user interface. In this guide, we anticipate that you already have the LAMP stack installed on your CentOS 7 server; if not, follow the instructions here.

Step 1: Create a MySQL Database

A MySQL database is required to store ownCloud files and extensions. So let's create one; first, login to the MySQL console.

$ mysql -u root -p

Enter your MySQL root password. Once logged in, create a new database for ownCloud.

CREATE DATABASE owncloud;

Create a new database user and assign a strong password.

CREATE USER 'example_user'@'localhost' IDENTIFIED BY 'YOUR_PREFFERED_PASSSWORD';

Now, grant the new user full rights to the ownCloud database.

GRANT ALL PRIVILEGES ON owncloud.* TO 'example_user'@'localhost';

Refresh the MySQL user privileges and exit the console.

 MariaDB [(none)]> FLUSH PRIVILEGES;

 MariaDB [(none)]> exit

Step 2: Install PHP and Necessary Extensions

ownCloud requires 7.2 or above to run, so we need to be sure that at least PHP 7.4 is installed. To do this, let's add a new trusted PHP 7 repository.

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

Now, install PHP and all required extensions.

$ sudo yum --enablerepo=remi-php74 install php php-bz2 php-mysql php-curl php-gd php-intl php-common php-mbstring php-xml php-zip php-posix     -y

Step 3: Install ownCloud

Method 1: Install ownCloud Through the Web Interface

With the LAMP stack installed on your server, ownCloud can run without any technical difficulties. To start the installation process through a web browser, you must download the latest ownCloud complete version using wget.

Install the wget and unzip packages.

$ sudo yum install wget unzip

Now, download the owncloud-complete file.

$ wget https://download.owncloud.org/community/owncloud-complete-20210721.zip

Move the downloaded file to /var/www/html/.

$ sudo mv owncloud-complete.zip /var/www/html/

Now, uncompress the owncloud-complete.zip file to ready installation files.

$ sudo unzip owncloud-complete.zip

Next, grant Apache read and write permissions to the new directory with the apache user account.

$ sudo CHOWN -R apache.apache owncloud/

Now, edit the default Apache main configuration file, httpd.conf, and change the server name and the root web server directory.

Open the file,

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

Set your server's domain name, replace cloud.example.com with your actual domain name.

 ServerName cloud.example.com

Now, change the root web server directory to /var/www/html/owncloud/

  DocumentRoot /var/www/html/owncloud

Save and close the file.

With changes made to Apache configuration files, we need to restart the web server for changes to take effect.

$ sudo service httpd restart

Next, open a web browser on your computer and enter your domain name pointed to the Cent OS 7 server instance, or, enter your server's public IP address in the URL bar.

http://YOUR_DOMAIN   OR   http://YOUR_SERVER_IP

The ownCloud configuration dashboard will be displayed; it's time to create your first administrator account and password. Once entered, click storage and database to select MySQL as the preferred database server, then enter the database name, username, and password created in step 1 of this guide.

Click Finish Setup to start the final ownCloud installation process. It will take a matter of seconds to set up an environment if the provided database information is correct.

Next, you will be redirected to the ownCloud dashboard, from where you can upload, share and view files hosted on your server.

Method 2: Manually Install ownCloud via the Command Line

ownCloud can be installed on CentOS 7 via the command line by adding the platform's repository file to the server. To do this, visit the ownCloud repositories directory, select a version, then choose Cent OS to copy the rpm file URL.

Install the ownCloud repository from the rpm file.

$ sudo yum install https://download.owncloud.org/download/repositories/10.7/CentOS_7/noarch/owncloud-complete-files-10.7.0-2.1.noarch.rpm

Update the server.

$ yum update

A new ownCloud directory will be created at /var/www/html. Change the user and group ownership to Apache to allow the web server to read and write to the directory.

$ chown -R apache.apache owncloud/

Next, edit the Apache main configuration file and change the root web server location to point to the ownCloud directory under /var/www/html.

$ sudo nano /etc/httpd/conf/httpd.conf

Locate the line, DocumentRoot "/var/www/html" and edit it to include /var/www/html/owncloud.

DocumentRoot "/var/www/html/owncloud"

Restart Apache.

$ systemctl restart httpd

Now, use the ownCloud PHP console (occ) to configure the service with an administrator password. By default, the username admin will be used. Then, enter a secure password to install.

$ sudo -u apache php occ maintenance:install 

Your output should be similar to the one below.

[user@example_com owncloud]# sudo -u apache php occ maintenance:install

What is the password you like to use for the admin account <admin>?
creating sqlite db
ownCloud was successfully installed

Finally, load the ownCloud web dashboard by visiting your public server IP or domain name to get started with uploading, downloading, and sharing files hosted on your CentOS server.

https://YOUR_DOMAIN_NAME OR  http://YOUR_SERVER_IP

ownCloud Installation Errors

During the ownCloud installation process, you may encounter some errors depending on your server configuration. Commonly, you will receive an error on ownCloud permissions. You can change the SELinux manage file context mapping definitions for the ownCloud directory to fix this.

$ sudo semanage fcontext -a -t httpd_sys_rw_content_t "/var/www/html/owncloud(/.*)?"
restorecon -R /var/www/html/owncloud

To confirm the change, long list the directory.

$ cd /var/www/html/

$ ls -lZ | grep owncloud

drwxr-x---. apache apache system_u:object_r:httpd_sys_rw_content_t:s0 owncloud

Once fixed, ownCloud will not have any permission problems, and the installation process will go on smoothly.

Also, when you access your ownCloud dashboard from a domain, you may receive an untrusted domain prompt. To fix this, go to the ownCloud/config directory and open config.php to add a new domain.

Open ownCloud config.php

$ sudo nano /var/www/html/owncloud/config/config.php

Add a trusted domain or IP address associated with your server.

  'trusted_domains' => 
 array (
 0 => 'localhost',
1 => 'YOUR_SERVER_IP',
    2=> 'YOUR_DOMAIN_NAME',
 ),

Save and close the file. Then, visit your domain or server IP to access ownCloud.

Congratulations, enjoy hosting your files privately on your server without any limitations.

ownCloud is an open-source file hosting, file sync, and content collaboration web application that lets users store and share personal content on a private server. ownCloud's cross-platform compatibility allows you to access your files anywhere, and because it runs on your private server, it eliminates any need for third-party cloud hosting services. Similar to cloud hosting services like Dropbox, Google Drive, OneDrive, and many others, ownCloud allows you to store files and share them with anyone on the Internet. To create your own cloud hosting platform with ownCloud, your server must have the necessary software to start the installation. Prerequisites Deploy a CentOS server instance on Rcs A sudo user account with root access An active domain name pointed to your server LAMP (Linux, Apache, MySQL, PHP) installed on your server To run, ownCloud requires a fully functioning web server, a database server, and PHP to support the in-browser graphical user interface. In this guide, we anticipate that you already have the LAMP stack installed on your CentOS 7 server; if not, follow the instructions here. Step 1: Create a MySQL Database A MySQL database is required to store ownCloud files and extensions. So let's create one; first, login to the MySQL console. $ mysql -u root -p Enter your MySQL root password. Once logged in, create a new database for ownCloud. CREATE DATABASE owncloud; Create a new database user and assign a strong password. CREATE USER 'example_user'@'localhost' IDENTIFIED BY 'YOUR_PREFFERED_PASSSWORD'; Now, grant the new user full rights to the ownCloud database. GRANT ALL PRIVILEGES ON owncloud.* TO 'example_user'@'localhost'; Refresh the MySQL user privileges and exit the console. MariaDB [(none)]> FLUSH PRIVILEGES; MariaDB [(none)]> exit Step 2: Install PHP and Necessary Extensions ownCloud requires 7.2 or above to run, so we need to be sure that at least PHP 7.4 is installed. To do this, let's add a new trusted PHP 7 repository. $ sudo yum install -y http://rpms.remirepo.net/enterprise/remi-release-7.rpm Now, install PHP and all required extensions. $ sudo yum --enablerepo=remi-php74 install php php-bz2 php-mysql php-curl php-gd php-intl php-common php-mbstring php-xml php-zip php-posix -y Step 3: Install ownCloud Method 1: Install ownCloud Through the Web Interface With the LAMP stack installed on your server, ownCloud can run without any technical difficulties. To start the installation process through a web browser, you must download the latest ownCloud complete version using wget. Install the wget and unzip packages. $ sudo yum install wget unzip Now, download the owncloud-complete file. $ wget https://download.owncloud.org/community/owncloud-complete-20210721.zip Move the downloaded file to /var/www/html/. $ sudo mv owncloud-complete.zip /var/www/html/ Now, uncompress the owncloud-complete.zip file to ready installation files. $ sudo unzip owncloud-complete.zip Next, grant Apache read and write permissions to the new directory with the apache user account. $ sudo CHOWN -R apache.apache owncloud/ Now, edit the default Apache main configuration file, httpd.conf, and change the server name and the root web server directory. Open the file, $ sudo nano /etc/httpd/conf.d/httpd.conf Set your server's domain name, replace cloud.example.com with your actual domain name. ServerName cloud.example.com Now, change the root web server directory to /var/www/html/owncloud/ DocumentRoot /var/www/html/owncloud Save and close the file. With changes made to Apache configuration files, we need to restart the web server for changes to take effect. $ sudo service httpd restart Next, open a web browser on your computer and enter your domain name pointed to the Cent OS 7 server instance, or, enter your server's public IP address in the URL bar. http://YOUR_DOMAIN OR http://YOUR_SERVER_IP The ownCloud configuration dashboard will be displayed; it's time to create your first administrator account and password. Once entered, click storage and database to select MySQL as the preferred database server, then enter the database name, username, and password created in step 1 of this guide. Click Finish Setup to start the final ownCloud installation process. It will take a matter of seconds to set up an environment if the provided database information is correct. Next, you will be redirected to the ownCloud dashboard, from where you can upload, share and view files hosted on your server. Method 2: Manually Install ownCloud via the Command Line ownCloud can be installed on CentOS 7 via the command line by adding the platform's repository file to the server. To do this, visit the ownCloud repositories directory, select a version, then choose Cent OS to copy the rpm file URL. Install the ownCloud repository from the rpm file. $ sudo yum install https://download.owncloud.org/download/repositories/10.7/CentOS_7/noarch/owncloud-complete-files-10.7.0-2.1.noarch.rpm Update the server. $ yum update A new ownCloud directory will be created at /var/www/html. Change the user and group ownership to Apache to allow the web server to read and write to the directory. $ chown -R apache.apache owncloud/ Next, edit the Apache main configuration file and change the root web server location to point to the ownCloud directory under /var/www/html. $ sudo nano /etc/httpd/conf/httpd.conf Locate the line, DocumentRoot "/var/www/html" and edit it to include /var/www/html/owncloud. DocumentRoot "/var/www/html/owncloud" Restart Apache. $ systemctl restart httpd Now, use the ownCloud PHP console (occ) to configure the service with an administrator password. By default, the username admin will be used. Then, enter a secure password to install. $ sudo -u apache php occ maintenance:install Your output should be similar to the one below. [user@example_com owncloud]# sudo -u apache php occ maintenance:install What is the password you like to use for the admin account ? creating sqlite db ownCloud was successfully installed Finally, load the ownCloud web dashboard by visiting your public server IP or domain name to get started with uploading, downloading, and sharing files hosted on your CentOS server. https://YOUR_DOMAIN_NAME OR http://YOUR_SERVER_IP ownCloud Installation Errors During the ownCloud installation process, you may encounter some errors depending on your server configuration. Commonly, you will receive an error on ownCloud permissions. You can change the SELinux manage file context mapping definitions for the ownCloud directory to fix this. $ sudo semanage fcontext -a -t httpd_sys_rw_content_t "/var/www/html/owncloud(/.*)?" restorecon -R /var/www/html/owncloud To confirm the change, long list the directory. $ cd /var/www/html/ $ ls -lZ | grep owncloud drwxr-x---. apache apache system_u:object_r:httpd_sys_rw_content_t:s0 owncloud Once fixed, ownCloud will not have any permission problems, and the installation process will go on smoothly. Also, when you access your ownCloud dashboard from a domain, you may receive an untrusted domain prompt. To fix this, go to the ownCloud/config directory and open config.php to add a new domain. Open ownCloud config.php $ sudo nano /var/www/html/owncloud/config/config.php Add a trusted domain or IP address associated with your server. 'trusted_domains' => array ( 0 => 'localhost', 1 => 'YOUR_SERVER_IP', 2=> 'YOUR_DOMAIN_NAME', ), Save and close the file. Then, visit your domain or server IP to access ownCloud. Congratulations, enjoy hosting your files privately on your server without any limitations.

Was this answer helpful?
Back

Powered by WHMCompleteSolution