How To

How To Install Nextcloud on Ubuntu 22.04|20.04|18.04

Welcome to our guide on how to install Nextcloud on Ubuntu 22.04|20.04|18.04 Linux system. Nextcloud is an open-source file-sharing service that is self-hosted. It is a fork of Owncloud and it gives you collaboration features similar to what you get on Dropbox. Some of the collaborative features of Nextcloud are:

Original content from computingforgeeks.com - post 4993
  • Has Media Player for playing shared media content
  • Has contact management feature
  • File sync and sharing – With notes to shares, searching in comments, recovery of files
  • Video calls with chat and  MCU, SIP-Bridge, ext. Signaling backend integration
  • Online document editor/reader
  • Calendar Management e.t.c.

You can extend Nextcloud functionalities via add-on applications. For Desktop and Android users, applications are available to install and connect to Nextcloud server.

Install Nextcloud on Ubuntu

Install Nextcloud on Ubuntu 22.04|20.04|18.04

Nextcloud dependencies are:

  • PHP
  • Apache / Nginx web server
  • MySQL / MariaDB Database server

Here are the steps for installing Nextcloud on Ubuntu 22.04|20.04|18.04

Step 1: Install PHP and Apache Web Server

Add PPA apt repository

sudo apt update
sudo apt install lsb-release ca-certificates apt-transport-https software-properties-common -y
sudo add-apt-repository ppa:ondrej/php

Update package index and install PHP 8.

sudo apt update && sudo apt install php8.2
sudo apt install php8.2-{bcmath,xml,fpm,mysql,zip,intl,ldap,gd,cli,bz2,curl,mbstring,pgsql,opcache,soap,cgi}
sudo apt install apache2 libapache2-mod-php8.2
sudo a2enmod php8.2

Set PHP variables to suit your use.

$ sudo vim /etc/php/*/apache2/php.ini
date.timezone = Africa/Nairobi
memory_limit = 512M
upload_max_filesize = 500M
post_max_size = 500M
max_execution_time = 300

Restart apache2 service:

sudo systemctl restart apache2

Step 2: Install MySQL / MariaDB Database Server

NextCloud can use MySQL, MariaDB, PostgreSQL or SQLite database to store its data. In this guide, we will use MariaDB or MySQL database server.

sudo apt -y install mariadb-server

Secure MariaDB database server:

sudo mysql_secure_installation

After the installation of the database server, you need to create a database and user for Nextcloud

$ sudo mysql -uroot -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.

Confirm if the user can connect to the database with the provided password:

$ mysql -u nextcloud -p 
Enter password: <ENTER PASSWORD> 
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 34
MariaDB [(none)]> SHOW DATABASES;
MariaDB [(none)]> QUIT
Bye

Step 3: Download and Install Nextcloud

Nextcloud is distributed as a zip file. Check for the latest release from  Nextcloud download page before pulling the archive.

Download Nextcloud zip package:

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

Once the file is downloaded, extract it:

unzip latest.zip

Move the resulting folder to /srv

sudo mv nextcloud/ /srv

Change directory permissions to the www-datauser

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

Step 4: Configure Apache Web Server

Create a VirtualHost file for Nextcloud:

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

Paste 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>

Enable required Apache modules and restart the service:

sudo a2enmod rewrite dir mime env headers
sudo systemctl restart apache2

Visit the pagehttp://example.com to finish the setup.

1. Create an admin user account

2.Specify data directory – The owner should be userwww-data and group.

install nextcloud 14 ubuntu 18.04 debian 9 01

3. Provide database connection settings as created in Step 2

install nextcloud 14 ubuntu 18.04 debian 9 02

Click “Finish Setup” butto to complete installation of Nextcloud on Ubuntu

install nextcloud 14 ubuntu 18.04 debian 9 03

Thanks for using our tutorial to Install Nextcloud on Ubuntu 22.04|20.04|18.04. I hope this was helpful.

Similar Articles:

Related Articles

Arch Linux i3 ssh configuration to unlock without passphrase Databases How To Install MySQL Workbench on Ubuntu 22.04|20.04 Virtualization Create and Configure Bridge Networking For KVM in Linux Zabbix Install and Configure Zabbix Agent on Ubuntu 20.04|18.04

2 thoughts on “How To Install Nextcloud on Ubuntu 22.04|20.04|18.04”

Leave a Comment

Press ESC to close