Debian 12 bookworm
Sponsored Link

NextCloud : Install2023/08/03

Install NextCloud which is the Cloud Storage System.
Configure SSL/TLS for Apache2.
HTTPS connection is required when httpd Chat, Camera, Screen Sharing features and so on.
[5] Install other required PHP modules.
apt -y install php-pear php8.2-mbstring php8.2-intl php8.2-gd php8.2-zip php8.2-mysql php8.2-bcmath php8.2-gmp php8.2-opcache php-imagick php8.2-curl php-apcu unzip imagemagick

vi /etc/php/8.2/fpm/pool.d/nextcloud.conf
# create new

user = www-data
group = www-data

listen.owner = www-data = www-data
listen = /run/php/nextcloud.sock
listen.allowed_clients =

pm = dynamic
pm.max_children = 50
pm.start_servers = 5
pm.min_spare_servers = 5
pm.max_spare_servers = 35

env[PATH] = /usr/local/bin:/usr/bin:/bin
env[TMP] = /tmp
env[TMPDIR] = /tmp
env[TEMP] = /tmp

php_value[session.save_handler] = files
php_value[session.save_path]    = /var/lib/php/sessions

# maybe you need to configure parameters below if users want to upload large files
php_value[max_execution_time] = 3600
php_value[memory_limit] = 2G
php_value[post_max_size] = 2G
php_value[upload_max_filesize] = 2G
php_value[max_input_time] = 3600
php_value[max_input_vars] = 2000
php_value[date.timezone] = Asia/Tokyo

php_value[zend_extension] = opcache
php_value[opcache.enable] = 1
php_value[opcache.memory_consumption] = 128
php_value[opcache.interned_strings_buffer] = 16
php_value[opcache.max_accelerated_files] = 10000
php_value[opcache.revalidate_freq] = 1
php_value[opcache.save_comments] = 1

systemctl restart php8.2-fpm

[6] Create a User and Database on MariaDB for NextCloud.

Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 37
Server version: 10.11.3-MariaDB-1 Debian 12

Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

MariaDB [(none)]> create database nextcloud; 
Query OK, 1 row affected (0.00 sec)

MariaDB [(none)]> grant all privileges on nextcloud.* to nextcloud@'localhost' identified by 'password'; 
Query OK, 0 rows affected (0.00 sec)

MariaDB [(none)]> exit 
[7] Configure Apache2 for NextCloud.
vi /etc/apache2/sites-available/nextcloud.conf
Timeout 3600
ProxyTimeout 3600
DirectoryIndex index.php index.html
Header set Strict-Transport-Security "max-age=15768000; includeSubDomains; preload"

<VirtualHost *:80>
    DocumentRoot /var/www/nextcloud

<VirtualHost *:443>
    DocumentRoot /var/www/nextcloud
    SSLEngine on
    SSLCertificateFile      /etc/letsencrypt/live/
    SSLCertificateKeyFile   /etc/letsencrypt/live/
    SSLCertificateChainFile /etc/letsencrypt/live/

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

    <FilesMatch \.(php|phar)$>
        SetHandler "proxy:unix:/run/php/nextcloud.sock|fcgi://localhost"

wget -P /var/www/

unzip /var/www/ -d /var/www/

chown -R www-data:www-data /var/www/nextcloud

a2ensite nextcloud

a2enmod headers

a2enmod rewrite

systemctl restart apache2

[8] Access to the virtual host URL you set on Apache2 with web browser from any client computer, then following screen is displayed. Configure Administrative user account and Database connection information. Input any admin user name and password. For Database, specify MariaDB user and database you added on [6]. That's OK, Click [Finish Setup].
[9] If you like to install recommended applications, Click [Install ***] button.
[10] After recommended apps successfully installed, NextCloud start page is displayed.
[11] After finishing setup, it's possible to access to NextCloud to the same URL with initial setup.
[12] This is the Nextcloud start page.
[13] After initial setup, configure memory cache and [default_phone_region] value that are the NextCloud recommended requirements.
vi /var/www/html/nextcloud/config/config.php
  # add a line in the section
  # replace [default_phone_region] value to your own region (ISO 3166-1) 
  'installed' => true,
  'memcache.local' => '\OC\Memcache\APCu',
  'default_phone_region' => 'JP',

systemctl reload php8.2-fpm

Matched Content