Install and Configure Nextcloud on CentOS 7 / RHEL 7

Configure Nextcloud on CentOS 7
Configure Nextcloud on CentOS 7

NextCloud is an open source web suite that provides a cloud storage over the network, fork of ownCloud. It is like a Dropbox that permits you to store and share your documents and pictures in a centralized location.

System Requirements:

NextCloud works on top of LAMP,

READ: Configure LAMP on CentOS 7 / RHEL 7

Linux: Redhat Enterprise Linux / CentOS 6 and 7, Ubuntu (14.04 & 16.04), Debian 7, SUSE Enterprise Server 11 SP3 & 12.

Apache 2 with mod_php

Database: MySQL / MariaDB, PostgreSQL, Oracle 11g.

PHP 5.4+

The commercial version of NextCloud is also available.


  • Access your files anytime, anywhere.
  • Share your files with the other users. Create and send password protected public links.
  • Two-factor authentication with TOTP and QR code.
  • Monitor the activity on your NextCloud server.
  • NextCloud can access files stored in external cloud storage service providers such as Amazon, Google, and Dropbox.

More here.


We will install the required packages for LAMP stack and the important PHP extension that NextCloud rely on.

yum -y install wget bzip2 mariadb-server php php-mysql php-dom php-gd php-mbstring php-posix php-xmlwriter php-zip

Download and Setup:

NextCloud provides you the archives for server admin’s to download and manually set it up on top of LAMP.

cd /tmp/
tar -jxvf nextcloud-10.0.1.tar.bz2
mv nextcloud /var/www/html/
mkdir /var/www/html/nextcloud/data

Add FirewallD rules to allow Apache traffic in the firewall.

firewall-cmd --permanent --zone=public --add-service=http
firewall-cmd --permanent --zone=public --add-service=https
firewall-cmd --reload

Set the ownership of the files inside the NextCloud directory so that apache user can write the data into it.

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

Start Apache and MariaDB services.

systemctl start httpd.service
systemctl start mariadb.service

Configure the both service to start automatically at system start-up.

systemctl enable httpd.service
systemctl enable mariadb.service

Create Database:

If you are setting up a MariaDB for the first time.

READ: Secure MariaDB with mysql_secure_installation

Ensure MariaDB service is running before attempting to create the database. Now, login to MariDB server.

mysql -u root -p

Create database called “nextclouddb

create database nextclouddb;

Allow “nextclouduser” to access the “nextclouddb” database on localhost with a predefined password.

grant all on nextclouddb.* to 'nextclouduser'@'localhost' identified by 'password';

Exit from the MariaDB prompt.



Set SELinux context to allow NextCloud to write the data inside its important directories.

restorecon -Rv /var/www/html/nextcloud
semanage fcontext -a -t httpd_sys_rw_content_t '/var/www/html/nextcloud/data'
restorecon '/var/www/html/nextcloud/data'
semanage fcontext -a -t httpd_sys_rw_content_t '/var/www/html/nextcloud/config'
restorecon '/var/www/html/nextcloud/config'
semanage fcontext -a -t httpd_sys_rw_content_t '/var/www/html/nextcloud/apps'
restorecon '/var/www/html/nextcloud/apps'

Configure NextCloud on CentOS 7:

Open up your web browser, point a URL to


The browser will take you automatically to NextCloud setup page where you have to begin the setup of NextCloud.

Enter admin details (username and password), data folder location where all of your documents get saved, and database information.

You can choose either SQLite or MySQL/MariaDB. If you want to SQLite database then you do not have to enter database details (not recommended for production use). Whereas MariaDB requires database user, password and database name.

For this tutorial, we will use MariaDB as a backend database.

Configure NextCloud on CentOS 7 – Setup
Configure NextCloud on CentOS 7 – Setup

Alternately you can download NextCloud client to upload the files.

Configure NextCloud on CentOS 7 – NextCloud Apps
Configure NextCloud on CentOS 7 – NextCloud Apps

The home page of NextCloud will look like below, and you can start uploading the contents using using “+ sign” button.

Configure NextCloud on CentOS 7 – Upload Files
Configure NextCloud on CentOS 7 – Upload Files


The default maximum file size for uploads is 2MB. You can increase this limit by editing relevant php.ini file.

vi /etc/php.ini

Modify the below entries according to your requirements.

upload_max_filesize 2048M
php_value post_max_size 2048M

And then, restart Apache service.

systemctl restart httpd.service

That’s All!.

You might also like

Comments are closed.