How to Install Nextcloud on Ubuntu 22.04

Nextcloud is a suite of client-server software for creating and using file hosting services. It is enterprise-ready with comprehensive support options. Being free and open-source software, anyone is allowed to install and operate it on their own private server devices

the free Nextcloud clients for Android, iOS and desktop systems allow you to sync and share files, in a fully secure way through an encrypted connection. The mobile clients feature automatic upload of pictures and videos you take and can synchronize select files and folders.

In this tutorial, i am going to show you how to install and configure Nextcloud on Linux ubuntu 22.04.

How to Install Nextcloud on Ubuntu 22.04

Follow the below given steps to install and configure Nextcloud on Linux ubuntu 22.04:

  • Step 1 – Install PHP and Apache Web Server
  • Step 2 – Install MySQL / MariaDB Database Server
  • Step 3 – Download and Install Nextcloud
  • Step 4 – Configure Apache to Serve Nextcloud
  • Step 5 – Enable ReWrite Mode and Restart Server
  • Step 6 – Complete Nextcloud Installation via GUI

Step 1 – Install PHP and Apache Web Server

Runthe following command on command line to install PHP and apache web server:

sudo apt update
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 by running the following command:

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

Then set PHP variables; is as follow:

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

And restart apache web server by running the following command:

sudo systemctl restart apache2

Step 2 – Install MySQL / MariaDB Database Server

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

sudo apt -y install mariadb-server

Secure MariaDB database server by running 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';
FLUSH PRIVILEGES;
QUIT;

Run the following command to create database:

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

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

Step 3 – Download and Install Nextcloud

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

sudo apt install -y wget unzip
wget https://download.nextcloud.com/server/releases/latest-23.zip

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

unzip latest-23.zip

Move the resulting folder to /srv

sudo mv nextcloud/ /srv

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

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

Step 4 – Configure Apache to Serve Nextcloud

Run 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/
     ServerName example.com
     ServerAlias www.example.com
     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
        </IfModule>
    </Directory>
</VirtualHost>

Step 5 – Enable ReWrite Mode and Restart Server

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

sudo a2enmod rewrite dir mime env headers

sudo systemctl restart apache2

Step 6 – Complete Nextcloud Installation via GUI

Open your browser and point it to the following address:

http://SERVR_IP/nextcloud/
OR
http://SERVER_ADDRESS/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.

Conclusion

In this tutorial, i have shown to you how to install and configure Nextcloud on Linux ubuntu 22.04.

More Tutorials

Leave a Comment