Skip to content

All topics  /  Linux

Install the Latest Version of Nextcloud on Ubuntu 22.04 Code Example

Linux ·

For teams turning “Install the Latest Version of Nextcloud on Ubuntu 22.04 Code Example” into a repeatable delivery task, practical practical form can document setup, troubleshooting and review time; managers should interpret those records alongside reliability and completed work, not as a stand-alone score.

Package and operating-system behaviour can change, so verify the commands and supported versions through Ubuntu before running them on a production host.

Hi Guys

This example is focused on Install the Latest Version of Nextcloud on Ubuntu 22.04 Code Example. We will look at example of Install Nextcloud on Ubuntu: A Step-by-Step Setup Guide. you will learn Install NextCloud on Ubuntu 22.04. this example will help you Install Nextcloud Desktop Client on Ubuntu 22.04.

You can use this post for ubuntu 14.04, ubuntu 16.04, ubuntu 18.4, ubuntu 20.04, ubuntu 21 and ubuntu 22.04 versions.

(1). Install PHP and Apache Web Server

(2). Install MySQL / MariaDB Database Server

(3). Download and Install Nextcloud

(4). Configure Apache to Serve Nextcloud

(5). Enable ReWrite Mode and Restart Server

(6). Complete Nextcloud Installation via GUI

Step 1: Install PHP and Apache Web Server


Run the following command 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

Set up PHP variables using 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

Restart apache web server

sudo systemctl restart apache2

Step 2: Install MySQL / MariaDB Database Server

Run the following command 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';
FLUSH PRIVILEGES;
QUIT;

Then execute 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 Strong Password with Database User Password.

Step 3: Download and Install Nextcloud

To download and install NextCloud on Linux Ubuntu, run the following commands:

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

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

unzip latest-23.zip

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 4: Configure Apache to Serve Nextcloud

Following the 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

Using 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 has loaded, create a NextCloud Superuser / Admin user account. Enter username and password.