How to install NextCloud 14 server on CentOS 7.x

NextCloud is a Dropbox-like solution for self-hosted file sharing and syncing. Installing NextCloud 14 on CentOS is quite simple. 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. In this other article you can find NextCloud 14 new features. 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).
Looking for an earlier version of this tutorial?
- How to install NextCloud 13 server on CentOS 7.x
- How to install NextCloud 12 server on CentOS 7.x
- How to install NextCloud 11 server on Centos 7.x
Step1: Install software
The first step in order to install NextCloud 14 is to install a web server and PHP. Since CentOS 7 ships with PHP 5.4 by default but NextCloud 14 requires at least PHP 7 we’ll also be installing PHP 7 from a third-party repository. The following procedure will install apache as webserver. Input the commands one by one to avoid errors!
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.
Step 3: Install NextCloud
This step involves getting the software and configure Apache to run it.
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:
# semanage fcontext -a -t httpd_sys_rw_content_t '/var/www/html/nextcloud/data(/.*)?' # semanage fcontext -a -t httpd_sys_rw_content_t '/var/www/html/nextcloud/config(/.*)?' # semanage fcontext -a -t httpd_sys_rw_content_t '/var/www/html/nextcloud/apps(/.*)?' # semanage fcontext -a -t httpd_sys_rw_content_t '/var/www/html/nextcloud/.htaccess' # semanage fcontext -a -t httpd_sys_rw_content_t '/var/www/html/nextcloud/.user.ini' # restorecon -Rv '/var/www/html/nextcloud/'
If you decided to use a Mariadb/MySQL/PostgreSQL, you also need to allow apache to access it:
# setsebool -P httpd_can_network_connect_db 1
Now that you’ve configured SELinux let’s start and enable Apache:
Step 5: Configuring firewall
This step is essential when your firewall is enabled. If your firewall is enabled you won’t be able to access your NextCloud 14 instance; on the other hand if it isn’t enabled you shouldn’t have any problems and you can simply skip this step.
In order for the firewall to work, it must be enabled. This guide will not include this part. When you enable a firewall many things can go wrong, e.g. you’re using SSH, you enable the firewall and your connection is cut and can’t connect otherwise, hence you should carefully review the documentation from your distribution.
To open the ports needed by NextCloud 14 follow these steps:
Step 6: Install
Once you’re done, it’s time to install everything. Head to http://YOUR_IP_ADDRESS/nextcloud/ and you will be facing the following screen:
Select an administrator username and password. Then click on “Storage & Database“, here 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 select the database you chose during step 2. Fill everything and if you’ve followed all the steps correctly you should be seeing the following screen:Latest posts by mark (see all)
- 2020 A year in review for Marksei.com - 30 December 2020
- Red Hat pulls the kill switch on CentOS - 16 December 2020
- OpenZFS 2.0 released: unified ZFS for Linux and BSD - 9 December 2020
Hi Mark… Thank you for sharing, please friend its very dificult install nextcluud 14 with nginx and postgres?
Hi Mark thanks for a great tutorial, however its missing a very important and required step.
SSL Installation. I dont really know much about it and would love to see tutorial for NextCloud 14 CentOS7 with LetsEncrypt SSL installation and automatic renewal.
Could you please provide a tutorial for it. I can’t imagine using this installation on open unsecured HTTP connection.
Thanks
Hello Joe I completely agree with you, I wouldn’t expose a NC installation (or whatever site) without SSL at all, especially now that LE gives SSL away for free, to the Internet. I’ve been trying to integrate a LE/SSL tutorial with my NC tutorial series for a long time but I still haven’t found a nice way to integrate it without compromising on the usability of this guide. It will surely come out at some point, in the meanwhile I’ve got a tutorial on setting up Let’s Encrypt! on CentOS be sure to check it out! : )
Hi Mark thank you for all your great work, tutorials are fantastic and easy to follow and thank you for your feedback on SSL issue, and looking forward to some solution that will work perfectly with your tutorials.
I looked into LE SSL but due to the fact that is valid for only 90 Days i would like to stick with 2 other options.
here is a request for
1. Self Generated SSL Cert tutorial on Centos 7 that would work with NextCloud
2. Commercial Validated SSL for NextCloud
i am capable to get 2 years commercial ssl for a decent price. So that would work for me :) as long as they would work with NextCloud.
I would like to deploy it and have it secured asap :)
p.s.
is there a Fail2Ban tut? i would like to protect DB ports SSH and NextCloud Login.
Great work !
Hello Joe, thank you for your appreciation. You shouldn’t worry about the 90-day expiration period on LE certificates, if you configure the certificate for automatic renewal it will literally automatically-renew for another 90 days about 14 days before the actual expiration. This process will work every time and should be considered a valid (and more reliable) alternative to commercial SSL. When a standard SSL certificate expires, you will have to install the new one or your visitors will encounter problems. With LE and Certbot this isn’t the case anymore since the certificates are renewed automatically. If you were to approach a certificate expiration, LE will also send you an email to warn you, and that’s pretty useful.
Self-signed certificates should be avoided for any production deployment, unless you’re the only user. Whatever SSL certificate will work with whatever web application, including NC, so long they’re well coded. SSL actually is more of a web-server thing rather than a web app one.
You shouldn’t expose the DB port to the Internet, unless you have some very specific requirements. You should use Unix sockets or hide the DB port in a private non-Internet-accessible network.
I don’t currently have a Fail2Ban-only tutorial, but you can actually check this tutorial: Change SSH port on CentOS 7. This tutorial includes a fail2ban section that you can easily adapt for port 22 (in case you don’t want to change your port).
Hi, after upgrading to 14.03 y had to install php70w-intl to get rid of errors in nextcloud log like “You are using a fallback implementation of the intl extension. Installing the native one is highly recommended instead.”
I have a similar setup to yours. Just wanted to advice just in case. Truth is maybe some app I’ve installed forced this error.
I checked documentation and php.intl is required.
Regards
Hello Andres, php-intl is indeed recommended, will update my guide(s) as soon as possible. What you’re experiencing is not caused by some other app, but by NextCloud itself that expects to be able to use the library. Can’t yet figure how I missed this one. Thank you for your help : )