How to Install Nextcloud on Ubuntu 22.04


To install and configure Nextcloud Server with Apache 2 web server in Ubuntu 22.04, you must first download and extract it with the wget command, which will complete the installation. Through this tutorial, we will show you how to install and configure Nextcloud on Linux ubuntu 22.04 with apache web server.

Here are steps to install and configure Nextcloud on ubuntu 22.04 linux with apache 2 web server:

Step 1 – Update System

Firstly, start your terminal window and type the following command to update system package:

sudo apt update

Step 2 – Install PHP and Apache Web Server

Next type the following command to install PHP and Apache web server on ubuntu 22.04:

sudo apt install -y php-cli php-fpm php-json php-intl php-imagick php-pdo php-mysql php-zip php-gd php-mbstring php-curl php-xml php-pear php-bcmath apache2 libapache2-mod-php

Once the installation of the packages is finished, Set PHP variables using the following command:

sudo vim /etc/php/*/apache2/php.ini

Then set PHP variables; is as follows:

date.timezone = Africa/Nairobi
memory_limit = 512M
upload_max_filesize = 500M
post_max_size = 500M
max_execution_time = 300

And restart apache web server using the following command:

sudo systemctl restart apache2

Step 3 – Install MySQL / MariaDB Database Server

Then execute the following command on command line to install MariaDB or MySQL database server:

sudo apt -y install mariadb-server

Secure MariaDB database server using the following command:

sudo mysql_secure_installation

Change authentication plugin to allow use of root password.

sudo mysql -u root

UPDATE mysql.user SET plugin = 'mysql_native_password' WHERE User = 'root';

Then execute the following command to create database:

mysql -u root -p
CREATE USER 'nextcloud'@'localhost' identified by 'StrongPassword';
GRANT ALL PRIVILEGES ON nextcloud.* TO 'nextcloud'@'localhost'; FLUSH PRIVILEGES;

Don’t forget to replace StrongPassword with your database user password.

Step 4 – Download and Install Nextcloud on Ubuntu 22.04

Execute the following commands on command line to download and install Nextcloud on linux ubuntu:

sudo apt install -y wget unzip

Once the file is downloaded, extract it by using the following command:


Move the resulting folder to /srv

sudo mv nextcloud/ /srv

By using the following command to change directory permissions to the www-datauser:

sudo chown -R www-data:www-data /srv/nextcloud/

Step 5 – Configure Nextcloud with Apache Ubuntu Webserver

Now execute the following command on command line to create a VirtualHost file for Nextcloud:

sudo vim /etc/apache2/conf-enabled/nextcloud.conf

After that, add the following content into the file:

<VirtualHost *:80>
     ServerAdmin [email protected]
     DocumentRoot /srv/nextcloud/
     ErrorLog /var/log/apache2/nextcloud-error.log
     CustomLog /var/log/apache2/nextcloud-access.log combined
    <Directory /srv/nextcloud/>
	Options +FollowSymlinks
	AllowOverride All
        Require all granted
 	SetEnv HOME /srv/nextcloud
 	SetEnv HTTP_HOME /srv/nextcloud
 	<IfModule mod_dav.c>
  	  Dav off

Step 6 – Enable ReWrite Mode and Restart Server

Use the following command to enable required Apache modules and restart the service:

sudo a2enmod rewrite dir mime env headers

sudo systemctl restart apache2

Step 7 – Complete Nextcloud Installation via GUI

That’s it! You’ve successfully installed NextCloud on Ubuntu 22.04. Access your NextCloud instance at https://your_server_ip/nextcloud.


Once the installation wizard loads, create a nextcloud superuser/admin user account. Enter the username and password. Besides, click on the Storage and Database link to access additional installation configuration options for your Nextcloud data directory and database.

Then fill in the database connection details as shown in the following screenshot and click Finish Setup.

Nextcloud Setup Wizard

When the installation is complete, we will see the following window. Click on the forward arrow that will appear at the right side of the blue window to proceed and follow the prompts.

Here is the video tutorial on how to install and configure Nextcloud on ubuntu 22.04 with apache 2:


This tutorial taught us how to install and configure Nextcloud on Linux ubuntu 22.04.

Recommended Linux Ubuntu Tutorials


Jaspreet Singh Ghuman

Jaspreet Singh Ghuman

Passionate Professional Blogger, Freelancer, WordPress Enthusiast, Digital Marketer, Web Developer, Server Operator, Networking Expert. Empowering online presence with diverse skills.

jassweb logo

Jassweb always keeps its services up-to-date with the latest trends in the market, providing its customers all over the world with high-end and easily extensible internet, intranet, and extranet products.


Jassweb, Rai Chak, Punjab, India. 143518
Item added to cart.
0 items - 0.00