Prerequisites

To complete this guide, ensure you have the following:

  • A Debian 12 server with at least 4 GB of memory and 2 CPUs.
  • A non-root user with administrator privileges.
  • A domain name pointed to the server IP address.
apt update && apt dist-upgrade && apt install -y apache2 php php-curl php-cli php-mysql php-gd php-common php-xml php-json php-intl php-pear php-imagick php-dev php-common php-mbstring php-zip php-soap php-bz2 php-bcmath php-gmp php-apcu libmagickcore-dev php-redis php-memcached php-memcache php-ldap unzip redis mariadb-server
nano /etc/php/8.2/apache2/php.ini
date.timezone = Europe/Paris
 
memory_limit = 512M  
upload_max_filesize = 500M  
post_max_size = 600M   
max_execution_time = 300
 
file_uploads = On  
allow_url_fopen = On
 
display_errors = Off  
output_buffering = Off
 
zend_extension=opcache
 
opcache.enable = 1  
opcache.interned_strings_buffer = 64  
opcache.max_accelerated_files = 10000  
opcache.memory_consumption = 512  
opcache.save_comments = 1  
opcache.revalidate_freq = 1
systemctl restart apache2
systemctl mariadb-secure-installation
mariadb
CREATE DATABASE nextcloud_db;  
CREATE USER nextclouduser@localhost IDENTIFIED BY 'StrongPassword';
GRANT ALL PRIVILEGES ON nextcloud_db.* TO nextclouduser@localhost;  
FLUSH PRIVILEGES;
SHOW GRANTS FOR nextclouduser@localhost;
EXIT;
cd /var/www/
curl -o nextcloud.zip https://download.nextcloud.com/server/releases/latest.zip
unzip nextcloud.zip
chown -R www-data:www-data nextcloud
nano /etc/apache2/sites-available/nextcloud.conf
<VirtualHost *:80>  
    ServerName nextcloud.hwdomain.io  
    DocumentRoot /var/www/nextcloud/  
  
    # log files  
    ErrorLog /var/log/apache2/files.hwdomain.io-error.log  
    CustomLog /var/log/apache2/files.hwdomain.io-access.log combined  
  
    <Directory /var/www/nextcloud/>  
        Options +FollowSymlinks  
        AllowOverride All  
  
        <IfModule mod_dav.c>  
            Dav off  
        </IfModule>  
  
        SetEnv HOME /var/www/nextcloud  
        SetEnv HTTP_HOME /var/www/nextcloud  
    </Directory>  
</VirtualHost>
a2ensite nextcloud.conf
systemctl restart apache2
nano /var/www/nextcloud/config/config.php
  'default_phone_region' => 'FR',
  'memcache.local' => '\OC\Memcache\APCu',
  'memcache.distributed' => '\OC\Memcache\Redis',
  'memcache.locking' => '\OC\Memcache\Redis',
  'redis' => [
       'host' => 'localhost',
       'port' => 6379,
  ],
  'maintenance_window_start' => 1,

You’ll also need to setup: