Overview
Nextcloud is a file hosting system which allows us to store our personal content like documents, pictures, videos etc and share with others, Instead of relying on external service providers for our personal and business documents, Nextcloud gives us the freedom to store them on our own servers or in trusted data centers. its a self managed centralized document and file management system. It is Open-Source hence enabling us to use and adapt the application as we need. We have full control over the application. So we can provide our own security measure to secure our contents.
In this tutorial, we are going to Install NextCloud On Ubuntu 22.04 LTS, This will be a detail step by step high performance Setup.
1. Install PHP and MySQL packages
2. Configure MySQL Server
3. Run the Nextcloud Setup on the Browser.
1. Install Packages
1. Update and Upgrade the Ubuntu Packages
# apt update && apt upgrade
2. install Apache and MySQL Server
# apt install apache2 mariadb-server
3. Install PHP and other Dependencies and Restart Apache
# apt install libapache2-mod-php php-bz2 php-gd php-mysql php-curl php-mbstring php-imagick php-zip php-ctype php-curl php-dom php-json php-posix php-bcmath php-xml php-intl php-gmp zip unzip wget
4. Enable required Apache modules and restart Apache:
# a2enmod rewrite dir mime env headers
# systemctl restart apache2
2. Configure MySQL Server
1. Login to MySQL Prompt, Just type
# mysql
2. Create MySQL Database and User for Nextcloud and Provide Permissions.
CREATE USER 'nextcloud'@'localhost' IDENTIFIED BY 'passw@rd';
CREATE DATABASE IF NOT EXISTS nextcloud CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci;
GRANT ALL PRIVILEGES ON nextcloud.* TO 'nextcloud'@'localhost';
FLUSH PRIVILEGES;
quit;
3. Download and Install Nextcloud
Now download the latest Nextcloud archive file, Go to the Nextcloud Download Page. Or you can download from this direct link: https://download.nextcloud.com/server/releases/latest.zip
1. Download and unzip at the web root (/var/www/html) folder
# cd /var/www/html
# wget https://download.nextcloud.com/server/releases/latest.zip
# unzip latest.zip
2. Move all nextcloud content to the web root (/var/www/html) folder
# cd /var/www/html/nextcloud
# mv * .* ../
3. Remove empty nextcloud directory
# rmdir /var/www/html/nextcloud
4. Change the ownership of the nextcloud content directory to the HTTP user.
# chown -R www-data:www-data /var/www/html
Now, Go to the Browser and type http:// [ ip or fqdn ] of the server, The below Nextcloud install page will appear. On the page we need to Provide information for
1. nextcloud admin username & password
2. Database Credentials (db name, db user and db Password)

– After Providing all the information click Install button. it will install nextcloud in a minute and provide the recommended app installation page, we can safely cancel the prompt for now.

Our installation and Initial Setup is complete so Next, the Nextcloud Dashboard will appear.

This is the fastest way to install Nextcloud on Ubuntu 22.04, after installation we should take care the nextcloud performance and security issues.