Guides 11792 Published by

This guide walks you through turning a fresh Rocky Linux 8 or AlmaLinux 8 machine into a self‑hosted file server that feels like your own cloud. It covers updating the system, adding EPEL, installing Apache, MariaDB and PHP, securing the database, creating Nextcloud’s database user, downloading and unpacking the latest tarball, configuring Apache with a virtual host and .htaccess support, and reloading the service. After launching the web installer you set up the data folder, link to MariaDB, pick an admin password, and then optionally secure everything with certbot‑generated HTTPS certificates while noting common pitfalls like mixing PHP handlers or misconfiguring Apache. With optional tuning for large media uploads, gzip compression, and timeouts, you finish the setup and can start adding users, quotas, and shared links, enjoying full control over your private cloud.



Deploy Your Private Cloud with Nextcloud on Rocky Linux 8 or Alma Linux 8

In this guide you’ll learn how to turn a fresh Rocky Linux 8 or Alma Linux 8 box into a self‑hosted file server that feels like your own cloud. From installing the base stack to tweaking the web interface, every step is laid out so you can skip the trial‑and‑error phase.

Installing the Base System

1. Update everything first

sudo dnf update -y

A clean start prevents hidden bugs later on; I’ve seen broken packages after a half‑completed upgrade in some older installs.

2. Add the EPEL repository

sudo dnf install epel-release -y

EPEL ships handy dependencies that RHEL‑based systems miss out on, like MariaDB and PHP‑modules.

3. Install Apache, MariaDB and PHP

   sudo dnf install httpd mariadb-server php php-mysqlnd \
       php-gd php-xml php-json php-curl -y

Those PHP packages give Nextcloud the features it needs (image handling, database access, HTTPS support).

4. Enable and start services

   sudo systemctl enable --now httpd mariadb
Securing MariaDB

1. Run the security wizard:

sudo mysql_secure_installation

It forces a root password and removes remote access to the database, which is a common pitfall when people forget to lock down MySQL.

2. Create the Nextcloud DB and user:

   sudo mysql -u root -p

Inside MySQL:

   CREATE DATABASE nextcloud;
   GRANT ALL PRIVILEGES ON nextcloud.* TO 'nextcloud'@'localhost' IDENTIFIED BY 'StrongPasswordHere';
   FLUSH PRIVILEGES;
   EXIT;
Pulling and Installing Nextcloud

1. Download the latest tarball:

wget https://download.nextcloud.com/server/releases/nextcloud-25.0.4.zip

2. Unpack it into Apache’s root:

   sudo unzip nextcloud-25.0.4.zip -d /var/www/html/
   sudo chown -R apache:apache /var/www/html/nextcloud

3. Tell Apache to serve the folder (replace example.com with your domain):

   <VirtualHost *:80>
       ServerName example.com
       DocumentRoot /var/www/html/nextcloud

       <Directory /var/www/html/nextcloud/>
           Require all granted
           AllowOverride All
           Options FollowSymLinks MultiViews
       </Directory>
   </VirtualHost>

AllowOverride All lets Nextcloud’s .htaccess do the heavy lifting for URL rewriting.

4. Reload Apache:

sudo systemctl restart httpd

Finishing with the Web Installer

Open a browser to http://your-server-ip/nextcloud.

On the setup screen you’ll need:

  • Data folder – choose /var/www/html/nextcloud/data (or any other location, but keep it on the same disk for speed).
  • Database type – MariaDB.
  • User credentials – pick a strong admin password; I usually go with something that’s not my everyday Wi‑Fi key.

If everything lines up, Nextcloud will populate its tables and you’ll see the familiar “Welcome to your new cloud” screen.

Enabling HTTPS (Optional but Recommended)

1. Install certbot:

sudo dnf install python3-certbot-apache -y

2. Run it against your domain:

sudo certbot --apache -d example.com

3. Certbot automatically edits the Apache config to redirect HTTP => HTTPS and sets up auto‑renewal.

Common Pitfall I’ve Seen

I once had a user who ran sudo dnf install php-fpm on a Rocky machine expecting PHP to be faster, but forgot to disable mod_php in Apache. The result? PHP errors flooding the logs and the whole site going blank. Keep it simple: stick with one PHP handler per server.

Tuning Performance (Optional)

If you’re serving large media files, add this to php.ini:

upload_max_filesize = 500M
post_max_size = 500M
memory_limit = 512M

And in /etc/httpd/conf.d/nextcloud.conf, bump the Timeout and enable Deflate for gzip compression.

Done!

You’ve got a fully functional, self‑hosted Nextcloud instance running on Rocky Linux 8 or Alma Linux 8. It’s now up to you to add users, tweak storage quotas, and maybe even spin off a public link for that friend who keeps asking where they can drop a photo.