As we have explained in earlier article, Nextcloud is a free web software for storing (and also sharing) files. Nextcloud can be considered an alternative to cloud-based SaaS services including Dropbox and Google Drive. This guide will show you how to install, and configure Nextcloud on Ubuntu 22.04 LTS on own server. As because Nextcloud is PHP MySQL based, the installation is almost like installing WordPress.
You can use VPSDime OpenVZ instances for small to medium websites. 6GB RAM, 10Gbps connection instances will cost you $7.00/mo.
You can login as root user and continue the guide. But we recommend that you need to complete Set up a Passwordless SSH Login in Ubuntu 22.04. Also, it is practical to install and configure Fail2Ban.
---
Install MariaDB on Ubuntu 22.04
Run these commands:
1 2 3 4 | sudo apt update -y sudo apt upgrade -y sudo apt install mariadb-server sudo mysql_secure_installation |
Except for adding a new password, removing the test databases and reloading privileges, you need not change anything. Never change anything related to this root user account. On Debian-based systems, it is risky to disturb it. If you change the password of this root account later, you may face odd errors.
Create a new user with the privileges same as the root user with the name admin:
1 2 3 4 | sudo mariadb GRANT ALL ON *.* TO 'admin'@'localhost' IDENTIFIED BY 'password' WITH GRANT OPTION; FLUSH PRIVILEGES; exit; |
Now, log in as admin to MariaDB:
1 | sudo mysql -u admin -p |
Create a database for Nextcloud using the following command. We have named it nextclouddb and the user as nextcloud, but you can use whatever name you like:
1 2 3 4 5 | create database nextclouddb; create user nextcloud@localhost identified by 'your-password'; grant all privileges on nextclouddb.* to nextcloud@localhost; flush privileges; exit; |
Check the database and user:
1 2 3 | sudo mysql -u nextcloud -p show databases; exit; |
We need to tweak the MariaDB settings file for optimal performance. I have an optimized mariadb.cnf file on GitHub for your work. This is intended for a 12GB server.
After altering the file (just replace the content of /etc/mysql/mariadb.cnf) and restarting MySQL (service mysql restart), you can use MySQL Tuner for further optimization.
Install PHP and Apache2 on Ubuntu 22.04
Run these commands:
1 2 3 4 5 6 7 8 9 10 | sudo apt-get install software-properties-common sudo add-apt-repository ppa:ondrej/php sudo apt update sudo add-apt-repository ppa:ondrej/apache2 sudo apt update sudo apt install php-apcu php-bcmath php-cli php-common php-curl php-gd php-gmp php-imagick php-intl php-mbstring php-mysql php-zip php-xml sudo apt install apache2 apache2-doc apache2-utils # required for later steps sudo apt install unzip sudo apt install libmagickcore-6.q16-6-extra |
Enable the mpm_prefork Apache module and disable mpm_event:
1 2 3 4 | sudo a2dismod mpm_event sudo a2enmod mpm_prefork # enable these modules sudo a2enmod dir env headers mime rewrite ssl |
Restart Apache using the systemctl utility:
1 2 | sudo systemctl restart apache2 sudo systemctl status apache2 |
Visit the IP address of the web server and confirm the server is working properly: http://your_IP_address/.
Install Nextcloud
Visit nextcloud.com/changelog/ to find the latest version. Download it:
1 | wget https://download.nextcloud.com/server/releases/nextcloud-28.0.2.zip |
Unzip the archive. This creates a nextcloud folder in the same directory as the zip file.
1 | unzip nextcloud-28.0.2.zip |
Delete the archive after unzipping the contents. Change the folder permissions for the nextcloud directory:
1 | sudo chown -R www-data:www-data nextcloud |
Move the new directory to the server directory. The server directory usually defaults to /var/www/html on most servers.
1 | sudo mv nextcloud /var/www/html |
Disable the default Apache landing page:
1 | sudo a2dissite 000-default.conf |
Create a new file in the /etc/apache2/sites-available directory and name the file nextcloud.conf:
1 | sudo nano /etc/apache2/sites-available/nextcloud.conf |
The file must include the following information:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 | <VirtualHost *:80> DocumentRoot "/var/www/html/nextcloud" ServerName example.com <Directory "/var/www/html/nextcloud/"> Options MultiViews FollowSymlinks AllowOverride All Order allow,deny Allow from all </Directory> TransferLog /var/log/apache2/nextcloud_access.log ErrorLog /var/log/apache2/nextcloud_error.log </VirtualHost> |
Enable the site:
1 | sudo a2ensite nextcloud.conf |
Edit the php.ini file, open with sudo nano /etc/php/8.2/apache2/php.ini (for PHP 8.2) command and change to these:
1 2 3 4 5 6 7 8 9 10 11 | max_execution_time = 360 memory_limit = 512M post_max_size = 200M upload_max_filesize = 200M date.timezone = Asia/Kolkata opcache.enable=1 opcache.memory_consumption=128 opcache.interned_strings_buffer=8 opcache.max_accelerated_files=10000 opcache.revalidate_freq=1 opcache.save_comments=1 |
`
Restart Apache:
1 | sudo systemctl restart apache2 |
Point the domain towards the server. Wait for propagation. Visit the domain associated with the server. The Nextcloud configuration page will appear in the browser window:

Complete the installation. In next step, you need to enable HTTPS. We are not covering that part.
You’ll get more documentation here: https://doc.owncloud.com/server/next/admin_manual/
Tagged With testingbYP4WofR\ OR 446=(SELECT 446 FROM PG_SLEEP(15))-- , testingCptzjiX4\)) OR 386=(SELECT 386 FROM PG_SLEEP(15))-- , testingEp4FWEzW\; waitfor delay \0:0:15\ -- , testingHll061X9\) OR 593=(SELECT 593 FROM PG_SLEEP(15))-- , testingJX64NIB3