Nextcloud is just like Google Drive or Dropbox. It allows you to store, manage, and share your data through servers. Nextcloud is purely open-source and self-hosted, i.e., users manage the data on their servers. Moreover, it synchronizes with your local machine and the data loss chance is minimal. Because of its open-source feature, it is loved by Linux users and also it has a large community to continuously develop and keep improving it.
Ubuntu is the leading distribution where users crave open-source utilities such as Nextcloud. So, today we will elaborate on the way(s) to set up Nextcloud on your Ubuntu 24.04, codenamed Noble Numbat.
Table of Contents:
- What Installation Methods Does Nextcloud Offer for Ubuntu 24.04?
- Method 1: Install and Configure Nextcloud Using LAMP
- Step 1: Install Apache, MySQL, and PHP
- Step 2: Integrate Some Modules/Extensions of MySQL and PHP
- Step 3: Configure MySQL and Apache
- Step 4: Create a Database, Database User for Data Management
- Step 5: Download the NextCloud File
- Step 6: Copy or Move the Extracted File Into /var/www/html
- Step 7: Create a New Configuration File For Nextcloud
- Step 8: Enable the Newly Configured Site
- Step 9: Test the Changes
- Step 10: Install and Setup Nextcloud
- Method 2: Install and Configure Nextcloud Using the Snap
- Bottom Line
What Installation Methods Does Nextcloud Offer for Ubuntu 24.04?
Nextcloud is hosted on the local host or any trusted domain. It allows configurable files on its own website that can be used with the web server, MySQL/MariaDB, and PHP. However, Snap offers the ready-made deployment of Nextcloud on any trusted domain or the local host. Thus, you have two ways to install the Nextcloud on your Ubuntu:
Method 1: Setting Up LAMP and Integrating the Nextcloud
- First, you need to set up LAMP Stack (Apache, MySQL, and PHP on Ubuntu 24.04).
- Then, get the Nexcloud’s file from the site and create an Apache Virtual Host.
- By doing so, you will be able to use Nextcloud on your Ubuntu 24 and a local host.
Method 2: Installing the Nextcloud Instance From the Snap Store
- Install the Nextcloud deployment from the snap command.
- Check the trusted domain(s), by default you will find localhost.
- Access the Nextcloud on that trusted domain, i.e., usually, it is localhost.
Let’s demonstrate these methods separately.
Method 1: Install and Configure Nextcloud Using LAMP
As discussed, Nextcloud can be hosted on Ubuntu by setting up LAMP. Follow the steps below to get the Nextcloud functional on your Ubuntu 24:
Step 1: Install Apache, MySQL, and PHP
First, update the packages list using the following command:
sudo apt update

Now, install Apache, MySQL, and PHP:
sudo apt install apache2 php mysql-server
Step 2: Integrate Some Modules/Extensions of MySQL and PHP
Additionally, you need some PHP modules and extensions that help in communicating with other linked services in the LAMP stack. Let’s install these:
sudo apt install php-zip php-mysql php-gd php-mbstring php-curl php-intl php-bcmath php-gmp php-imagick php-xml libapache2-mod-php
You might have already installed/acquired these, i.e., in any other installation:
Step 3: Configure MySQL and Apache
Apache and MySQL servers are backed up by system services. Before using them, you should start/enable these services, as follows:
sudo systemctl start apache2 sudo systemctl start mysql
Enable the services also to keep them actively running after each reboot:
sudo systemctl enable apache2 sudo systemctl enable mysql
Finally, check the status of these services to ensure their working before going forward:
sudo systemctl status apache2
Apache is running actively, let’s check the status of the “mysql” service:
sudo systemctl status mysql
The services are now configured. Let’s do the firewall relevant setup.
The “ufw” is the recommended utility to allow/deny the specific ports/connections through the firewall. Interestingly, Apache has a complete profile, you do not need to configure the firewall for each (required) component. There are three Apache-based profiles, i.e., Apache Secure, Apache Full, and Apache.
It is recommended to allow the “Apache Full” profile, i.e., using the command:
sudo ufw allow 'Apache Full'
Reload the firewall using ufw and also restart the Apache service:
sudo ufw reload sudo systemctl restart apache2
Step 4: Create a Database, Database User for Data Management
Now, you have to create an empty database, and a database user, and manage the privileges for that user on the local host. Here is the procedure:
Access the MySQL Server as a root user:
sudo mysql -u root
Create a Database, i.e., we named it “geniecloud”:
CREATE DATABASE geniecloud;
Create a user, i.e., “genie” for the localhost with any password:
CREATE USER 'genie'@'localhost' IDENTIFIED BY 'password';
Now, grant all privileges to the user “genie” on the database “geniecloud”:
GRANT ALL PRIVILEGES ON geniecloud.* TO genie@'localhost';
Lastly, “Flush the Privileges” to reload the grant tables to update the user access:
FLUSH PRIVILEGES;
Until now, we have completed the building blocks for the Nextcloud. Let’s proceed further:
Step 5: Download the NextCloud File
Go to the “Releases Download Page” of the Nextcloud and get the latest “zip” file available:
wget https://download.nextcloud.com/server/releases/nextcloud-29.0.0.zip
Extract the newly downloaded file:
unzip <zip-file-name>
Step 6: Copy or Move the Extracted File Into /var/www/html
Copy the extracted directory into the “/var/www/html” directory as this directory acts as the main web root for the Apache server (and NGINX as well):
sudo cp nextcloud /var/www/html/nextcloud
Now, make Apache user (www-data) the owner of the copied (nextcloud) directory:
sudo chown -R www-data:www-data /var/www/html/nextcloud
Step 7: Create a New Configuration File For Nextcloud
Before you create a new configuration file, first, disable the functionality of the default configuration file of the Apache Server:
sudo a2dissite 000-default.conf sudo systemctl restart apache2
Now, create the new configuration file inside the “sites-available” directory:
sudo nano /etc/apache2/sites-available/<filename>.conf
<VirtualHost *:80>
DocumentRoot "/var/www/html/nextcloud"
ServerName localhost
<Directory "/var/www/html/nextcloud/">
Options MultiViews FollowSymlinks
AllowOverride All
Order allow,deny
Allow from all
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
Here, two entities are recommended to configure always:
- DocumentRoot: Refers to the main directory of the VirtualHost to be hosted. Apache looks for this directory to trace and host the website.
- ServerName: The name of the server where the VirtualHost will be available through Apache.
However, the optional parameter includes the <Directory> tag that defines some extra grants for the root directory.
Step 8: Enable the Newly Configured Site
Now, enable the newly configured website using the following command:
sudo a2ensite nextcloud.conf
Here, it is recommended to map the ServerName to the IP address or the domain where you would access Nextcloud. We are using the ServerName with the Address 127.0.0.1 in the Apache configuration file:
sudo nano /etc/apache2/apache2.conf
Restart the Apache service and check its status to reload the changes and also confirm the status:
sudo systemctl status apache2
Step 9: Test the Changes
To verify whether the nextcloud is enabled or not, list the content of the “Sites-Enabled” directory:
ls /etc/apache2/sites-enabled/
The enabled site must appear in the output, as can be seen below:
Test the new configurations of the Apache:
sudo apache2ctl configtest
Step 10: Install and Setup Nextcloud
Once every step has been executed successfully, you can launch Nextcloud’s installer by visiting the localhost or the domain you configured in Apache’s configuration file (/etc/apache2/apache2.conf).
Upon the launch, you need to create an admin account, i.e., with a login and password:
On the same screen, you have to enter the “database user”, “database name”, and the associated password, i.e., that we created in Step 4:
Choose the recommended apps that you want to integrate with Nextcloud. You can skip this as well:
You can integrate the Nextcloud on your mobile devices as well:
Proceed with the instructions and you will soon land on the dashboard of your Nextcloud:
That’s how you can install Nextcloud on your Ubuntu 24.04.
Method 2: Install and Configure Nextcloud Using the Snap
Snap store offers a ready-to-launch deployment of the Nextcloud. This Nextcloud instance can be launched on any trusted domain configured by the user. Here is the step-by-step guide to install and use Nextcloud via Snap:
Step 1: Install and Enable Snap
Although the snap support is enabled by default on Ubuntu 24.04, if not, you can use the below commands for snap setup:
sudo apt install snapd sudo systemctl enable snapd sudo systemctl start snapd
Step 2: Install and Configure Nextcloud
The Nextcloud is available with the name “nextcloud” in the in the snap store:
sudo snap install nextcloud
Once it is installed, you need to configure it manually, i.e., admin account.
Create an administrative account with a username and a password, i.e., will be used for login:
sudo nextcloud.manual-install <user-name> password
Here, we have created a user named “genie.admin” with a password:
Step 3: Launch Nextcloud
Once the installation of the Nextcloud is completed, you will be able to load it on the local host. Just navigate to the browser and load your localhost, you will see the output below:
Use the username and the password you set at the time of installation, i.e., as we did in Step 2. Upon successful authentication, your dashboard will appear:
That’s how simple it is to install Nextcloud from Snap.
Tip: How to Set Trusted Domains for Nextcloud
Is it possible to add a custom trusted domain? Yes, it is possible. You can add an IP address or the domain name as a trusted domain
Syntax:
sudo nextcloud.occ config:system:set trusted_domain 1 --value=ip-address/domain-name
Here, we have used our Public IP address and mapped it on the Nextcloud trusted domain:
Now, get the trusted domain configured for Nextcloud using the command:
sudo nextcloud.occ config:system:get trusted_domain
That’s how you can get Nextcloud on your Ubuntu 24.04.
How to Disable Nextcloud on Ubuntu 24.04
The Nextcloud has two installation methods, as discussed earlier. Before removing, it depends on which installation method you followed for the installation. We have discussed both methods to disable the Nextcloud:
If Installed Manually
First, disable the configuration file associated with the Nexcloud using the “a2dissite” script:
sudo a2dissite nextcloud.conf
Additionally, you can remove the Nextcloud root directory, i.e., pasted inside the “/var/www/html/” directory:
sudo rm -r /var/www/html/nextcloud
If Installed Using Snap
Just remove the nextcloud snap using the command:
sudo snap remove nextcloud
Once done, you won’t be able to load the Nextcloud on your trusted domain.
Bottom Line
Nextcloud is a renowned self-hosted platform to organize your data and offers tens of applications to integrate with your Nextcloud instance, i.e., multimedia-related apps, monitoring-related apps, and more. The Nextcloud can be hosted with the help of LAMP, i.e., Apache, MySQL 0r MariaDB, and PHP on your Ubuntu 24.04. Then, you need to create a VirtualHost for Nextcloud and you can access the Nextcloud instance on the browser. On the other hand, you can also install and configure Nextcloud from the snap store which requires less time and resources as compared to the LAMP.
Among these, it is recommended to use Method 1 as it offers more control and customization capability for Nextcloud. However, you have learned both methods and choose what you want.

