How to install Nextcloud on CentOS 8

Nextcloud is open source software to create a cloud storage service like Dropbox or Google Drive but can be installed on your own server.

Nextcloud server supports a variety of major Linux distributions, such as Ubuntu, Debian, Red Hat, CentOS, SUSE, and openSUSE. Meanwhile, the Nextcloud client is available for desktop versions (Windows, macOS, Linux) and mobile versions (Android, iOS, Windows Phone).

*0. System Requirements*

Nextcloud server requires a system with the following specifications:

*Operating System*

· Ubuntu 18.04 LTS (recommended) · Red Hat Enterprise Linux 8 (recommended) · Debian 10 · SUSE Linux Enterprise Server 15 · openSUSE Leap 42.1+ · CentOS 8

*Database*

· MySQL 5.7+ atau MariaDB 10.2+ (recommended) · Oracle Database 11g · PostgreSQL 9/10/11 · SQLite (only recommended for testing)

*Web Server*

· Apache 2.4 dengan mod_php atau php-fpm (recommended) · nginx dengan php-fpm

*PHP Runtime*

· 7.2 · 7.3 (recommended) · 7.4 (recommended)

*Memory* The memory required depends on the number of users, apps, files and server activity.

Nextcloud requires a minimum of 128MB of RAM, a minimum of 512MB of RAM is recommended.

*1. Setting up CentOS 8 Server*

This tutorial uses the CentOS 8 VPS at UpCloud with 1 core CPU specs, 1GB RAM, and 25GB storage.

UpCloud Virtual Private Server

SSH login to server, update system.

[INPUT]

1 dnf update -y

Install *langpack* to resolve the error message *Failed to set locale, defaulting to C.UTF-8*.

[INPUT]

1 dnf install langpacks-en glibc-all-langpacks -y

Install EPEL repository.

[INPUT]

1 dnf install epel-release -y

Install the support package.

[INPUT]

1 dnf install unzip curl wget bash-completion mlocate policycoreutils-python-utils -y

*2. Connect Domain with Server*

This tutorial uses the subdomain *cloud.defnex.com*. In the DNS manager, create a *A record* with *hostname cloud.defnex.com* and *server IP address*.

Defnex.com DNS Records

ping the domain to test if it is connected to the server.

[INPUT]

1 2 3 4 5 6 ping cloud.defnex.com   PING cloud.defnex.com (94.237.74.88) 56(84) bytes of data. 64 bytes from 94-237-74-88.sg-sin1.upcloud.host (94.237.74.88): icmp_seq=1 ttl=53 time=25.0 ms 64 bytes from 94-237-74-88.sg-sin1.upcloud.host (94.237.74.88): icmp_seq=2 ttl=53 time=29.1 ms 64 bytes from 94-237-74-88.sg-sin1.upcloud.host (94.237.74.88): icmp_seq=3 ttl=53 time=34.6 ms

*3. Install Apache Web Server*

Install Apache web server.

[INPUT]

1 dnf install httpd -y

Activate and run the httpd service.

[INPUT]

1 2 3 systemctl enable –now httpd systemctl start httpd systemctl status httpd

Allow http protocol in firewall

[INPUT]

1 2 3 firewall-cmd –add-service=http –permanent firewall-cmd –reload firewall-cmd –list-services

-Apache virtual host-

Create an Apache virtual host configuration file for the domain/subdomain.

[INPUT]

1 2 cd /etc/httpd/conf.d nano cloud.defnex.com.conf

The contents of the virtual host configuration file.

[INPUT]

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18     ServerName cloud.defnex.com     DocumentRoot /var/www/cloud.defnex.com             Options +FollowSymlinks        AllowOverride All                     Dav off               SetEnv HOME /var/www/cloud.defnex.com      SetEnv HTTP_HOME /var/www/cloud.defnex.com            ErrorLog /var/log/httpd/cloud.defnex.com_error.log     CustomLog /var/log/httpd/cloud.defnex.com_access.log combined

Create a document root directory.

[INPUT]

1 2 cd /var/www mkdir cloud.defnex.com

Create a *index.html* file for testing virtual hosts.

[INPUT]

1 2 cd cloud.defnex.com echo “cloud.defnex.com” > index.html

Testing Apache configuration, the result is *Syntax OK*.

[INPUT]

1 2 3 apachectl -t   Syntax OK

Restart httpd service.

[INPUT]

1 2 systemctl restart httpd systemctl status httpd

Browse http://cloud.defnex.com.

Browse http://cloud.defnex.com

*4. Install SSL*

Install Certbot Let’s Encrypt.

[INPUT]

1 dnf install certbot python3-certbot-apache -y

Disable virtual host default SSL configuration.

[INPUT]

1 2 3 cd /etc/httpd/conf.d mv ssl.conf ssl.conf.off systemctl restart httpd

Request an SSL certificate for the subdomain cloud.defnex.com.

[INPUT]

1 certbot –apache -d cloud.defnex.com

Enter the requested information.

[INPUT]

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 Enter email address (used for urgent renewal and security notices) (Enter ‘c’ to cancel): address@email.com – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – –   Please read the Terms of Service at https://letsencrypt.org/documents/LE-SA-v1.2-November-15-2017.pdf. You must agree in order to register with the ACME server at https://acme-v02.api.letsencrypt.org/directory – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – (A)gree/(C)ancel: A   – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – Would you be willing, once your first certificate is successfully issued, to share your email address with the Electronic Frontier Foundation, a founding partner of the Let’s Encrypt project and the non-profit organization that develops Certbot? We’d like to send you email about our work encrypting the web, EFF news, campaigns, and ways to support digital freedom. – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – (Y)es/(N)o: N

SSL installed successfully.

[INPUT]

1 Congratulations! You have successfully enabled https://cloud.defnex.com

SSL Let’s Encrypt

Allow https protocol in firewall

[INPUT]

1 2 3 firewall-cmd –add-service=https –permanent firewall-cmd –reload firewall-cmd –list-services

Browse https://cloud.defnex.com.

Browse https://cloud.defnex.com

*5. Install PHP*

The PHP version available in the default CentOS 8 repository is PHP 7.2. To be able to run PHP 7.4 install the REMI repository.

[INPUT]

1 dnf install https://rpms.remirepo.net/enterprise/remi-release-8.rpm -y

Enable PHP 7.4 stream module.

[INPUT]

1 dnf module enable php:remi-7.4 -y

Install PHP 7.4 along with the extensions needed by the Nextcloud server.

[INPUT]

1 dnf install php74 php74-php php74-php-common php74-php-fpm php74-php-cli php74-php-gd php74-php-mbstring php74-php-intl php74-php-pecl-apcu php74-php-mysqlnd php74-php-opcache php74-php-json php74-php-zip -y

Activate and run the PHP-FPM service.

[INPUT]

1 2 3 systemctl enable –now php74-php-fpm systemctl start php74-php-fpm systemctl status php74-php-fpm

Restart httpd service.

[INPUT]

1 systemctl restart httpd

Create a *info.php* file for PHP tests.

[INPUT]

1 2 cd /var/www/cloud.defnex.com echo “” > info.php

Browse https://cloud.defnex.com/info.php.

PHP Information

If PHP is running properly, delete the info.php and index.html files.

[INPUT]

1 rm -f info.php index.html

*6. Install MariaDB Database*

Install MariaDB database.

[INPUT]

1 dnf install mariadb-server -y

Activate and run the MariaDB service.

[INPUT]

1 2 3 systemctl enable mariadb systemctl start mariadb systemctl status mariadb

Secure MariaDB installation.

[INPUT]

1 mysql_secure_installation

Answer the question.

[INPUT]

1 2 3 4 5 6 Enter current password for root (enter for none): ENTER Set root password? [Y/n] Y Remove anonymous users? [Y/n] Y Disallow root login remotely? [Y/n] Y Remove test database and access to it? [Y/n] Y Reload privilege tables now? [Y/n] Y

Login to MariaDB.

[INPUT]

1 mysql -u root -p

Create a database and user for Nextcloud.

[INPUT]

1 2 3 4 5 CREATE DATABASE nextcloud; CREATE USER ‘usrnxtcld’@’localhost’ IDENTIFIED BY ‘thesecret’; GRANT ALL PRIVILEGES ON nextcloud.* TO ‘usrnxtcld’@’localhost’; FLUSH PRIVILEGES; EXIT;

*7. Install Nextcloud Server*

Download Nextcloud server, extract it, and copy it to the document root directory.

[INPUT]

1 2 3 wget https://download.nextcloud.com/server/releases/nextcloud-19.0.1.zip unzip nextcloud-19.0.1.zip cp -R nextcloud/* /var/www/cloud.defnex.com

Change document root ownership and permissions.

[INPUT]

1 2 3 cd /var/www chown -R apache:apache cloud.defnex.com chmod -R 755 cloud.defnex.com

Check if SELinux is active.

[INPUT]

1 2 3 getenforce   Enforcing

If SELinux is enabled (Enforcing), restore the context document root as a web file.

[INPUT]

1 2 semanage fcontext -a -t httpd_sys_rw_content_t ‘/var/www/cloud.defnex.com(/.*)?’ restorecon -Rv ‘/var/www/cloud.defnex.com’

Browse https://cloud.defnex.com to install Nextcloud.

Create an admin account.

Admin account

Database configuration, click *Storage & database*, click *MySQL/MariaDB*. Enter the username, password and database.

Storage & database

Check *Install recommended apps* if you want to install Calendar, Contacts, Talk, Mail, & Collaborative editing applications.

Finally, click *Finish setup*.

Finish setup

Installing apps

Nextcloud has finished installing.

Nextcloud dashboard

Good luck 🙂

Leave a Reply

Your email address will not be published.