# How to install Nextcloud on Ubuntu 24.04 step by step

Ubuntu 24.04 gives you a stable server base for installing Nextcloud and running your own cloud environment securely. It is an LTS release, which means it receives five years of security updates and is well suited to live server deployments.

### Key Takeaways

- You need a server with Ubuntu 24.04, at least 2 GB RAM, root or sudo access and ideally your own domain.
- First update the system, then install the Apache web server and the required PHP packages.
- Nextcloud stores key information such as user accounts and settings in a MariaDB database with a dedicated user.
- Download Nextcloud to /var/www/, set the access permissions and create an Apache VirtualHost.
- Complete the setup in the installation wizard in your browser; for live use, set up cron jobs and HTTPS.

## Step 1: Check the prerequisites for installation

Before you install Nextcloud on Ubuntu 24.04, you need to meet a few basic requirements. These help ensure that the installation works properly and that Nextcloud runs smoothly afterwards:

- A **server with Ubuntu 24.04** (e.g. [VPS](https://www.ionos.de/digitalguide/server/knowhow/was-ist-ein-virtual-private-server-vps/), [cloud server](https://www.ionos.com/en-ie/digitalguide/server/know-how/what-is-a-cloud-server/), or [dedicated server](https://www.ionos.com/en-ie/digitalguide/server/know-how/what-is-a-dedicated-server/)) where you have full admin rights
- At least **2 GB RAM**, which is enough for small setups with only a few users; generally speaking, RAM requirements depend on usage intensity and the number of users
- **Root access** or a user account with [sudo](https://www.ionos.com/en-ie/digitalguide/server/configuration/linux-sudo-command/) privileges to install software and make system changes
- A **dedicated domain** (optional but recommended), especially if you want to set up an encrypted [HTTPS](https://www.ionos.de/digitalguide/hosting/hosting-technik/was-ist-https/) connection

For **live deployments**, a server with [SSD](https://www.ionos.de/digitalguide/server/knowhow/was-ist-ssd/) storage and enough [CPU](https://www.ionos.de/digitalguide/server/knowhow/cpu/) is also recommended to ensure good performance even with multiple simultaneous accesses.

Note [Nextcloud](https://www.ionos.com/en-ie/digitalguide/server/tools/what-is-nextcloud/) is an [open source](https://www.ionos.de/digitalguide/server/knowhow/was-ist-open-source/) platform for running your own [cloud](https://www.ionos.com/en-ie/digitalguide/server/know-how/what-is-the-cloud/). It lets you store, sync, and share files with others while keeping the data on your own server. In addition to file management, Nextcloud offers **numerous extensions**, including calendar and contact management, video conferencing, task planning, and collaborative document editing.

## Step 2: Update Ubuntu

Before installing any software, update the Ubuntu server. Use the following commands for this:

```bash
sudo apt update
sudo apt upgrade -y
```

This updates the package list and installs any available security updates.

## Step 3: Install the web server (Apache)

Nextcloud needs a web server so you can access the interface in a [browser](https://www.ionos.de/digitalguide/websites/web-entwicklung/was-ist-ein-browser/). The web server handles incoming requests and displays the cloud interface. In this guide, we use [Apache](https://www.ionos.de/digitalguide/server/knowhow/was-ist-apache/) because it is a widely used and reliable option. Install Apache with the following command:

```bash
sudo apt install apache2 -y
```

During installation, all the required components are set up automatically and the service is started. Check that Apache is running correctly with this command:

```bash
sudo systemctl status apache2
```

If the status shows ‘active (running)’, it means the web server is active. Now open a browser and enter your server’s [IP address](https://www.ionos.de/digitalguide/server/knowhow/was-ist-eine-ip-adresse/) in the address bar. If the Apache default page appears, it means the installation was **successful** and the web server is ready for use.

## Step 4: Install PHP

Nextcloud is based on [PHP](https://www.ionos.com/en-ie/digitalguide/websites/web-development/what-is-php/), meaning you need to install the following components:

```bash
sudo apt install libapache2-mod-php \
php php-gd php-mysql php-curl php-mbstring php-intl php-imagick \
php-xml php-zip php-bcmath php-gmp php-apcu php-redis unzip bzip2 -y
```

These packages give Nextcloud the features it needs to process files, connect to the database and support encryption.

Note After installation, check the main PHP settings for your Nextcloud environment. Pay particular attention to the memory limit (memory_limit) and the upload limits (upload_max_filesize and post_max_size). Nextcloud recommends setting memory_limit to at least 512 MB. If you want to upload larger files through the web interface, increase the upload limits accordingly. Make sure post_max_size is at least as high as upload_max_filesize. After changing the PHP configuration, reload the web server or PHP service.

## Step 5: Set up the database (MariaDB)

Nextcloud stores key information such as user accounts, settings, and details about shared files and folders in a database. On Ubuntu 24.04, [MariaDB](https://www.ionos.com/en-ie/digitalguide/server/know-how/what-is-mariadb/) is often used for this purpose because it is stable, widely used, and fully **compatible with MySQL**. Start by installing the database server:

```bash
sudo apt install mariadb-server -y
```

Then secure the installation:

```bash
sudo mysql_secure_installation
```

Note For live Nextcloud deployments, you should also adjust the MariaDB or MySQL configuration to meet Nextcloud’s requirements. The most important setting is the transaction isolation level READ-COMMITTED, which can help prevent issues when many users access the system at the same time or several file operations run in parallel. If binary logging is enabled, you should also set binlog_format = ROW. These settings apply to the database server itself. After changing them, restart the database service.

The wizard helps you apply some basic security settings, such as removing anonymous users or disabling insecure default options. After that, log in to the database:

```bash
sudo mysql
```

Now create a dedicated database for Nextcloud with the utf8mb4 character set, set up a separate user, and assign a secure password:

```sql
CREATE DATABASE IF NOT EXISTS nextcloud CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci;
CREATE USER 'ncuser'@'localhost' IDENTIFIED BY 'securepassword';
GRANT ALL PRIVILEGES ON nextcloud.* TO 'ncuser'@'localhost';
FLUSH PRIVILEGES;
EXIT;
```

This provides a dedicated database that only Nextcloud can access.

## Step 6: Download Nextcloud

In this step, you’ll actually install Nextcloud on Ubuntu 24.04. To do this, switch to the web directory:

```bash
cd /var/www/
```

Download the current version of Nextcloud and then set the appropriate access permissions:

```bash
sudo wget https://download.nextcloud.com/server/releases/latest.tar.bz2
sudo tar -xjf latest.tar.bz2
sudo chown -R www-data:www-data /var/www/nextcloud
sudo find nextcloud/ -type d -exec chmod 750 {} \;
sudo find nextcloud/ -type f -exec chmod 640 {} \;
```

## Step 7: Configure Apache

Now create a dedicated configuration file so that Apache knows which domain your Nextcloud instance should be accessible under and where the files are located. Start by creating a new file:

```bash
sudo nano /etc/apache2/sites-available/nextcloud.conf
```

In this file, you define a VirtualHost. This tells Apache which domain points to which directory. Insert the following content:

```apacheconf
<VirtualHost *:80>
    ServerName your-domain.ie
    DocumentRoot /var/www/nextcloud

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

        <IfModule mod_dav.c>
            Dav off
        </IfModule>
    </Directory>
</VirtualHost>
```

ServerName specifies your domain. Replace your-domain.ie with yours. DocumentRoot defines where the Nextcloud files are located. The Directory block allows access to the directory and ensures that Nextcloud can use its own settings via .htaccess files.

Save the file and then activate the new configuration:

```bash
sudo a2ensite nextcloud.conf
sudo a2enmod rewrite headers env dir mime
sudo systemctl restart apache2
```

After the restart, the configuration is active and your Nextcloud instance can be accessed via the specified domain.

## Step 8: Complete the installation in the browser

With the web server, PHP, and database set up, go to your browser for the final step. Open your domain or, alternatively, your server’s IP address. The **Nextcloud installation wizard** will appear automatically.

Start by creating an admin account. This user will later have full permissions within your cloud environment, so make sure you enter a secure admin username and password.

Then enter the database details you created earlier. In our case, this would be:

- Database name: `nextcloud`
- Database user: `ncuser`
- Password: the database password you chose
- Host: `localhost` (this specifies that the database is located on the same server).

Nextcloud now creates the required tables and sets up the environment automatically. This may take **a few minutes**, depending on how fast your server is. Once the setup is complete, you’ll be taken straight to the dashboard, where you can start configuring your cloud. For live deployments, you should also set up [cron jobs](https://www.ionos.de/digitalguide/hosting/hosting-technik/cronjob/) so Nextcloud can run background tasks, like file checks, notifications and clean-up processes. The default AJAX option only runs when someone accesses a page, so it is mainly suitable for personal use or setups with only a few users.

Note For live use, your Nextcloud setup on Ubuntu should only be accessible over encrypted HTTPS. This protects login details and file transfers. You can set this up with a free SSL/TLS certificate, for example with a [Let’s Encrypt installation](https://www.ionos.com/en-ie/digitalguide/websites/website-creation/install-a-lets-encrypt-ssl-certificate/). Once HTTPS is active, the connection is encrypted. In the browser, this is shown by the padlock icon in the address bar.


This is a markdown version of: [https://www.ionos.com/en-ie/digitalguide/server/configuration/nextcloud-ubuntu-2404/](https://www.ionos.com/en-ie/digitalguide/server/configuration/nextcloud-ubuntu-2404/) for AI/LLM consumption.