How To Install NextCloud — File Share and Collaboration platform On CentOS 7

NextCloud is an open source, self-hosted file share and collaboration platform, similar to Dropbox. It comes bundled with media player, calendar and contact management. Nextcloud is extensible via apps and has desktop and mobile clients for all major platforms.

In this tutorial, we are installing NextCloud on CentOS 7. To configure NextCloud File Sharing Application, we will install Apache, PHP & MySQL then we will configure NextCloud.

We will install and set up a NextCloud on Alibaba Cloud Elastic Compute Service (ECS) with CentOS 7 installed.


  • 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.


  • You must have Alibaba Cloud Elastic Compute Service (ECS) activated and verified your valid payment method. If you are a new user, you can get $300 — $1200 worth in Alibaba Cloud credits for your new account. If you don’t know how to setup your ECS instance, you can refer to this tutorial or quick-start guide.
  • A domain name registered from Alibaba Cloud. If you have already registered a domain from Alibaba Cloud or any other host, you can update its domain nameserver records.
  • Domain name must be pointed to your Alibaba Cloud ECS’s IP address
  • Access to VNC console in your Alibaba Cloud or SSH client installed in your PC
  • Set up your server’s hostname and create a user with root privileges.

Environment Specification

We have configured a CentOS 7 virtual machine with following specifications.

  • CPU — 3.4 Ghz (2 cores)
  • Memory — 2 GB
  • Storage — 40 GB
  • Operating System — CentOS 7.6
  • Hostname —
  • IP Address —

Installing Prerequisite Packages for NextCloud:

Nextcloud works only with PHP v7.x. So, we need to enable software collection repository.

So, Install required software packages using yum command.

Install Apache

Install the Apache server and other utilities.

Install PHP 7.x

Install PHP 7 and other required extensions for Nextcloud.

Create symlinks so that Apache can support PHP 7.x.

Also, create a symlink for executing the php command.

Install MariaDB

The database can be any of from SQLite, MySQL/MariaDB, Oracle or PostgreSQL database.

For this demo, we will use MariaDB as a database for Nextcloud, and we will talk about the reason behind it later.


Start the Apache and MariaDB service using the following command.

Enable both Apache and MariaDB service to start automatically at system start-up.

Install Nextcloud

NextCloud provides installable archives for server admins to download and manually set it up on top of the LAMP stack. Download the latest version of Nextcloud using the terminal.

Extract the Nextcloud archive using the tar command.

Move the extracted files to Apache’s document root and then create a data directory to hold the user data.

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

Create Database

If you are setting up a MariaDB for the first time, then

Now, login to the MariaDB server.

Create a database called “nextclouddb“.

Now you need to create the user that will be used to connect to the database:

The last step is to grant the privileges to the new user:

Exit from the MariaDB prompt.


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


Configure the firewall to allow access to the Nextcloud storage from external machines.

Setup NextCloud

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.

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.

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

Access Nextcloud

Once the set up is complete, you will get the below popup. Click on close.

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


That’s All. We have successfully installed NextCloud — File Share and Collaboration platform on CentOS 7.

To find more information about how to manage your Nextcloud instance visit the Documentation page.

If you have any questions, please leave a comment below.

Original Source:

Follow me to keep abreast with the latest technology news, industry insights, and developer trends.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store