Home // How to install Nextcloud on Ubuntu 20.04

How to install Nextcloud on Ubuntu 20.04

0 comment 5 mins read

Nextcloud is a great choice if you want to make your own file sharing and syncing platform. Let me walk you through the simple steps needed to install Nextcloud on Ubuntu.

Nextcloud is an application server for sharing files that you host yourself. It lets you store all of your files, documents, and contacts in one place. Unlike Dropbox, Google Drive, OneDrive, and other closed-source cloud storage options, this one is free for everyone to use.

Moreover, they’ll be able to see their files from any computer by logging onto the server, exactly like Dropbox. Specifically, Nextcloud’s server software was developed to run on Linux distributions. This makes it simple to set up for even the most inexperienced Linux user. Let us not waste any more time and get started.

You can share files with other people and keep all of your devices in sync when you use Nextcloud. You can also open extra accounts for family and friends, which is another benefit.

We’ll show how to install Nextcloud on Ubuntu and configure Nextcloud on Ubuntu.

Install Apache Web Server to run Nextcloud

Before you can use Nexcloud, you need to set up the Apache Web Server, since it will be a browser-based app.

sudo apt install -y apache2 apache2-utils

After Apache has been installed, make sure it works:

sudo systemctl status apache2

The result above checks to see if the Apache Web Server is running.

Install PHP8.0 for Nextcloud

Since PHP is the language in which Nextcloud was originally written, you must know atleast some PHP to work with its source code. Follow these steps to install the PHP modules that Nextcloud needs or suggests

You Might Be Interested In

Enabling PHP Repository

Ondrej Sur, a contributor to the Debian project, keeps a repository updated with several PHP distributions. Just type:

sudo apt install software-properties-common
sudo add-apt-repository ppa:ondrej/php

After enabling the PPA, PHP 8 can be installed.

PHP Module Installation on Apache

Installing PHP as an Apache module is a straightforward task:

sudo apt update
sudo apt install php libapache2-mod-php php8.0 libapache2-mod-php8.0

Once the packages are installed, restart Apache for the PHP module to get loaded:

sudo systemctl restart apache2

Set up PHP-FPM for use with Apache.

Php-FPM is a FastCGI process manager for PHP. Run the following command to install the necessary packages:

sudo apt update
sudo apt install php8.0-fpm php-fpm libapache2-mod-fcgid

By default PHP-FPM is not enabled in Apache. To enable it, run:

sudo a2enmod proxy_fcgi setenvif
sudo a2enconf php8.0-fpm

To activate the changes, restart Apache:

systemctl restart apache2

Installing PHP extensions

PHP extensions are built-in libraries that add to PHP’s core features. Extensions come as packages that are easy to install with apt:

sudo apt install php8.0-[extname]

To install the MySQL and GD extensions, for example, you would run the following command:

You Might Be Interested In
sudo apt install php8.0-mysql php8.0-gd

The modules below are the ones we need for Nextcloud

sudo apt install php php8.0 libapache2-mod-php php-imagick php-common php-mysql php-gd php-json php-curl php-zip php-mbstring php-bz2 php-intl php-bcmath php-gmp unzip

After installing a new PHP extension, don’t forget to restart the Apache or PHP FPM service, depending on your setup.

systemctl restart apache2

This is a faster way to add the extensions to the php version of your choice:

sudo apt install php8.0-{mysql,redis,imagick,common,gd,json,curl,zip,xml,mbstring,bz2,intl,bcmath,gmp}

You should reload Apache for the changes to take effect.

sudo systemctl reload apache2

and maybe reload php-fpm (if its not fpm just remove -fpm)- choose whichever applies to you below:

service php8.0-fpm restart
service php8.1-fpm restart
service php7.4-fpm restart

Verify your PHP version:

php -v

MariaDB Database Server Setup & Configuration.

Nextcloud can keep its data in SQLite, MySQL, MariaDB, or PostgreSQL databases, what’s more the lesson assumes that you have already installed MariaDB, as it is the recommended database.

sudo apt install mariadb-server

Once MariaDB servers are up and running, the password for the MariaDB admin user must be changed.

sudo mysql_secure_installation

Since the root password isn’t set, press the Enter key when asked for the MariaDB root password. Type Y if you want to change MariaDB’s root password. Make sure that the root user of MariaDB has a strong password.

Then press Enter to terminate the remaining queries, delete the test database, and disable remote root login.

You Might Be Interested In

Establish a New Nextcloud Database and User

Use the superuser, or root, to connect to MariaDB:

sudo mysql -u root -p

Thereafter, Make a new database that Nextcloud can use. In this case, the database has been given the name nextcloudpc, however you are free to choose whatever name you like.

CREATE DATABASE nextcloudpc;

The next step is to add a new user to the database and give them access to the Nextcloud server. I went with “pcplanet,” but really anything will do.

You need change “your-password” to your actual password.

GRANT ALL ON nextcloudpc.* TO [email protected]'localhost' IDENTIFIED BY 'your-password';

Exit after reloading privileges.

FLUSH PRIVILEGES;
EXIT;

Check to see if the user’s password has given them access to the database.

mysql -u pcplanet -p

Obtain Nextcloud and Set it Up

After setting up the database, you can move on to installing Nextcloud on ubuntu. The software package for Nextcloud is a compressed file. First, go to the official download page for Nextcloud to make sure you have the latest version.

As of this writing, version 24.0.4 is the most recent available. Type in this command to get NextCloud:

wget https://download.nextcloud.com/server/releases/nextcloud-24.0.4.zip

Follow the steps below to install Nextcloud. This will unpack the archive to /var/www/html, create the data directory where Nextcloud will store user data, and change permissions.

You Might Be Interested In
Note: installing unzip may be required
sudo unzip nextcloud-24.0.4.zip -d /var/www/html/
sudo mkdir /var/www/html/nextcloud/data
sudo chown -R www-data:www-data /var/www/html/nextcloud/

Apache Configuration and SSL

Set up the Apache virtualhost by going into the apache directory /etc/apache2/sites-enabled/000-default.conf

<VirtualHost *:80>
  DocumentRoot /var/www/html/nextcloud/
  ServerName  your.server.com

  <Directory /var/www/html/nextcloud/>
    Require all granted
    AllowOverride All
    Options FollowSymLinks MultiViews

    <IfModule mod_dav.c>
      Dav off
    </IfModule>
  </Directory>
</VirtualHost>

Additionnal Apache settings

a2enmod rewrite
a2enmod headers
a2enmod env
a2enmod dir
a2enmod mime
a2enmod setenvif

6. Configure Nextcloud

Installation of Nextcloud completed successfully.

Secondly; Go to http://server-ip/nextcloud/ in a web browser.

Thirdly, complete setting up NextCloud on ubuntu..

Fill in the Username and Password to activate your admin account.

Set the Data folder. You can find the data stored in /var/www/html/nextcloud/data.

Connect using the login (pcplanet), password (your-password), and database name (nextcloudpc) generated in Step 4.

To install Nextcloud on Ubuntu, click Finish Setup.

Nextcloud will immediately make you the system administrator and log you in. it’s that simple to set up as a personal cloud storage service.

You Might Be Interested In

Leave a Comment

Copyright @2022-2023 All Right Reserved – PCPlanet

Adblock Detected

The only intrusive ad here is the google vignette, help support me by disabling your adblocker.