Skip to content
Follow
CMS

How to install Nextcloud with Apache on Ubuntu 24.04

Richard
Written by
Richard
Jun 4, 2024 Updated Jul 11, 2026 7 min read
Nextcloud featured image
Nextcloud featured image

You install Nextcloud with Apache on Ubuntu 24.04 to set up your own private cloud for file syncing, sharing, and collaborative work.

Nextcloud is a free software suite that gives you a personal cloud for data syncing and sharing. You will configure Apache, a popular web server, to efficiently serve your Nextcloud setup.

This process specifically targets Ubuntu 24.04 LTS, also known as Noble Numbat, ensuring you get a modern and stable setup. Following these steps will grant you the benefits of Apache’s reliability and Ubuntu’s ease of use.

⚡ Quick Answer

Install Apache and MariaDB using `sudo apt install apache2 mariadb-server`. Then create a Nextcloud database and user within MariaDB. Finally, install PHP with `sudo apt install php libapache2-mod-php php-`.

Install Apache HTTP server on Ubuntu

Install the Apache HTTP server on Ubuntu 24.04 to host your Nextcloud. This guide shows you how to get Apache running using simple terminal commands so you can start building your Nextcloud Apache Ubuntu 24.04 setup.

To do that, open the Ubuntu terminal and run the commands below to install the Apache web server.

🐧Bash / Shell
sudo apt update
sudo apt install apache2

Once Apache is installed, the commands below can start, stop, and enable the Apache web server to start automatically when your server boots up.

🐧Bash / Shell
sudo systemctl stop apache2
sudo systemctl start apache2
sudo systemctl enable apache2

You can test that the Apache web server is running by opening your web browser and browsing to the server’s localhost or IP address.

http://localhost

Default Apache2 web server welcome page after successful Ubuntu installation
Default Apache2 web server welcome page after successful Ubuntu installation

When you see the Apache2 Default Page, it means the Apache HTTP server is successfully installed.

Additional help on installing Apache on Ubuntu is in the link below.

How to install Apache on Ubuntu

Install MariaDB database server on Ubuntu Linux

Your Nextcloud needs a database to store its information, and MariaDB is a great choice for Ubuntu Linux. This guide explains how to install the MariaDB database server using simple terminal commands, getting it ready for your Nextcloud Apache Ubuntu 24.04 setup.

To install and use the MariaDB database server, use the instructions below.

Open the Ubuntu terminal and run the commands below to install the MariaDB database server.

🐧Bash / Shell
sudo apt update
sudo apt install mariadb-server

Once the MariaDB database server is installed, use the commands below to stop, start, and enable the MariaDB server to start automatically when the server boots.

🐧Bash / Shell
sudo systemctl stop mariadb
sudo systemctl start mariadb
sudo systemctl enable mariadb

Run the following commands to validate and test if the MariaDB database server is installed successfully.

🐧Bash / Shell
sudo mariadb

Once you run the commands above, it will log you onto the MariaDB console and display a message similar to the one below.

💻Code
Welcome to the MariaDB monitor.  Commands end with ; or g.
Your MariaDB connection id is 32
Server version: 10.11.2-MariaDB-1 Ubuntu 23.04

Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.

Type 'help;' or 'h' for help. Type 'c' to clear the current input statement.

MariaDB [(none)]> 

The message tells you that the server is installed successfully.

Additional help on installing MariaDB.

Create a Nextcloud database

After installing MariaDB, you need to create a dedicated database for Nextcloud to securely store all its data. This guide shows you how to set up a database and a user account specifically for your Nextcloud Apache Ubuntu 24.04 installation.

As part of the setup, we will create a database named ‘nextclouddb‘ and a corresponding user account called ‘nextclouddbuser.’

Finally, we’ll grant the nextclouddbuser full access to the nextclouddb database.

All the database steps above can be done using the commands below:

But first, log on to the MariaDB database server:

🐧Bash / Shell
sudo mariadb

Then run the commands below to complete the steps:

💻Code
CREATE DATABASE nextclouddb CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci;
CREATE USER nextclouddbuser@localhost IDENTIFIED BY 'type_your_password_here';
GRANT ALL ON nextclouddb.* TO nextclouddbuser@localhost WITH GRANT OPTION;
FLUSH PRIVILEGES;
exit

Ensure to replace ‘type_your_password_here ‘with your password.

Install PHP on Ubuntu Linux

Nextcloud is built using PHP, which means you must install PHP and all its required extensions on your Ubuntu Linux system. This guide provides the command to install PHP and the necessary modules for your Nextcloud Apache Ubuntu 24.04 setup to work correctly.

Then, install PHP using the command below.

🐧Bash / Shell
sudo apt install php libapache2-mod-php php-intl php-mysql php-curl php-cli php-zip php-xml php-gd php-gmp php-common php-mbstring php-xmlrpc php-json php-sqlite3 php-ldap php-imap php-pgsql php-ssh2 php-soap php-zip

Additional help on installing PHP

How to install PHP on Ubuntu Linux

Download Nextcloud files

Download the latest Nextcloud software for your Ubuntu Linux installation directly from the official Nextcloud download page. This guide walks you through downloading the files, unpacking them, and moving them to the correct location for your Nextcloud Apache Ubuntu 24.04 setup.

⚠️Warning
Always check the download page for the latest release. Replace the download link below with the current so you have the latest version.
⚠️Warning
First, navigate to the /tmp/ directory and download Nextcloud files. After unzipping the file, move the content into the Nextcloud folder in the Apache root directory.

The final step is to change the permissions. This will allow the Apache web server to safely interact with the files, ensuring a secure environment for your Nextcloud installation.

💻Code
wget https://download.nextcloud.com/server/releases/latest.zip -P /tmp
sudo unzip /tmp/latest.zip -d /var/www
sudo chown -R www-data:www-data /var/www/nextcloud/

Once all the steps are done, configure the Apache webserver to serve the Nextcloud content.

Run the commands below to create an Apache virtual host file for Nextcloud.

🐧Bash / Shell
sudo nano /etc/apache2/sites-available/nextcloud.conf

Then, copy and paste the content block below into the Apache server block.

💻Code
Alias /nextcloud "/var/www/nextcloud/"

<Directory /var/www/nextcloud/>
Options +FollowSymlinks
AllowOverride All

<IfModule mod_dav.c>
Dav off
</IfModule>

SetEnv HOME /var/www/nextcloud
SetEnv HTTP_HOME /var/www/nextcloud

</Directory>

Save the file.

You enable the virtual host and restart the Apache server by running specific commands. Enabling the virtual host makes Apache aware of your Nextcloud site, and restarting Apache applies these new settings so that your Nextcloud installation becomes accessible.

🐧Bash / Shell
sudo a2ensite nextcloud.conf
sudo a2enmod env rewrite dir mime headers setenvif ssl
sudo systemctl restart apache2

Setup Let’s Encrypt SSL/TLS for Nextcloud

Secure your Nextcloud installation with HTTPS by setting up a free SSL/TLS certificate using Let’s Encrypt with Apache on Ubuntu. This guide helps ensure your Nextcloud connection is encrypted and safe for your Nextcloud Apache Ubuntu 24.04 setup.

Please read the post below for additional resources on installing and creating Let’s Encrypt SSL certificates for Apache.

How to set up Let’s Encrypt SSL certificate for Apache on Ubuntu Linux

Once you have restarted the Apache web server, open your browser and browse to the server hostname or IP address defined in the Apache server block.

💻Code
http://localhost/nextcloud

A Nextcloud installation wizard page should appear. Create an administrator account and password, enter the database name, database account name, and password created above, and click Install.

Nextcloud set up wizard
Nextcloud set up wizard

Your Nextcloud site should be ready to use.

Nextcloud set up wizard complete
Nextcloud set up wizard complete

Set up a reverse proxy for Nextcloud

Set up a reverse proxy with Apache for your Nextcloud installation if you want to use a custom domain name. This section guides you on how to configure Apache to work as a reverse proxy, letting you access your Nextcloud Apache Ubuntu 24.04 using your own domain.

The links below should help you set that up.

That should do it!

Conclusion:

  • In this comprehensive guide, you learned how to install Nextcloud with Apache support on Ubuntu 24.04, setting up a reliable platform for hosting cloud storage and collaboration services.
  • By leveraging the stability and security of the Apache web server and the robustness of Ubuntu as the operating system, you’ve ensured a reliable cloud hosting solution.
  • The step-by-step instructions covered the installation of the Apache HTTP server, MariaDB database server, PHP, and Nextcloud files, the setup of Let’s Encrypt SSL/TLS, and the option to configure a reverse proxy for Nextcloud using Nginx or Apache.
  • This guide provides a solid foundation for creating your Nextcloud site and offers additional resources for further customization and optimization of your setup.

Which Ubuntu for Nextcloud?

As far as I know, Nextcoud's supported PHP versions are based on the Ubuntu versions. Currently, the dist upgrade from Ubuntu 22.04 LTS to Ubuntu 24.04 LTS for Nextcloud 28, Nextcloud 29 and the new release Nextcloud 30 should work fine with the default sources. The Nextcloud releases support PHP 8.1 and PHP 8.3.

Was this guide helpful?

Was this helpful?
Richard

About the Author

Richard

Tech Writer, IT Professional

Richard, a writer for Geek Rewind, is a tech enthusiast who loves breaking down complex IT topics into simple, easy-to-understand ideas. With years of hands-on experience in system administration and enterprise IT operations, he’s developed a knack for offering practical tips and solutions. Richard aims to make technology more accessible and actionable. He's deeply committed to the Geek Rewind community, always ready to answer questions and engage in discussions.

📚 Related Tutorials

How to Install PHP on Ubuntu Linux
Ubuntu Linux How to Install PHP on Ubuntu Linux
How to Install Apache on Ubuntu Linux
Ubuntu Linux How to Install Apache on Ubuntu Linux
Install MySQL and MariaDB on Ubuntu: A Step-by-Step Guide
Ubuntu Linux Install MySQL and MariaDB on Ubuntu: A Step-by-Step Guide
How to Install KDE Desktop on Ubuntu 24.04
Ubuntu Linux How to Install KDE Desktop on Ubuntu 24.04

No comments yet — be the first to share your thoughts!

Leave a Comment

Your email address will not be published. Required fields are marked *