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 :
1 |
wget https://download.nextcloud.com/server/releases/nextcloud-18.0.2.tar.bz2 |
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.
Nextcloud files
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/ ):
1 |
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):
1 |
sudo chown -R apache:apache /var/www/html/nextcloud/ |
SELinux
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:
1 |
sudo chcon -R -t httpd_sys_rw_content_t /var/www/html/nextcloud/ |
We will make these permanent changes with semanage command :
1 |
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:
1 |
sudo setsebool -P httpd_can_network_connect on |
Database
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 :
1 |
mysql -u root -p |
We create the database for Nextcloud:
1 |
create database nextcloud collate utf8mb4_general_ci character set utf8mb4; |
In MariaDB or MySQL 5 we create the user as usual:
1 |
create user nextcloud@localhost identified by 'XXXXXXXX'; |
But in MySQL 8 it is better to also specify the authentication plugin:
1 |
create user nextcloud@localhost identified with mysql_native_password by 'XXXXXXXX'; |
We grant permissions to the user on the basis:
1 |
grant all privileges on nextcloud.* to nextcloud@localhost; |
And we close the connection:
1 |
exit |
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:
1 |
sudo nano /etc/httpd/conf.d/nextcloud.conf |
As content we will add the AllowOverride directive that allows the use of .htaccess files :
1 2 3 4 5 6 7 8 9 10 11 12 13 14 |
Alias /nextcloud "/var/www/html/nextcloud/" <Directory /var/www/html/nextcloud/>; Options +FollowSymlinks AllowOverride All <IfModule mod_dav.c>; Dav off </IfModule> SetEnv HOME /var/www/html/nextcloud SetEnv HTTP_HOME /var/www/html/nextcloud </Directory> |
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:
1 |
sudo systemctl reload httpd |
PHP
Nextcloud requires the presence in CentOS 8 of certain PHP extensions, so we must ensure that they are installed:
1 |
sudo yum install -y php-gd php-json php-mbstring php-xml php-zip |
Web Installer
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.
Conclusion
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.