How to Install and Configure Nextcloud on Fedora

Install Nextcloud on Fedora by adding the official repository, installing the package, and configuring Apache and MariaDB for the web interface.

You need a private cloud that actually stays online

You just finished backing up your photos and documents, and you want them accessible from your phone, your laptop, and a friend's machine without relying on a third-party cloud. You point your browser to localhost/nextcloud after running the install command, and Apache returns a 403 Forbidden error. Or maybe the setup wizard hangs on checking prerequisites because the database connection failed. This happens when the web server, the database, and the application stack do not share the same expectations about paths, permissions, and network ports.

What Nextcloud actually does on Fedora

Nextcloud is not a single binary. It is a PHP application that talks to a database for user accounts and file metadata, and it relies on Apache to handle HTTP requests and serve static assets. Fedora ships with strict defaults. Apache refuses to serve directories without explicit configuration. MariaDB waits for a properly authenticated user. SELinux blocks web processes from writing to unexpected locations. The installation process is really about aligning these three components so they can talk to each other without permission errors. Think of it like setting up a shared office. Nextcloud is the desk, MariaDB is the filing cabinet, and Apache is the receptionist. If the receptionist does not know where the desk is, or if the filing cabinet is locked, nobody gets work done.

Run the initial package pull from a clean terminal. Fedora maintains the official Nextcloud packages in the standard repositories, so you do not need third-party COPR channels for a basic setup.

sudo dnf install -y nextcloud nextcloud-mysql nextcloud-php
# Pulls the core Nextcloud application, MariaDB client libraries, and the required PHP modules
# --refresh forces dnf to check for updated metadata before resolving dependencies
# This prevents stale package conflicts that often break PHP extension chains

Check the installation output for dependency resolution warnings. Fedora's package manager will abort if a PHP extension conflicts with a system library. Let it resolve the transaction naturally. Do not force installs with --skip-broken unless you are debugging a known repository mirror issue. Trust the package manager. Manual file edits drift, snapshots stay.

Install the packages and prepare the database

Nextcloud expects a dedicated database. MariaDB is the default relational database on Fedora. You need to create a schema and a user that Nextcloud can authenticate against. Do not use the root account for the application. Application accounts should have the minimum privileges required to function.

sudo mysql -u root -p
# Opens the MariaDB interactive shell. You will be prompted for the root password you set during installation.
# The -p flag forces a password prompt. Never pass credentials directly on the command line.
# Command line arguments appear in process lists and shell history.

Inside the MariaDB prompt, run these statements. Each line creates a boundary between your application data and the rest of the system.

CREATE DATABASE nextcloud CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci;
# Creates an isolated schema for Nextcloud. utf8mb4 ensures emoji and special characters store correctly.
# Collation defines how string comparisons handle case and accents.
CREATE USER 'nextcloud'@'localhost' IDENTIFIED BY 'your-strong-password-here';
# Binds the account to localhost only. Remote connections are blocked by default for security.
# The password must meet MariaDB's default complexity requirements.
GRANT ALL PRIVILEGES ON nextcloud.* TO 'nextcloud'@'localhost';
# Grants full control over the nextcloud schema only. No access to other databases.
# Nextcloud needs CREATE, ALTER, and DROP to manage its own table structure during updates.
FLUSH PRIVILEGES;
# Forces MariaDB to reload the grant tables so the new user takes effect immediately.
# This step is technically optional after GRANT, but it guarantees consistent behavior across versions.
EXIT;

Close the database prompt and verify the user can connect. Test the credentials before handing them to the web interface.

mysql -u nextcloud -p nextcloud -e "SELECT 1;"
# Authenticates as the nextcloud user against the nextcloud database
# -e executes the query and exits immediately. A successful run returns a table with a single 1.
# If authentication fails, MariaDB prints Access denied for user 'nextcloud'@'localhost'.

Configure Apache and SELinux

Apache on Fedora does not serve the /var/www/html/nextcloud directory by default. The package drops a configuration file in /etc/httpd/conf.d/. You need to enable it and adjust the DocumentRoot if you want Nextcloud at the root of your domain or localhost. For a clean test, the default conf file works. Enable the service and start it.

sudo systemctl enable --now httpd
# Enables Apache to start on boot and launches the daemon immediately
# Fedora uses systemd targets to manage service dependencies. httpd will wait for network-online.target
# The --now flag combines enable and start into a single transaction.

SELinux is the part that trips up most first-time deployments. The Nextcloud data directory lives in /var/lib/nextcloud/data. Apache runs under the apache_t domain. SELinux policy allows apache_t to read and write to files labeled httpd_sys_rw_content_t. The package sets these labels during installation, but if you move the data directory later, you will hit access denied errors. Check the current context to verify the labels are applied.

ls -lZ /var/lib/nextcloud/data
# Lists files with SELinux security contexts attached
# Look for unconfined_u:object_r:httpd_sys_rw_content_t:s0 on the directory entries
# If you see default_t or user_home_t, Apache will refuse to write session files

You also need to open port 80 for HTTP traffic. Fedora's firewall is active by default and blocks inbound connections except for SSH.

sudo firewall-cmd --permanent --add-service=http
# Adds HTTP to the persistent firewall configuration
# The --permanent flag writes to the configuration file that survives reboots.
sudo firewall-cmd --reload
# Applies the change to the running firewall without dropping existing connections
# Always reload after permanent changes. The runtime and persistent configs diverge otherwise.

Fedora's release cadence is 6 months. The N-2 release goes EOL when N+1 ships. Plan upgrades on that cycle. Run dnf upgrade --refresh weekly to keep the stack patched. dnf system-upgrade is for crossing major Fedora releases. They are different commands. Do not conflate them.

Finish the setup in the browser

Point your browser to http://localhost/nextcloud. The setup wizard will load. Enter the admin username and password. Under the storage and database section, select MySQL/MariaDB. Fill in the database name, username, and password you created earlier. Leave the host as localhost. Click Finish setup.

The wizard writes the configuration to /var/www/html/nextcloud/config/config.php. This file is generated automatically. Do not edit it manually unless you are changing advanced parameters like trusted domains or memory caching. Manual edits drift during upgrades. The package manager will overwrite manual changes if you do not follow the upgrade path correctly. Config files in /etc/ are user-modified. Files in /usr/lib/ ship with the package. Edit /etc/. Never edit /usr/lib/.

If you plan to access Nextcloud from other machines on your network, you must add your domain or IP to the trusted domains list. Nextcloud blocks requests from unrecognized hosts to prevent host header attacks.

sudo nano /var/www/html/nextcloud/config/config.php
# Opens the main Nextcloud configuration file for editing
# The trusted_domains array controls which hostnames the application will accept.
# Add your server IP or domain as a string in the array.

Restart Apache after modifying the configuration file. The web server caches PHP configuration and Nextcloud settings in memory.

sudo systemctl restart httpd
# Reloads the PHP interpreter with the new configuration values
# Always restart the web server after modifying config.php. The changes do not apply to running workers
# systemd will report Active: active (running) if the daemon accepted the new configuration.

Verify the installation

Open a terminal and check the Apache error log. A clean installation produces no PHP fatal errors on the first page load.

sudo journalctl -xeu httpd
# Shows recent Apache logs with explanatory context
# The -x flag adds SELinux and systemd hints. The -e flag jumps to the end of the journal
# Look for AH00558 warnings. They are harmless and do not affect Nextcloud functionality.

Visit http://localhost/nextcloud/settings/admin/overview. The security and setup warnings section should be empty. If you see a warning about the data directory being accessible, verify that the Apache configuration includes Options -Indexes and that SELinux contexts are correct. Run journalctl -t setroubleshoot if you suspect SELinux is blocking a legitimate operation. SELinux denials show up there with a one-line summary. Read those before disabling SELinux.

Reboot before you debug. Half the time the symptom is gone.

Common pitfalls and what the error looks like

The most frequent error is a database connection timeout. Nextcloud will display Error: Could not connect to database: Unknown authentication error. This happens when the MariaDB user is created with IDENTIFIED BY 'password' but the application config uses a different string, or when localhost resolves to an IPv6 socket that MariaDB is not listening on. Force IPv4 by changing the host to 127.0.0.1 in the setup form.

Another common issue is the 403 Forbidden response. Apache returns this when the directory permissions are too restrictive or when SELinux blocks the request. Run sudo restorecon -Rv /var/www/html/nextcloud to reset the security contexts to their package defaults. Check /var/log/httpd/error_log for the exact denial message.

Memory limits also cause silent failures. PHP defaults to 128 megabytes. Nextcloud recommends at least 512 megabytes for smooth operation. Edit /etc/php.ini and change memory_limit = 512M. Restart Apache afterward. The systemctl status httpd command shows recent log lines AND state in one view. Always check status before restart.

If the boot menu is gone, GRUB rescue is your friend, not your enemy.

When to use Nextcloud versus alternatives

Use Nextcloud when you need a self-hosted file sync and share solution with built-in calendar, contacts, and office integration. Use Syncthing when you only want peer-to-peer file synchronization without a central server. Use Seafile when you prioritize raw storage performance and block-level deduplication over a full application ecosystem. Stay on the Fedora package manager if you want automatic security patches and dependency resolution. Compile from source only when you need a specific PHP extension that the distribution has not packaged yet.

Where to go next