How to install NextCloud 11 on Centos 7

NextCloud CentOS Logo

NextCloud is a Dropbox-like solution for self-hosted file sharing and syncing. Whether you want to backup, have file-syncing or just have a Google Calendar alternative, this guide is for you.

What is NextCloud? Is it like a “cloud”?

If you stumbled here by chance and don’t know what NextCloud is, here is an article explaining its principal features and advantages/disadvantages. To tell you the truth, NextCloud is a SaaS cloud, if you want to know more about cloud types you can read this article.

In this article we will cover the installation of the server (not the client).

Step1: Install software

Important
I take absolutely NO responsibility of what you do with your machine; use this tutorial as a guide and remember you can possibly cause data loss if you touch things carelessly.

The first step in order to install NextCloud 11 is to install a web server and PHP. Since CentOS 7 ships with PHP 5.4 by default but NextCloud 11 requires at least PHP 7 we’ll also be installing PHP 7.0 from a third-party repository. The following procedure will install apache as webserver. Input the commands one by one to avoid errors!

CentOS 7

If you’d rather use PHP 7.1, you can follow this tutorial: how to install PHP 7.1 on CentOS 7. If you do so, replace each instance of php70w with php71w in the next commands.

Open a terminal and input the following commands:

Step 2: Database selection

Now that you got the software, you need to choose a database that will support the installation. You have three choices:

  • SQLite: is a single-file database. It is suggested only for small installations since it will slow NextCloud down sensibly.
  • MariaDB/MySQL: are popular open source databases especially amongst web developers. It is the suggested choice.
  • PostgreSQL: a popular enterprise-class database. More complicated than MySQL/MariaDB.

Now, this choice won’t really alter the functionality of NextCloud (except if you use SQLite), so pick whatever you know best. If you’re unsure pick MariaDB/MySQL.

SQLiteMySQL/MariaDBPostgreSQL

No additional steps are required if you choose SQLite.

Install the software:

Start (and enable at boot) the service:

Next step is to configure the database management system. During the configuration you will be prompted to choose a root password, pick a strong one.

Now you need to enter the database (you will be asked the password you just set):

Now that you are in create a database:

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:

When you’re done type Ctrl-D to exit.

Install the software:

Run the setup:

Start (and enable at boot) the service:

Now you need to enter the database:

Now that you are in create a database:

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:

When you’re done type \q and press enter to exit.

Warning: You may experience difficulties in authenticating NextCloud with PostgreSQL since the local authentication method is set to ident by default. If you want to change it keep reading.

The configuration file for PostgreSQL is a file located in /var/lib/pgsql/data/pg_hba.conf . Open it with your favourite editor and look for the marked line:

Replace ident with md5 on that line and restart PostgreSQL:

At this point, if you selected MySQL/MariaDB or PostgreSQL restart the webserver in order to load the new PHP extension:

Step 3: Install NextCloud

This step involves getting the software and configure Apache to run it.

CentOS 7

With these step we download the software and extract it:

Now we need to create a new file in /etc/httpd/conf.d/nextcloud.conf . Feel free to use whatever editor you feel comfortable with and add the following lines:

Step 4: Setting Apache and SELinux

In this step we’ll start (and enable) the webserver and we’ll set SELinux up. Now, many tutorials will tell you to disable SELinux (because it is a difficult component to manage). Instead, I suggest you to keep it on and add the rules for NextCloud:

If you decided to use a Mariadb/MySQL/PostgreSQL, you also need to allow apache to access it:

Now that you’ve configured SELinux let’s start and enable Apache:

CentOS/RHEL 7

Start (and enable at boot) the service:

Step 5: Install

Once you’re done with selecting the database, it’s time to install everything. Head to http://YOUR_IP_ADDRESS/nextcloud/ and you will be facing the following screen:

Nextcloud Installation

Nextcloud 11 Installation

Select an administrator username and password, then you can select the data folder, but if you don’t know what you’re doing it’s best if you leave it with the default value. Then click on “Storage & Database” to select the database you chose during step 2. Fill everything and if you’ve followed all the steps correctly you should be seeing the Files app:

Nextcloud Files

Nextcloud 11 Files

Image courtesy of mark | marksei

The following two tabs change content below.
The IT guy with a little boredom look in his eyes, fond of computers since forever he now works as a freelancer in the IT and shares his experiences through this blog.

You may also like...

  • michiel lebbink

    Nice clear instructions. You may want to include firewall commands (just for completeness… and change hmtl to html… took me a minute to find what was wrong :)

    • Hello Michiel,
      thank you for your contribution, I’m fixing the html typo right away. About the firewall, I could include it for reference, I initially excluded it to protect newbie users. Experienced users should be able to configure their distribution firewall without problems.