How to install Nextcloud 27 on your server

Welcome to the Wiki. Enjoy this article!
You are responsible for the quality of your edits. :heart:
This is the german tutorial for it.
This article shows you how to install your own Nextcloud on Ubuntu 23.X or 22.X LTS!

updating

apt update && apt upgrade -y

Installing apache

apt install apache2

Install PHP 8.2

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

Install PHP & Moduls

apt install apt install libapache2-mod-php php php-zip php-dompdf php-xml php-mbstring php-gd php-curl php-imagick libmagickcore-6.q16-6-extra php-intl php-bcmath php-gmp php-cli php-json php-mysql php-pear unzip nano php-apcu redis-server ufw php-redis php-smbclient php-ldap

If you are asked to confirm something during any installation, you must also do this.

adjust PHP.ini file

nano /etc/php/8.2/apache2/php.ini

memory_limit = 2048M
upload_max_filesize = 20G
post_max_size = 20G
date.timezone = Europe/Berlin
output_buffering = Off

Install Databse Server

apt install mariadb-server

Maria DB Server Konfiguration

mysql_secure_installation

open SQL dialoge

mysql

create database calles nextcloud

CREATE DATABASE nextcloud;

create database user with password

CREATE USER 'nextclouduser'@'localhost' IDENTIFIED BY 'password_here';

grant accesss to databse

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

save changes and exit

FLUSH PRIVILEGES;
EXIT;

Download lastest nextcloud version

cd /tmp && wget https://download.nextcloud.com/server/releases/latest.zip
unzip latest.zip
mv nextcloud /var/www/

#adjust apache conf
nano /etc/apache2/sites-available/000-default.conf

→ change /var/www/html to /var/www/nextcloud

Enable the NextCloud and Rewrite Module

a2enmod rewrite
a2enmod headers
a2enmod env
a2enmod dir
a2enmod mime

restart apache

service apache2 restart

prepare data folder

mkdir /home/data/
chown -R www-data:www-data /home/data/

chown -R www-data:www-data /var/www/nextcloud/
chmod -R 755 /var/www/nextcloud/
4 Likes

Thank you for reading this article
Feel free to visit us at dev.to and Github!

Might be worth adding which OS (incl. version) you are using as basis.

Thanks for the info, I’ve added it!

The permissions do not need to be 755. They can be 750 for folders and 640 for files. An original instruction is to prepare as follows:

chown -R www-data:www-data nextcloud
find nextcloud/ -type d -exec chmod 750 {} ;
find nextcloud/ -type f -exec chmod 640 {} ;

In my experience, these can be applied either for the installation folder (generally var/www), data folder (within to out of the installation folder) or external drives.

There is no reason to allow ‘other users’ to read and execute if files are not accessed outside nextcloud.

So instead of

should i use this?

chown -R www-data:www-data nextcloud
find nextcloud/ -type d -exec chmod 750 {} ;
find nextcloud/ -type f -exec chmod 640 {} ;

Thanks for the info anyway!