In this article we will see how to install Nextcloud in CentOS 8 step by step, so that you can mount your own cloud of files and applications for the local network or through the Internet on your CentOS server or VPS.
If you still do not have the necessary environment, it may be advisable to consult our LAMP stack installation guide in CentOS 8 beforehand. On the other hand, Nextcloud can be integrated in the CentOS 8 web service in many ways, either as the main server website, as a separate virtual server or, as we will do in this tutorial for simplicity, as part of the main site. It is also very important to work on HTTPS, although for anyone to try this tutorial, we will work with Nextcloud over HTTP.
How to download Nextcloud for CentOS 8
We are going to download Nextcloud for CentOS 8 from the official site of this application since there are no packages in the system repositories.
Following any of the ” Get Nextcloud ” links we will find the server downloads, where we should display the download options with the ” Details and downloads options ” button:
We will see that the Nextcloud package is available in .tar.bz2 and .zip formats . In this tutorial we will choose the first option, so we will copy the link to download from the console using the wget command :
How to install Nextcloud on CentOS 8
To install Nextcloud on CentOS 8 we must prepare the system by performing a series of tasks prior to running the web installer. We develop these steps below.
We unzipped the package we previously downloaded directly to the location we have decided for the integration of Nextcloud in the web service (in this case, as part of the main website, hosted at /var/www/html/ ):
sudo tar xf nextcloud-18.0.2.tar.bz2 -C /var/www/html/
Nextcloud needs to be able to create and modify files in its own installation directory, so we will change the owner of this directory and its content, becoming the user with whom the web service runs in CentOS 8 ( apache for Apache):
sudo chown -R apache:apache /var/www/html/nextcloud/
It is not enough to adjust the conventional permissions of the Nextcloud files, since if SELinux is activated, which happens by default in CentOS 8, it will be necessary to give read / write context for the web service to these files:
sudo chcon -R -t httpd_sys_rw_content_t /var/www/html/nextcloud/
We will make these permanent changes with semanage command :
sudo semanage fcontext -a -t httpd_sys_rw_content_t "/var/www/html/nextcloud(/.*)?"
On the other hand, to allow the application to connect to the Internet to download modules, updates, etc. we will have to explicitly allow it:
sudo setsebool -P httpd_can_network_connect on
Since Nextcloud is supported by the database service that is running on CentOS 8, in this case MySQL / MariaDB, we will have to prepare what is necessary. We connect the service with the mysql console client :
mysql -u root -p
We create the database for Nextcloud:
create database nextcloud collate utf8mb4_general_ci character set utf8mb4;
In MariaDB or MySQL 5 we create the user as usual:
create user nextcloud@localhost identified by 'XXXXXXXX';
But in MySQL 8 it is better to also specify the authentication plugin:
create user nextcloud@localhost identified with mysql_native_password by 'XXXXXXXX';
We grant permissions to the user on the basis:
grant all privileges on nextcloud.* to nextcloud@localhost;
And we close the connection:
Web service (Apache)
It is important to make a custom configuration for Nextcloud, since this application uses .htaccess files that, by default, are ignored by the web service. We will, therefore, create a new configuration file:
sudo nano /etc/httpd/conf.d/nextcloud.conf
As content we will add the AllowOverride directive that allows the use of .htaccess files :
Alias /nextcloud "/var/www/html/nextcloud/"
SetEnv HOME /var/www/html/nextcloud
SetEnv HTTP_HOME /var/www/html/nextcloud
But we will also adjust some waiting times between the web service and the PHP-FPM service, since there may be errors during the installation if the machine we are working on is not very powerful. We can shorten or lengthen these values as we need.
Saved and closed the file, we reload the configuration of the web service:
sudo systemctl reload httpd
Nextcloud requires the presence in CentOS 8 of certain PHP extensions, so we must ensure that they are installed:
sudo yum install -y php-gd php-json php-mbstring php-xml php-zip
Finished the previous steps we have the system ready to install Nextcloud in CentOS 8 through the web installer. We will access from the browser using the corresponding URL according to the integration in the web service that we have chosen. In this tutorial, for example, just add the path / nextcloud to the IP address or domain of the server:
On the first page of the installer we will enter all the necessary data to configure the installation, which will be:
- The name of the administrator user and what will be his password.
- We deploy ” Storage and database ” and select the database engine we are going to use (MySQL / MariaDB in this tutorial), and enter the connection data as we created it previously.
- We can mark or not the option to download the recommended applications as we are interested.
We will continue the installation by following the link ” Complete the installation “.
In a few moments the installation tasks will finish, the session will start automatically and a brief slide show will be shown, highlighting some of the features and news of Nextcloud:
After the pass, the user’s main page will be displayed, where we can start organizing files and folders, start uploading files, create new users, etc.
Now you can work with your new file cloud and start installing Nextcloud clients for the different systems and devices it supports.
Now that you know how to install Nextcloud in CentOS 8 you can now mount your own cloud of files and applications for the local network or through the Internet on your CentOS server or VPS.