How do I install Nextcloud 20 on CentOS 7 Linux?. This guide will walk you through the installation of Nextcloud 20 on CentOS 7 with PHP 7.3, Apache and MariaDB 10.4. You can optionally configure SSL encryption with Let’s Encrypt to ensure that access and data is being transferred through a secure tunnel.

For Ubuntu/ Debian, check: How to Install Nextcloud on Ubuntu / Debian

Nextcloud is an open-source seft-hosted syncing and file sharing server forked from ownCloud. It is written in PHP and JavaScript and has support for MySQL, PostgreSQL, SQLite and Oracle Database.

Install NextCloud on CentOS 7 with Let’s Encrypt SSL

Nextcloud provides client applications for Windows, Linux, macOS, Android and iOS which are used to sync files between your Desktop and the Nextcloud file server. It also has a modern and easy-to-use web interface which enables you to access files from a web browser.

Follow the steps provided in this article to install and configure Nextcloud on your CentOS 7 server. It can be a freshly installed or a server with running applications provided you can satisfy pre-requisites and required dependencies.

Disable SELinux or Put in in Permissive mode

Consider disabling SELinux for smooth operations:

sudo setenforce 0
sudo sed -i 's/^SELINUX=.*/SELINUX=permissive/g' /etc/selinux/config

Step 1: Install PHP and httpd

We require PHP and Apache to run Nextcloud on CentOS 7. For PHP, we will use PHP 7.3 since it is the latest stable release of PHP available for CentOS 7. This is available on Remi repository which needs to be added prior to installation.

sudo yum -y install epel-release yum-utils
sudo yum -y install

Disable default PHP 5.x enabled repository and enable one for PHP 7.3:

sudo yum-config-manager --disable remi-php54
sudo yum-config-manager --enable remi-php73

Then install Apache and PHP packages:

sudo yum -y install vim httpd php php-cli php-mysqlnd php-zip php-devel php-gd php-mcrypt php-mbstring php-curl php-xml php-pear php-bcmath php-json php-pdo php-pecl-apcu php-pecl-apcu-devel

Confirm your PHP version

$ php -v
PHP 7.3.1 (cli) (built: Jan 8 2019 13:55:51) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.3.1, Copyright (c) 1998-2018 Zend Technologies

Step 2: Install and Configure MariaDB / MySQL

Install MariaDB / MySQL database server on CentOS 7 using our previous guides. Choose one, recommended is MariaDB.

Install MariaDB 10.x on Ubuntu 18.04 and CentOS 7

After the installation, login as a root user to MySQL console and create a new database for Nextcloud.

$ mysql -u root -p
CREATE USER 'nextcloud'@'localhost' IDENTIFIED BY "StrongPassword";
GRANT ALL PRIVILEGES ON nextcloud.* TO 'nextcloud'@'localhost';

Step 3: Download and Install Nextcloud on CentOS 7

Download the latest release of Nextcloud:

sudo yum -y install wget unzip

Unzip the downloaded file:

rm -f

Move the resulting nextcloud folder to /var/www/html directory.

sudo mv nextcloud/ /var/www/html/

Create data directory to store Nextcloud uploaded files. This can be any path e.g NFS mount point, SAN mount point e.t.c.

sudo mkdir /var/www/html/nextcloud/data
sudo chown apache:apache -R /var/www/html/nextcloud/data

Give apache user and group the ownership of nextcloud folder.

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

Step 4: Configure Apache VirtualHost – Without SSL

Now create an Apache configuration file for Nextcloud.

sudo vim /etc/httpd/conf.d/nextcloud.conf

Paste below content to the file.

<VirtualHost *:80>
  ServerAdmin [email protected]
  DocumentRoot /var/www/html/nextcloud
  <directory /var/www/html/nextcloud>
    Require all granted
    AllowOverride All
    Options FollowSymLinks MultiViews
    SetEnv HOME /var/www/html/nextcloud
    SetEnv HTTP_HOME /var/www/html/nextcloud

Set correct ServerName and change other settings to suit your use. When done, save the file and start httpd service.

sudo systemctl enable --now httpd
sudo semanage fcontext -a -t httpd_sys_content_t "/var/www/html(/.*)?"
sudo sudo restorecon -Rv /var/www/html

Configure Firewall:

If you have an active firewalld service, allow http and https ports.

sudo firewall-cmd --add-service={http,https} --permanent
sudo firewall-cmd --reload

Step 5: Configure Apache With Let’s Encrypt SSL

To use Let’s Encrypt SSL certificate, first install certbot

chmod a+x certbot-auto
sudo mv certbot-auto /usr/local/bin

Then request for SSL certificate.

export DOMAIN=""
export EMAIL="[email protected]"
certbot-auto certonly --standalone -d $DOMAIN --preferred-challenges http --agree-tos -n -m $EMAIL --keep-until-expiring

Modify your VirtualHost configuration file to look like below.

<VirtualHost *:80>
   ServerAdmin [email protected]
   RewriteEngine On
   RewriteCond %{HTTPS} off
   RewriteRule ^(.*)$ https://%{HTTP_HOST}$1 [R=301,L]

<IfModule mod_ssl.c>
   <VirtualHost *:443>
     ServerAdmin [email protected]
     DocumentRoot /var/www/html/nextcloud
     <directory /var/www/html/nextcloud>
        Require all granted
        AllowOverride All
        Options FollowSymLinks MultiViews
        SetEnv HOME /var/www/html/nextcloud
        SetEnv HTTP_HOME /var/www/html/nextcloud
     SSLEngine on
     SSLCertificateFile /etc/letsencrypt/live/
     SSLCertificateKeyFile /etc/letsencrypt/live/

Step 6: Access Nextcloud UI and finish installation

Open your nextcloud server URL as configured on Apache:

Create admin account on first page.


Provide admin username and password. Also configure MySQL / MariaDB database.


When done click the “Finish Setup” button. You should get the Files dashboard of Nextcloud. Now install Nextcloud Agent on your end device to start syncing files.

Thanks for using our guide to install Nextcloud 20 on CentOS 7. Stay connected for more informative guides.

More guides:

Setup GlusterFS Storage With Heketi on CentOS 8 / CentOS 7

How To Setup S3 Compatible Object Storage Server with Minio

Install and Use Stratis to Manage Local Storage on RHEL 8 / CentOS 8

Your support is our everlasting motivation,
that cup of coffee is what keeps us going!

As we continue to grow, we would wish to reach and impact more people who visit and take advantage of the guides we have on our blog. This is a big task for us and we are so far extremely grateful for the kind people who have shown amazing support for our work over the time we have been online.

Thank You for your support as we work to give you the best of guides and articles. Click below to buy us a coffee.


Please enter your comment!
Please enter your name here