Site icon CentLinux

How to install Nextcloud Server on CentOS 8

Share on Social Media

Learn how to install Nextcloud Server on CentOS 8 with this comprehensive step-by-step guide, enabling private cloud storage and collaboration for your organization. #centlinux #linux #nextcloud

What is Nextcloud?

Nextcloud is a powerful, open-source software platform designed for creating and managing private cloud storage and collaboration environments. It allows individuals and organizations to host their own secure cloud servers, providing capabilities similar to those of commercial services like Google Drive, Dropbox, and Microsoft OneDrive.

Key features of Nextcloud include:

  1. File Storage and Sharing: Users can store, share, and access files from anywhere, on any device.
  2. Collaboration Tools: Includes integrated tools for document editing, calendar management, and communication, supporting seamless collaboration among team members.
  3. Security and Privacy: Offers robust security features such as end-to-end encryption, two-factor authentication, and detailed access controls, ensuring that data remains private and secure.
  4. Customizability: Highly customizable with a wide range of apps and extensions available to extend its functionality.
  5. Self-Hosting: Allows users to host their data on their own servers, giving them complete control over their data and infrastructure.
  6. GDPR Compliance: Helps organizations comply with data protection regulations like GDPR.

Nextcloud is ideal for businesses, educational institutions, and individuals who need a reliable, secure, and flexible cloud storage solution without relying on third-party providers.

Recommended Online Training: Learn Bash Shell in Linux for Beginners

Filecloud vs Nextcloud

FileCloud and Nextcloud are both popular self-hosted cloud storage and collaboration solutions, but they have different features and strengths. Here’s a comparison to help you understand the differences:

FileCloud

Enterprise Focus

Security and Compliance

File Management

Customization and Branding

Integration

Nextcloud

Open-Source and Community-Driven

Collaboration Tools

Security and Privacy

Flexibility and Customization

Integration

Summary

Choosing between FileCloud and Nextcloud depends on your specific needs regarding customization, compliance, integration, and the level of control you require over your data.

Read Also: How to install ownCloud on RHEL 8

Nextcloud System Requirements

Minimum system requirements for Nextcloud server are:

A complete list of recommended software for Nextcloud is available on their website.

Linux Server Specification

We are using a minimal CentOS 8 virtual machine with following specification.

Update your Linux Server

Connect with nextcloud-01.centlinux.com as root user by using a SSH client such as PuTTY.

Use dnf command to update software packages on your Linux operating system.

# dnf update -y

Install MariaDB Server on CentOS 8

Nextcloud software requires a back-end database server to create its data repository.

SQLite is the default database for Nextcloud server, which is good for test environments.

Nextcloud also supports MySQL, MariaDB, Oracle 11g and PostgreSQL databases. But MySQL/MariaDB are the recommended databases for Next Cloud in production environments.

Therefore, you should install MariaDB server on your Linux operating system.

# dnf install -y mariadb-server

Enable and start MariaDB service by executing systemctl command.

# systemctl enable --now mariadb.service
Created symlink /etc/systemd/system/mysql.service â /usr/lib/systemd/system/mariadb.service.
Created symlink /etc/systemd/system/mysqld.service â /usr/lib/systemd/system/mariadb.service.
Created symlink /etc/systemd/system/multi-user.target.wants/mariadb.service â /usr/lib/systemd/system/mariadb.service.

Configure MySQL server and set a strong password for root user.

# mysql_secure_installation

NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MariaDB
      SERVERS IN PRODUCTION USE!  PLEASE READ EACH STEP CAREFULLY!

In order to log into MariaDB to secure it, we'll need the current
password for the root user.  If you've just installed MariaDB, and
you haven't set the root password yet, the password will be blank,
so you should just press enter here.

Enter current password for root (enter for none):
OK, successfully used password, moving on...

Setting the root password ensures that nobody can log into the MariaDB
root user without the proper authorisation.

Set root password? [Y/n] Y
New password:
Re-enter new password:
Password updated successfully!
Reloading privilege tables..
 ... Success!


By default, a MariaDB installation has an anonymous user, allowing anyone
to log into MariaDB without having to have a user account created for
them.  This is intended only for testing, and to make the installation
go a bit smoother.  You should remove them before moving into a
production environment.

Remove anonymous users? [Y/n] Y
 ... Success!

Normally, root should only be allowed to connect from 'localhost'.  This
ensures that someone cannot guess at the root password from the network.

Disallow root login remotely? [Y/n] Y
 ... Success!

By default, MariaDB comes with a database named 'test' that anyone can
access.  This is also intended only for testing, and should be removed
before moving into a production environment.

Remove test database and access to it? [Y/n] Y
 - Dropping test database...
 ... Success!
 - Removing privileges on test database...
 ... Success!

Reloading the privilege tables will ensure that all changes made so far
will take effect immediately.

Reload privilege tables now? [Y/n] Y
 ... Success!

Cleaning up...

All done!  If you've completed all of the above steps, your MariaDB
installation should now be secure.

Thanks for using MariaDB!

Install Nginx Server on CentOS 8

Nextcloud is a PHP based web application, therefore, it requires a LAMP on LEMP server for deployment.

As per documentation use of Apache web server is recommended. However, Nextcloud also supports Nginx web server and we are using the same in this installation guide.

# dnf install nginx -y

Enable and start Nginx service by executing the systemctl command.

# systemctl enable --now nginx.service
Created symlink /etc/systemd/system/multi-user.target.wants/nginx.service â /usr/lib/systemd/system/nginx.service.

Allow Nginx service to be accessible across the network by allowing the relevant service ports in Linux firewall.

# firewall-cmd --permanent --add-service=http
success
# firewall-cmd --reload
success

To verify that Nginx web server is accessible, open the URL http://nextcloud-01.centlinux.com in a web browser.

Nginx Default Webpage

Install PHP on CentOS 8

Finally, you have to install PHP on your Linux server and integrate it with Nginx web server to form the LEMP stack.

We have list down all the required PHP extensions and we are installing all of them with a single dnf command.

# yum install php php-mysqlnd php-fpm php-opcache php-gd php-xml php-mbstring php-common php-json php-curl php-zip php-bz2 php-intl -y

Configure PHP settings for integration with Nginx web server.

# vi /etc/php-fpm.d/www.conf

Locate following parameters.

user = apache
group = apache

and replace with following parameters.

user = nginx
group = nginx

Set following SELinux boolean to allow Nginx web server to execute external programs.

# setsebool -P httpd_execmem 1

Enable and start php-fpm.service by using systemctl command.

# systemctl enable --now php-fpm.service
Created symlink /etc/systemd/system/multi-user.target.wants/php-fpm.service â /usr/lib/systemd/system/php-fpm.service.

To Apply PHP configurations to your Nginx web server, you need to restart it.

# systemctl restart nginx.service

Create a sample PHP page with famous phpinfo() function, to verify the PHP support and check the installed modules.

# vi /usr/share/nginx/html/info.php

Add following PHP code therein.

<?php phpinfo(); ?>

Open URL https://nextcloud-01.centlinux.com/info.php in a web browser.

phpinfo output page

Your LEMP server has been configured successfully.

Install Nextcloud Server on CentOS 8

Nextcloud is free and open source, therefore you can easily download Nextcloud from their official website.

Download NextCloud

Currently, Nextcloud 19 is available for download at their website.

Copy link location of Download Nextcloud button. You will use this URL to download the Nextcloud software from the Linux CLI.

Change directory to /tmp and use the copied URL with wget to download Nextcloud 19 installation archive.

# cd /tmp
# wget https://Nextclouddownload.nextcloud.com/server/releases/nextcloud-19.0.0.zip
--2020-07-12 22:02:38--  https://download.nextcloud.com/server/releases/nextcloud-19.0.0.zip
Resolving download.nextcloud.com (download.nextcloud.com)... 95.217.64.181, 2a01:4f9:2a:3119::181
Connecting to download.nextcloud.com (download.nextcloud.com)|95.217.64.181|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 111544326 (106M) [application/zip]
Saving to: ânextcloud-19.0.0.zipâ

nextcloud-19.0.0.zi 100%[===================>] 106.38M   126KB/s    in 18m 49s

2020-07-12 22:21:27 (96.5 KB/s) - ânextcloud-19.0.0.zipâ saved [111544326/111544326]

The downloaded Nextcloud software is in zip format, therefore, you require unzip utility to extract the contents of downloaded file.

If unzip is not already installed on your Linux server, then you can easily install it by executing dnf command.

# dnf install unzip -y

Extract the contents of downloaded file by using unzip command.

# unzip nextcloud-19.0.0.zip -d /usr/share/nginx/

We have used -d switch to extract the zip file directly into default document root directory of our Nginx web server.

Configure SELinux and File Permissions

Adjust the file permission on Nextcloud server software.

# chown -R nginx:nginx /usr/share/nginx/nextcloud

You are also required to adjust owner-group of following PHP directories.

# chgrp -R nginx /var/lib/php/{opcache,session,wsdlcache}

Since, you are installing Nextcloud with SELinux in enforcing mode. Therefore, you need to add a custom “File Context” of the Nextcloud software directory in SELinux policies.

For this purpose, you can use semanage command. If semanage command is not available in your CentOS / RHEL 8 machine, then you have to install policycoreutils-python-utils package by using Linux package manager.

# semanage fcontext -a -t httpd_sys_rw_content_t '/usr/share/nginx/nextcloud(/.*)?'

Apply the newly added file context on the Nexcloud directory by using restorecon command.

# restorecon -R /usr/share/nginx/nextcloud

Create MariaDB Database

Connect to MariaDB database server as root user.

# mysql -u root -p
Enter password:
Welcome to the MariaDB monitor.  Commands end with ; or g.
Your MariaDB connection id is 16
Server version: 10.3.17-MariaDB MariaDB Server

Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.

Type 'help;' or 'h' for help. Type 'c' to clear the current input statement.

MariaDB [(none)]>

Create a MySQL database for Nextcloud server as follows.

MariaDB [(none)]> CREATE DATABASE nextcloud DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci;
Query OK, 1 row affected (0.143 sec)

Create a user to own nextcloud database.

MariaDB [(none)]> CREATE USER ncuser@localhost IDENTIFIED BY 'Centlinux@123';
Query OK, 0 rows affected (0.209 sec)

Grant all privileges on nextcloud database to ncuser.

MariaDB [(none)]> GRANT ALL PRIVILEGES ON nextcloud.* TO ncuser@localhost;
Query OK, 0 rows affected (0.032 sec)

Reload privileges tables.

MariaDB [(none)]> FLUSH PRIVILEGES;
Query OK, 0 rows affected (0.069 sec)

Exit from MariaDB shell.

MariaDB [(none)]> EXIT;
Bye

Configure Nginx for Nextcloud Server

Edit /etc/nginx/nginx.conf configuration file.

# vi /etc/nginx/nginx.conf

Search and set following directive in this file.

server_name  nextcloud-01.centlinux.com;
root         /usr/share/nginx/nextcloud/;

Restart Nginx service to apply changes.

# systemctl restart nginx.service

Create a data directory for Nextcloud server. This directory is very important because it will hold all the files uploaded by using web interface.

# mkdir /usr/share/nginx/nextcloud/data

Set nginx user as owner of this directory.

# chown -R nginx:nginx /usr/share/nginx/nextcloud/data

Create a SELinux File Context for this directory. So, the nginx user can write on this directory.

# semanage fcontext -a -t httpd_sys_rw_content_t '/usr/share/nginx/nextcloud/data(/.*)?'

Apply the newly added file context on data directory.

# restorecon -R /usr/share/nginx/nextcloud/data/

Access Nextcloud web application by opening URL http://nextcloud-01.centlinux.com in a web browser.

NextCloud Server Configuration

You will be asked to

You can enter the required information.

NextCloud Hub

Click on “Finish Setup” and you will be routed to “Nextcloud Hub”.

By default, we have been logged in as Admin user. You can now use Nextcloud web interface to upload your files.

If you faced difficulty in understanding the above tutorial, we strongly recommend you to read Linux Administration: A Beginner’s Guide, Eighth Edition (PAID LINK) by McGraw-Hill Education.

Final Thoughts

Setting up a Nextcloud server on CentOS 8 is a fantastic way to ensure secure, private cloud storage and collaboration for your organization. By following the steps in this guide, you’ll have a robust and flexible cloud solution tailored to your needs.

If you need professional assistance with installing Nextcloud on your CentOS 8 server or any other server configuration tasks, I offer expert services on Fiverr. Check out my service offerings and get in touch for personalized support: Linux Administration Expert

Thank you for reading, and I look forward to helping you create your private cloud!

Exit mobile version