How to Deploy the Nextcloud Cloud Server on AlmaLinux
Nextcloud is an open source cloud server that gives users more security and control than similar clouds do. This tutorial shows how to get started.
Jul 23rd, 2024 11:43am by
What You’ll Need
The only things you’ll need for this basic installment are a running instance of AlmaLinux 9 and a user with sudo privileges. Of course, if you want to point a domain name to the instance, you’ll need an FQDN and secure it with SSL. Since I’m only deploying this to an internal network, I’m not going to worry about those things at the moment. With those things at the ready, let’s install them.Installing the Requirements
There are a few dependencies we have to take care of.Apache
The first thing we’ll do is install the Apache web server. Log into AlmaLinux and issue the command:
sudo dnf install httpd -y
sudo systemctl enable --now httpd
PHP
Next, we’ll install the necessary PHP release. First, enable the EPEL release with:
sudo dnf install epel-release -y
sudo dnf install https://rpms.remirepo.net/enterprise/remi-release-9.rpm -y
sudo dnf module reset php -y
sudo dnf module enable php:remi-8.1 -y
Configure PHP
We now need to configure PHP. Open the configuration file with:
sudo nano /etc/php.ini
sudo nano /etc/php.d/10-opcache.ini
Install the Database
The next step is the installation of the MariaDB database. To do that, we must create a repository file with the command:
sudo nano /etc/yum.repos.d/MariaDB.repo
sudo dnf install MariaDB-server MariaDB-client -y
sudo systemctl enable --now mariadb
sudo mariadb-secure-installation
sudo mariadb -u root -p
CREATE DATABASE netxcloud_db;
CREATE USER nextuser@localhost IDENTIFIED BY 'PASSWORD';
GRANT ALL PRIVILEGES ON netxcloud_db.* TO nextuser@localhost;
Download Nextcloud
Before you download Nextcloud, you’ll need to install a few more bits with:
sudo dnf install unzip wget setroubleshoot-server setools-console -y
cd /var/www/
sudo wget https://download.nextcloud.com/server/releases/latest.zip
sudo unzip latest.zip
sudo chown -R apache:apache /var/www/nextcloud
SELinux
Unless we configure SELinux properly, Nextcloud will not function. The first thing to do is to properly label all of the Nextcloud files and folders with the following commands: Next, you must allow the webserver to connect to the network with the following commands: We have to create a new policy module to ensure PHP-FPM can connect to the MariaDB socket. First, create a new file with the command:
sudo nano my-phpfm.te
sudo checkmodule -M -m -o my-phpfpm.mod my-phpfpm.te
sudo semodule_package -o my-phpfpm.pp -m my-phpfpm.mod
sudo semodule -i my-phpfpm.pp
Virtual Host
We now have to create a virtual host file with the command:
sudo nano /etc/httpd/conf.d/nextcloud.conf
sudo systemctl restart httpd
Finishing Up the Installation
You should now be able to point a web browser to http://SERVER (where SERVER is the IP address of the hosting server) and be greeted by the Nextcloud web-based installer, where you can create an admin user and finish up the process with a few clicks. If you find there’s an error connecting to the database and writing to the data directory, temporarily disable SELinux (until the next reboot) with: After the installation completes, reboot the machine and SELinux is back to keeping tabs on the system and Nextcloud is up and running. And that, my friends, is how you deploy Nextcloud to AlmaLinux.
YOUTUBE.COM/THENEWSTACK
Tech moves fast, don't miss an episode. Subscribe to our YouTube
channel to stream all our podcasts, interviews, demos, and more.