Project

General

Profile

Actions

Install on Ubuntu 2204

Installation Instructions

This is an easy to use install script

Step 1: Install Git
First, make sure Git is installed on your server. If it’s not installed, you can install it with the following command:

sudo apt update
sudo apt install git -y

Step 2: Clone the Repository and Run the Installer
After installing Git, follow these steps to install Nextcloud:

git clone https://gitlab.lightningcr.com/installers/next-cloud-installer.git
cd next-cloud-installer
chmod +x install_nextcloud.sh
sudo ./install_nextcloud.sh

If you prefer not to use the script

h1. Install on Ubuntu 20.04 / 22.10

h2. Requirements
  • A server running Ubuntu 20.04.
  • A valid domain name pointed to the server or Nginx Proxy Manager IP. See A Record
  • A root password is configured on your server.
  • install software-properties-common
sudo apt update
sudo apt install software-properties-common

After successfully installing software-properties-common, you can add the PHP PPA as follows:

sudo LC_ALL=C.UTF-8 add-apt-repository ppa:ondrej/php
sudo apt-get update

Before starting, LAMP stack must be installed on your server. If not installed, you can install it with the following command:

NOTE: If you are installing Nextcloud 26 + on Ubuntu 20.04, you will need php8, this so use this LAMP stack

sudo apt install apache2 mariadb-server php8.1 php8.1-cli php8.1-fpm php8.1-intl php8.1-imagick php8.1-pdo php8.1-mysql php8.1-zip php8.1-gd php8.1-mbstring php8.1-curl php8.1-xml php8.1-bcmath libapache2-mod-php8.1 php8.1-gmp -y

NOTE: to use 8.3 php install the following...

sudo apt install apache2 mariadb-server php8.3 php8.3-cli php8.3-fpm php8.3-intl php8.3-imagick php8.3-pdo php8.3-mysql php8.3-zip php8.3-gd php8.3-mbstring php8.3-curl php8.3-xml php8.3-bcmath libapache2-mod-php8.3 -y

sudo apt-get install librsvg2-bin
sudo apt-get install --reinstall php-imagick

if you have installed 8.1 you can remove it using this...

sudo apt-get remove libapache2-mod-php8.1 php8.1 php8.1-bcmath php8.1-cli php8.1-common php8.1-curl php8.1-fpm php8.1-gd php8.1-gmp php8.1-imagick php8.1-intl php8.1-mbstring php8.1-mysql php8.1-opcache php8.1-readline php8.1-xml php8.1-zip

sudo apt-get autoremove
sudo systemctl restart apache2

After installing all packages, edit the PHP configuration file and change some default settings:

Use php -v to check which php is installed, and change the #.# with the right numbers
in my case it say, PHP 8.1

nano /etc/php/8.1/apache2/php.ini

Change the following lines:

date.timezone = UTC or what ever time zone you are in
memory_limit = 512M
upload_max_filesize = 500M
post_max_size = 500M
max_execution_time = 300
opcache.interned_strings_buffer=16

Note: https://www.php.net/manual/en/timezones.php

Save and close the file then restart the Apache service to apply the changes:

systemctl restart apache2

 

Create a Database for Nextcloud


Nextcloud uses a MariaDB database as a database backend so you will need to create a database and user in MariaDB.

First, connect to the MariaDB shell with the following command:

mysql

Once you are connected to the MariaDB, create a database and user with the following command:

NOTE: Change the 'password' to the password you would like to use.

CREATE DATABASE nextcloud;
CREATE USER 'nextcloud'@'localhost' identified by 'password';

Next, grant all the privileges to the Nextcloud database with the following command:

GRANT ALL PRIVILEGES ON nextcloud.* TO 'nextcloud'@'localhost';

Next, flush the privileges and exit from the MariaDB with the following command:
FLUSH PRIVILEGES;
QUIT;

 

Download Nextcloud


At the time of of updateing this article, the latest version of Nextcloud is 26.0.2. It is now nextcloud-28.0.0.zip - You can download it with the following command:
NOTE: you can go to https://download.nextcloud.com/server/releases/ to check which is the latest version

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

Once the download is completed, unzip the downloaded file with the following command:

apt install unzip
unzip nextcloud-28.0.0.zip

Next, move the extracted directory to the Apache web root with the following command:

mv nextcloud /var/www/html/

Next, change the ownership and permission of the Nextcloud directory using the following command:

chown -R www-data:www-data /var/www/html/nextcloud
chmod -R 775 /var/www/html/nextcloud

 

Create an Apache Virtual Host for Nextcloud


Next, you will need to create an Apache virtual host configuration file for Nextcloud. You can create it with the following command:

nano /etc/apache2/sites-available/next.conf

Add the following lines:

NOTE: Change the and next.example.com, to the right one for you

<VirtualHost *:80>
     ServerAdmin [email protected]
     DocumentRoot /var/www/html/nextcloud
     ServerName next.example.com
     ErrorLog /var/log/apache2/nextcloud-error.log
     CustomLog /var/log/apache2/nextcloud-access.log combined

    <Directory /var/www/html/nextcloud>
    Options +FollowSymlinks
    AllowOverride All
        Require all granted
     SetEnv HOME /var/www/html/nextcloud
     SetEnv HTTP_HOME /var/www/html/nextcloud
     <IfModule mod_dav.c>
        Dav off
        </IfModule>
    </Directory>
</VirtualHost>

Save and close the file then activate the Apache virtual host and other required Apache modules with the following command:

a2ensite next
a2enmod rewrite dir mime env headers

Next, restart the Apache service to apply the changes:

systemctl restart apache2

NOTE: we have had it where the default site configuration was overriding my vhost configuration, if this happens to you you can disable the default configuration.

sudo a2dissite 000-default.conf
service apache2 reload

 

Now in a web-browser go to your nextcloud address(http://next.example.com) and finish the install,

Set up an admin user account, and for the database it should be,

Database user: nextcloud
Database password: what ever you used
Database name: nextcloud
Database hose:localhost

"Adding default phone region to Nextcloud config file for validating phone numbers in profile settings."


The install should now be complete.


"Configure a Memcache for Better Performance in Nextcloud"


Depending on how you setup your network and server you might have to install a SSL more information on how to do that below.

You should also go to "Administration Settings" and in the Overview tab, see the Security & setup warning, see https://lightningcr.com/projects/nextcloud/wiki to help you with each warning you get.

also setup your Email Server, this is found in Basic setting, again see https://lightningcr.com/projects/nextcloud/wiki to help you with this.


Installing SSL with Let's Encrypt SSL
Installing on with a Nginx with a reverse proxy using a Nginx Proxy Manager

Updated by Gareth Eaton 4 months ago · 57 revisions