How to deploy Nextcloud 25 on Ubuntu Server 22.04

Close up of an unrecognizable young businessman holding a laptop in a server room
Image: Myvisuals/Adobe Stock

Nextcloud is always pushing the envelope of what on-premises cloud servers can be and do. With their latest release, Nextcloud shifts some of the focus to digital well-being with the help of a complete redesign of the UI. There’s more personalization, more universal access, much-improved applications, a built-in photo uploader and editor, AI-powered facial and object recognition for uploaded photos, improved Talk, a more performant email client, better contact organization and more.

SEE: Hiring Kit: Cloud Engineer (TechRepublic Premium)

What’s most striking about Nextcloud 25 is the UI. The designers and developers have really gone out of their way to make the platform much more user-friendly and modern. As usual, there are also multiple routes for getting Nextcloud installed. However, I want to go the traditional route and install it on Ubuntu Server 22.04.

What you’ll need to install Nextcloud 25

To install Nextcloud 25, you’ll need a running instance of Ubuntu Server 22.04 and a user with sudo privileges. That’s it.

How to install the necessary requirements

The first thing you must do is install the web and database servers with the command:

sudo apt-get install apache2 mysql-server -y

Start and enable them both with:

sudo systemctl enable --now apache2
sudo systemctl enable --now mysql

Next, install the php dependencies with:

sudo apt-get install php zip libapache2-mod-php php-gd php-json php-mysql php-curl php-mbstring php-intl php-imagick php-xml php-zip php-mysql php-bcmath php-gmp zip -y

How to set the MySQL root password

For some reason, the mysql_secure_installation failed me. Instead, I had to set the MySQL admin password manually. First log into the MySQL console with:

sudo mysql

Once there, set the admin password with:

ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password by 'PASSWORD';

Where PASSWORD is a strong/unique password.

Exit from the console with exit.

How to create the database and user

Next, we can create the database. To do that, log back into the MySQL console with:

mysql -u root -p

Create the database with:

CREATE DATABASE nextcloud;

Create the new user with:

CREATE USER 'nextcloud'@'localhost' IDENTIFIED BY 'PASSWORD';

Where PASSWORD is a unique and strong password.

Give the new user the necessary permissions with the command:

GRANT ALL PRIVILEGES ON nextcloud.* TO 'nextcloud'@'localhost';

Flush the privileges and exit the console with the commands:

FLUSH PRIVILEGES;
exit

How to download and unpack the Nextcloud file

Download the Nextcloud source with the command:

wget https://download.nextcloud.com/server/releases/latest.zip

Install unzip with:

sudo apt-get install unzip -y

Unpack the downloaded file with:

unzip latest.zip

Move the new directory into the Apache document root with:

sudo mv nextcloud /var/www/html/

Grant the proper permissions with:

sudo chown -R www-data:www-data /var/www/html/nextcloud

How to configure Apache for Nextcloud

We now have to create an Apache configuration file with the command:

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

In that file, paste the following:

Alias /nextcloud "/var/www/html/nextcloud/"

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

<IfModule mod_dav.c>

Dav off
</IfModule>
</Directory>

Enable the new site with:

sudo a2ensite nextcloud

Enable the necessary Apache modules:

sudo a2enmod rewrite headers env dir mime

Increase the PHP memory limit with the command:

sudo sed -i '/^memory_limit =/s/=.*/= 512M/' /etc/php/7.4/apache2/php.ini

Restart Apache:

sudo systemctl restart apache2

How to complete the installation

Finally, open a web browser and point it to http://SERVER/nextcloud, where SERVER is the IP address or domain of the hosting server. You should be greeted by the web-based installer, where you must create an admin user and fill in the details for the database (Figure A).

Figure A

The Nextcloud 25 web-based installer.

Click Install and allow the magic to happen under the hood. When it finishes, you’ll find yourself on the new Nextcloud Hub, logged in as the admin user (Figure B).

Figure B

The new Nextcloud interface is a subtle, but important upgrade from the previous iterations.

And there you have it, you’ve just installed the latest and greatest release from the fine developers of Nextcloud. Enjoy that refreshed interface and all the new features.

Subscribe to TechRepublic’s How To Make Tech Work on YouTube for all the latest tech advice for business pros from Jack Wallen.

Leave a Reply

Your email address will not be published. Required fields are marked *