
Nextcloud is a free and open-source platform for hosting and managing file storage services. It offers similar functionality to Google Drive, such as file sharing and collaboration, but runs entirely on infrastructure you control. Its source code is publicly available on GitHub for review and contributions.
In this article, you will deploy Nextcloud on Rocky Linux 9 using either a manual installation with Nginx, PHP, and MariaDB, or a containerized installation with Docker and Docker Compose. Both methods include secure web server configuration, database setup, and optional HTTPS support for encrypted access.
Before you begin, ensure you:
sudo privileges.nextcloud.example.com.This section sets up the system to install Nextcloud. You'll update your packages, install required tools, and prepare the environment for web, database, and PHP services.
Update the system packages.
When prompted, press Y to confirm and install available updates.
Install system utilities and dependencies.
These packages provide essential tools for web application setup and SELinux management.
Download the latest Nextcloud release.
This command downloads the latest stable version of Nextcloud to your current working directory.
Extract the archive.
This creates a nextcloud/ directory containing the web application files.
Ensure the target web root directory exists.
Move the extracted files to /var/www.
The Nextcloud files are now ready to be served from /var/www/nextcloud.
Nextcloud stores its configuration and user data in a relational database. It supports MySQL, PostgreSQL, SQLite, and Oracle, but SQLite is recommended only for testing or small-scale environments. In this section, install and configure MariaDB as the production database backend.
Create a custom repository file for MariaDB.
Install the MariaDB server and client.
Start and enable MariaDB at boot.
Secure your MariaDB installation.
The script guides you through setting the root password and adjusting basic security options. When prompted, enter a strong root password, then answer Y to the remaining prompts to apply the recommended defaults.
Log in to the MariaDB root account.
Enter the root password you set during mariadb-secure-installation.
Create the Nextcloud database.
Create a dedicated database user for Nextcloud.
Replace StrongPass with an alphanumeric, secure password.
Grant the user full privileges on the Nextcloud database.
Reload the privileges.
Exit the MariaDB console.
Test the new database user login.
Enter the password you set earlier.
Verify that the nextcloud database exists.
Output:
Exit the session by typing exit.
Nextcloud requires specific MariaDB settings for compatibility and performance. Modify the MariaDB configuration to meet these requirements.
Edit the MariaDB configuration file.
Under the [mysqld] section, add the following lines:
bind-address = 127.0.0.1: Restricts connections to localhost.character_set_server and collation_server: Configure utf8mb4 for full Unicode support.transaction_isolation = READ-COMMITTED: Prevents uncommitted read inconsistencies.binlog_format = ROW: Improves replication accuracy and recovery.In the [server] section of the same file, add the following:
skip_name_resolve: Disables DNS lookups to improve connection speed.innodb_* parameters: Configure buffer pools, flushing, and log buffers for balanced performance.query_cache_* parameters: Manage the query cache (note: deprecated in MariaDB 11.4 and may be ignored).tmp_table_size and max_heap_table_size: Define limits for temporary and in-memory tables.slow_query_log options: Enable and configure slow query logging for performance analysis.Restart MariaDB to apply the changes.
Verify that MariaDB is running.
Nextcloud requires PHP to run. Version 8.3 or higher is recommended for better performance, memory management, and compatibility. In this section, install PHP 8.3, enable necessary modules, and configure PHP-FPM to work with Nginx.
Check available PHP streams.
PHP 8.3 is available by default in Rocky Linux 9, but some packages may not be included. To ensure all required modules are accessible, you need to add and enable the Remi repository for PHP 8.3.
Add the Remi repository.
The Remi repository is a trusted third-party repo that maintains up-to-date PHP builds for Enterprise Linux distributions.
Enable the Remi repository and PHP 8.3 module.
Install PHP 8.3, PHP-FPM, and required extensions.
Edit the PHP-FPM configuration to use the nginx user.
Change the following lines:
Increase the PHP memory limit.
Change the following line:
Enable and start PHP-FPM.
Update SELinux to allow PHP-FPM access to the MariaDB socket.
Restart all services to apply the changes.
Nextcloud requires a web server to serve its frontend and handle PHP requests. Nginx is a lightweight and high-performance web server well-suited for this task. Follow these steps to install and configure it.
Install Nginx.
DNF automatically accepts the GPG key and installs the stable version from the configured repository.
Enable and start the Nginx service.
Verify that Nginx is active.
The output should indicate that the service is active (running).
Allow HTTP and HTTPS traffic through the firewall.
Reload the firewall to apply the changes.
Visit your server’s IP address in a browser. If Nginx is installed correctly, the default welcome page appears:
Change file ownership for the Nextcloud directory to allow Nginx to read and execute the files.
Set directory permissions to give the owner read, write, and execute access.
Create a new configuration file for Nextcloud.
Add the following content. Replace nextcloud.example.com with your actual domain.
Test the Nginx configuration.
Output:
Allow Nginx access to Nextcloud files using SELinux.
Restart Nginx web server.
Verify that the Nginx web server is running and active.
Ensure the output shows active (running) to confirm Nginx is operational
Use Certbot to automatically request and install a TLS certificate from Let’s Encrypt. Certbot integrates with Nginx to configure HTTPS and redirect HTTP traffic securely.
Install Certbot and the Nginx plugin.
Generate and install the TLS certificate.
--nginx: Uses the Nginx plugin to automatically configure HTTPS.-d nextcloud.example.com: Replace with your actual domain name.When prompted:
Ensure that port 80 (HTTP) and 443 (HTTPS) are open in the firewall before running Certbot.
Once the setup is complete and the containers are running, access your instance by visiting:
From the setup wizard:
nextcloudnextclouddb (if using Docker) or 127.0.0.1 (if using local MariaDB)After completing the setup, you can extend Nextcloud with additional apps, organize and share files, and sync data across devices using the web interface or mobile and desktop clients. This gives you a centralized platform to manage your private cloud storage through an intuitive dashboard.
In this article, you deployed Nextcloud on Rocky Linux 9 using either a manual installation or a Docker-based setup. You secured the deployment with Nginx and HTTPS, configured the database and Redis, and ensured that user data persists on the host system for easier backups.
The containerized deployment offers isolation, efficient resource use, and flexibility, while the manual method provides granular control over the environment. For advanced features such as external storage and groupware tools, see the Nextcloud documentation.
0 Comments
Be the first to comment and share your perspective with the community.