Ubuntu 24.04 gives you a stable server base for in­stalling Nextcloud and running your own cloud en­vir­on­ment securely. It is an LTS release, which means it receives five years of security updates and is well suited to live server de­ploy­ments.

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 in­form­a­tion such as user accounts and settings in a MariaDB database with a dedicated user.
  • Download Nextcloud to /var/www/, set the access per­mis­sions and create an Apache Vir­tu­al­Host.
  • Complete the setup in the in­stall­a­tion wizard in your browser; for live use, set up cron jobs and HTTPS.
VPS Hosting
VPS at an un­beat­able price – and better than ever
  • NEW: Flexible scaling with VM-cloning, load balancing, new storage options and more
  • Unlimited traffic and >99.99% avail­ab­il­ity
  • 24/7 expert support and your own personal con­sult­ant

Step 1: Check the pre­requis­ites for in­stall­a­tion

Before you install Nextcloud on Ubuntu 24.04, you need to meet a few basic re­quire­ments. These help ensure that the in­stall­a­tion works properly and that Nextcloud runs smoothly af­ter­wards:

  • A server with Ubuntu 24.04 (e.g. VPS, cloud server, or 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 re­quire­ments depend on usage intensity and the number of users
  • Root access or a user account with sudo priv­ileges to install software and make system changes
  • A dedicated domain (optional but re­com­men­ded), es­pe­cially if you want to set up an encrypted HTTPS con­nec­tion

For live de­ploy­ments, a server with SSD storage and enough CPU is also re­com­men­ded to ensure good per­form­ance even with multiple sim­ul­tan­eous accesses.

Note

Nextcloud is an open source platform for running your own cloud. It lets you store, sync, and share files with others while keeping the data on your own server. In addition to file man­age­ment, Nextcloud offers numerous ex­ten­sions, including calendar and contact man­age­ment, video con­fer­en­cing, task planning, and col­lab­or­at­ive document editing.

Step 2: Update Ubuntu

Before in­stalling any software, update the Ubuntu server. Use the following commands for this:

sudo apt update
sudo apt upgrade -y
bash

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. The web server handles incoming requests and displays the cloud interface. In this guide, we use Apache because it is a widely used and reliable option. Install Apache with the following command:

sudo apt install apache2 -y
bash

During in­stall­a­tion, all the required com­pon­ents are set up auto­mat­ic­ally and the service is started. Check that Apache is running correctly with this command:

sudo systemctl status apache2
bash

If the status shows ‘active (running)’, it means the web server is active. Now open a browser and enter your server’s IP address in the address bar. If the Apache default page appears, it means the in­stall­a­tion was suc­cess­ful and the web server is ready for use.

Step 4: Install PHP

Nextcloud is based on PHP, meaning you need to install the following com­pon­ents:

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
bash

These packages give Nextcloud the features it needs to process files, connect to the database and support en­cryp­tion.

Note

After in­stall­a­tion, check the main PHP settings for your Nextcloud en­vir­on­ment. Pay par­tic­u­lar attention to the memory limit (memory_limit) and the upload limits (upload_max_filesize and post_max_size). Nextcloud re­com­mends setting memory_limit to at least 512 MB. If you want to upload larger files through the web interface, increase the upload limits ac­cord­ingly. Make sure post_max_size is at least as high as upload_max_filesize. After changing the PHP con­fig­ur­a­tion, reload the web server or PHP service.

Step 5: Set up the database (MariaDB)

Nextcloud stores key in­form­a­tion such as user accounts, settings, and details about shared files and folders in a database. On Ubuntu 24.04, MariaDB is often used for this purpose because it is stable, widely used, and fully com­pat­ible with MySQL. Start by in­stalling the database server:

sudo apt install mariadb-server -y
bash

Then secure the in­stall­a­tion:

sudo mysql_secure_installation
bash
Note

For live Nextcloud de­ploy­ments, you should also adjust the MariaDB or MySQL con­fig­ur­a­tion to meet Nextcloud’s re­quire­ments. The most important setting is the trans­ac­tion isolation level READ-COMMITTED, which can help prevent issues when many users access the system at the same time or several file op­er­a­tions 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:

sudo mysql
bash

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

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;
sql

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:

cd /var/www/
bash

Download the current version of Nextcloud and then set the ap­pro­pri­ate access per­mis­sions:

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 {} \;
bash

Step 7: Configure Apache

Now create a dedicated con­fig­ur­a­tion file so that Apache knows which domain your Nextcloud instance should be ac­cess­ible under and where the files are located. Start by creating a new file:

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

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

<VirtualHost *:80>
    ServerName your-domain.co.uk
    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>
apacheconf

ServerName specifies your domain. Replace your-domain.co.uk 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 con­fig­ur­a­tion:

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

After the restart, the con­fig­ur­a­tion is active and your Nextcloud instance can be accessed via the specified domain.

Step 8: Complete the in­stall­a­tion in the browser

With the web server, PHP, and database set up, go to your browser for the final step. Open your domain or, al­tern­at­ively, your server’s IP address. The Nextcloud in­stall­a­tion wizard will appear auto­mat­ic­ally.

Start by creating an admin account. This user will later have full per­mis­sions within your cloud en­vir­on­ment, 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 en­vir­on­ment auto­mat­ic­ally. 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 con­fig­ur­ing your cloud. For live de­ploy­ments, you should also set up cron jobs so Nextcloud can run back­ground tasks, like file checks, no­ti­fic­a­tions 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 ac­cess­ible over encrypted HTTPS. This protects login details and file transfers. You can set this up with a free SSL/TLS cer­ti­fic­ate, for example with a Let’s Encrypt in­stall­a­tion. Once HTTPS is active, the con­nec­tion is encrypted. In the browser, this is shown by the padlock icon in the address bar.

Reviewer

Go to Main Menu