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.
- NEW: Flexible scaling with VM-cloning, load balancing, new storage options and more
- Unlimited traffic and >99.99% availability
- 24/7 expert support and your own personal consultant
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, 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 requirements depend on usage intensity and the number of users
- Root access or a user account with sudo privileges to install software and make system changes
- A dedicated domain (optional but recommended), especially if you want to set up an encrypted HTTPS connection
For live deployments, a server with SSD storage and enough CPU is also recommended to ensure good performance even with multiple simultaneous accesses.
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 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:
sudo apt update
sudo apt upgrade -ybashThis 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 -ybashDuring installation, all the required components are set up automatically and the service is started. Check that Apache is running correctly with this command:
sudo systemctl status apache2bashIf 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 installation was successful and the web server is ready for use.
Step 4: Install PHP
Nextcloud is based on PHP, meaning you need to install the following components:
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 -ybashThese packages give Nextcloud the features it needs to process files, connect to the database and support encryption.
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 is often used for this purpose because it is stable, widely used, and fully compatible with MySQL. Start by installing the database server:
sudo apt install mariadb-server -ybashThen secure the installation:
sudo mysql_secure_installationbashFor 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:
sudo mysqlbashNow 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;sqlThis 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/bashDownload the current version of Nextcloud and then set the appropriate access permissions:
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 {} \;bashStep 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:
sudo nano /etc/apache2/sites-available/nextcloud.confbashIn 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>apacheconfServerName 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 configuration:
sudo a2ensite nextcloud.conf
sudo a2enmod rewrite headers env dir mime
sudo systemctl restart apache2bashAfter 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 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.
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. Once HTTPS is active, the connection is encrypted. In the browser, this is shown by the padlock icon in the address bar.


