Metadata:
How to install Nextcloud productivity suite on Ubuntu 24.04.
- Initially published on 12-23-2024.
- Parent note: Raspberry Pi Network Interface
How to install Nextcloud on Ubuntu Server

A live instance of Nextcloud using the Notes app.
Nextcloud is a suite of productivity software as a web-app. Think of it as an open source alternative to Microsoft's office 365 offering. It can be deployed as a server for personal use and fine-tuned through its administrative interfaces and app addons.
This page will cover the installation process with respect to hardware that is running Ubuntu Server. Specifically, Ubuntu Server 24.04 is being used. This will act as a tutorial that is generic enough to be applied to earlier and future versions of the operating system.
The conclusion of the processes covered on this page will leave a user in a state where they can access their Nextcloud instance within a local area network. This will act as a transitory piece for a future writing discussing how to take the deployed instance from one that is accessed locally to one that can be accessed externally. That being said, much of what is covered here is included through Nextcloud's own set of tutorials. This page will elaborate more on some concepts and shy away from others, providing a good juxtaposition to the originating set of tutorials in which one can gain more insight to the process overall.
It is assumed that someone following along with this tutorial will have Ubuntu Server installed on their hardware. It is assumed they have a means to access a program shell on their system; They will need to be familiar with the concept of using a terminal if they have direct access or they will need to be familiar with using secure shell (ssh).
Downloading Nextcloud
Nextcloud can be downloaded from the following URL: https://nextcloud.com/install. Specifically, a server will be deployed necessitating a download of an archive from the "Download server" section.
There are a set of options within the "Download server" subsection of the webpage. "One click signup" allows one to deploy an instance through a cloud provider. "Enterprise solutions" offers an enterprise-ready version of the software. "All-in-one" affords a set of images to be used within virtualized environments. This tutorial will be concerned with running on bare-metal, which allows one to gain more insight into the deployment process. In theory, this insight can help one make their own containerized image that can be customized to their own desire. Thus, an archive will be downloaded from the "Community projects" section of this subsection.
Users who are visiting this website using a Windows operating system will be given the option to download a zip file. One approach to downloading Nextcloud would be to download it in the Windows environment, extracting the archive, and then moving the extracted files to the server via physical media or accessing the server using the sftp protocol. Alternatively, the web-app can instead be downloaded within the server environment itself using the terminal or ssh. In this context, a tar.bz2 file will be downloaded.
Accessing the Ubuntu environment, download Nextcloud with the following set of commands:
The first statement runs wget which simply gets the archive from Nextcloud's server. The second statement extracts the archive using tar. The third statement copies the extracted archive to /var/www. Alternatively, mv can be used instead of cp to simply move the files instead of duplicating them. Finally, the owner of the extracted folder is changed to www-data so that the web server can serve up the folder and its contents.
Take note of any error message that may be returned upon running the last statement of the above sequence. It will likely be indicative of the fact there may not be any user with the name www-data. This is likely because a set of program dependencies aren't in place.
Preparing installation
Installing dependencies
A LAMP server will be used to run Nextcloud. LAMP is an acronym that stands for Linux, Apache, MySql, and PHP. Knowing this, these services should be installed. It can only be guaranteed that the first letter of this acronym has been satisfied at this point. Thus, it needs to be ensured that Apache, MySql, and PHP are also installed.
Begin by running sudo apt update && sudo apt upgrade to ensure the advanced package tool is up to date in terms of itself, its catalog, and any other packages that already exist on the server.
Next, running the following command will install Apache, MySql, and PHP along with a suit of php modules that are necessary to run a Nextcloud server:
The above modules are listed as requirements by Nextcloud within their documentation here. Confirmation that they are installed can be confirmed by running the composite command php -m | grep -i <module_name> where php -m produces a list of installed modules and grep does a regular expression search on the return of php -m via the pipe operator. Be sure to omit any "php-" prefix from the regular expression. I.e., instead of running php -m | grep -i php-xml , instead use php -m | grep -i xml.
Alternatively, the following bash script can be used instead of piping to the grep command an amount of times equal to the amount of requirements. It takes a look at the installed set of Apache mods and parses through an array of requirements checking to see if each requirement is in the mod list. If a mod is missing, stdout informs the user.
The script can be downloaded here. Run it by using bash within the terminal. I.e., bash apache-mod-parser.sh.
A set of optional requirements will need to be installed as well. These optional requirements are dependent on how one intends to use Nextcloud and are often tied into specific apps that an administrator will want to deploy in the environment. For example, the ftp module will be needed for FTP storage, necessitating the installation of php-ftp using the advanced package manager (apt). Look through the requirements page as a guide and note that these modules can always be installed after Nextcloud is installed.
To leverage the above script for this set of optional requirements, simply alter req_array with the module names while minding the php- prefix that apt expects.
Preparing the database
A database environment needs to be setup to allow Nextcloud to enforce data integrity. This will require establishing a logical space with its name and a user that can use said space. This is done by first running MySql: sudo mysql;
Within the MySql console, first create the user. In the following sql statement, the terms "username" and "password" are arbitrary and should be changed to something more suitable. Do be sure to maintain the apostrophes that flank these terms as they are necessary for the sql syntax.
Executing the above command should give a response indicating the query was successful. If no response is given, it's likely that the semicolon was forgotten. The semi-colon is an important piece of syntax in this context.
After the user is created, the logical space for the database then needs to be created:
Here, the term "nextcloud" is as arbitrary as "username" and "password", but is descriptive enough to maintain. Be sure to remember all three of these values as they will be needed while doing the proper installation of Nextcloud.
Privileged access now needs to be granted to the user to use said database:
Now exit the mysql console by running quit
Configuring Apache
Apache is the subsystem which serves up the web pages of Nextcloud. It acts as an interface between http requests and handling any static html or dynamic html that is put together by a scripting language, (such as PHP). This subsystem relies on a set of configuration files to help determine what occurs upon a specific directory access. In the case of this Nextcloud deployment, an access to the /nextcloud subdirectory will grant access the web-app.
To accomplish this, a configuration file must be placed in the relevant folder. This can be done with the following command:
From this file, nano will be invoked to allow a text edit of this file to allow proper configuration. Run sudo nano /etc/apache2/sites-available/nextcloud.conf and input the following configuration:
Within the nano editor, use ctrl-o to save the file then ctrl-x to exit. Once this is done, the configuration needs to be enabled to ensure that apache knows how to handle the subdirectory. Run sudo a2ensite nextcloud.conf then restart the Apache service by running sudo systemctl reload apache2. The configuration's syntax can be confirmed by running sudo systemctl configtest.
A set of Apache mods also need to be enabled in order for Nextcloud to work properly. Run the following set of commands in the terminal:
Finally, set the user permissions if an error was received when doing so earlier in the tutorial:
Enabling SSL
When sending information to and from servers on the internet, data travels through the wire and is queued through various server and router hops as it makes its way to the destination. Any of these stops provides an opportunity for any curious adversary to inspect the the data contains. Thus, it has become standard to encrypt this information by using the HTTPS protocol.
Since the immediate goal here is to have a Nextcloud instance within a local area network, this is not as important. Though it's still worth encrypting web-app communication to mitigate any local attacks via tools like Wireshark. A self-signed certificate will be used here for ease. Though it is encouraged that the reader takes a look at Let's Encrypt's certbot to use an approach that is more robust.
To create a self-signed certificate the following set of commands should be run within the shell:
Installing Nextcloud
The system is now in a state where Nextcloud can be installed. This is done by accessing the installation script through a web browser. The easiest approach is to use a device outside of the Ubuntu Server environment using a web browser with a graphical user interface (gui).
Unless a desktop manager was installed on the Ubuntu Server, using an external web browser implies using some external operating system environment. This requires knowing the local address of the server. To discover the address, run ip address within Ubuntu and note the ipv4 address of either the eth0 interface or the wlan0 interface.
Within the web browser, navigate to https://<ipv4-address>/nextcloud to begin the installation process. Here the web browser may issue a warning that the https certificate is not valid. This is because it is self-signed. Take the route of actions to bypass this and continue to the website. The initial installation interface will greet the visitor:
The form that's presented first asks a user to create an admin account. What should be supplied for Login and Password is what will be used to initially access and administrate the Nextcloud instance after it is installed. The values given for these should be exclusive from what was given in the MySQL console during database creation.
The data folder is where the web-app will end up placing user files. For security reasons, it is recommended to select a location outside of /var/www. If the default is chosen, this can be changed later following the instructions here.
Pertaining to the fields for "Database account", "Database password", and "Database name", use the values that were chosen during the creation of the MySQL database. Using the unchanged code given in the section - username, password, and nextcloud would be the values given within this example.
Leave the Database host field blank with the default value, as the database exists on the same server as the web-app itself.
Once the values are given in the form, press install. AJAX in the page will inform that the the web-app is being installed to the server. Once it is complete, a redirect will occur.
Personal experience has presented a redirect to a page using the nextcloud.com top-level-domain. This seems to be an error in the installation script which assumes some third-party provider is being used. A page like this will be presented within the browser:

The DNS_PROBE_POSSIBLE error message presented upon conclusion of installation.
Fret not. Once this is presented, simply enter https://<ipv4-address>/nextcloud into the web browser's address bar. A login page will be presented where the admin account credentials can be given to log into the web-app! (Be sure that https is being used here, instead of http).

The initial Nextcloud login interface.
Thus concludes the installation of Nextcloud Server on Ubuntu Server. Logging in will provide a video tutorial and exploring the various administrative interfaces will shore up any intuition of what can be accomplished using Nextcloud.
