Ubuntu 22.04
Sponsored Link

NextCloud : Install
2022/09/09
 
Install NextCloud which is the Cloud Storage System.
[1]
[2]
Configure SSL/TLS for Nginx.
HTTPS connection is required when using Chat, Camera, Screen Sharing features and so on.
[3]
[4]
[5] Install other required PHP modules.
root@dlp:~#
apt -y install php-pear php8.1-mbstring php8.1-intl php8.1-gd php8.1-zip php8.1-mysql php8.1-bcmath php8.1-gmp php8.1-opcache php-imagick php8.1-curl php-apcu unzip

root@dlp:~#
vi /etc/php/8.1/fpm/pool.d/nextcloud.conf
# create new

[nextcloud]
user = www-data
group = www-data

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

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

env[HOSTNAME] = $HOSTNAME
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[opcache.enable] = 1
php_value[opcache.memory_consumption] = 128
php_value[opcache.interned_strings_buffer] = 8
php_value[opcache.max_accelerated_files] = 10000
php_value[opcache.revalidate_freq] = 1
php_value[opcache.save_comments] = 1

root@dlp:~#
systemctl restart php8.1-fpm

[6] Create a User and Database on MariaDB for NextCloud.
root@dlp:~#
mysql

Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 37
Server version: 10.6.7-MariaDB-2ubuntu1.1 Ubuntu 22.04

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)]> flush privileges; 
Query OK, 0 rows affected (0.00 sec)

MariaDB [(none)]> exit 
Bye
[7] Configure Nginx for NextCloud.
# add follows into [server] section of a Virtual Host setting you'd like to set NextCloud (example below is the default site)

root@dlp:~#
vi /etc/nginx/sites-available/default
       fastcgi_read_timeout 3600;
       proxy_read_timeout 3600;
       fastcgi_hide_header X-Powered-By;

       add_header Referrer-Policy "no-referrer" always;
       add_header X-Content-Type-Options "nosniff" always;
       add_header X-Download-Options "noopen" always;
       add_header X-Frame-Options "SAMEORIGIN" always;
       add_header X-Permitted-Cross-Domain-Policies "none" always;
       add_header X-Robots-Tag "none" always;
       add_header X-XSS-Protection "1; mode=block" always;

       location ^~ /nextcloud {
              client_max_body_size 2G;
              fastcgi_buffers 64 4K;

              gzip on;
              gzip_vary on;
              gzip_comp_level 4;
              gzip_min_length 256;
              gzip_proxied expired no-cache no-store private no_last_modified no_etag auth;
              gzip_types application/atom+xml application/javascript application/json application/ld+json application/manifest+json application/rss+xml application/vnd.geo+json application/vnd.ms-fontobject application/x-font-ttf application/x-web-app-manifest+json application/xhtml+xml application/xml font/opentype image/bmp image/svg+xml image/x-icon text/cache-manifest text/css text/plain text/vcard text/vnd.rim.location.xloc text/vtt text/x-component text/x-cross-domain-policy;

              location /nextcloud {
                            rewrite ^ /nextcloud/index.php;
              }
              location ~ ^\/nextcloud\/(?:build|tests|config|lib|3rdparty|templates|data)\/ {
                            deny all;
              }
                            location ~ ^\/nextcloud\/(?:\.|autotest|occ|issue|indie|db_|console) {
                            deny all;
              }
              location ~ ^\/nextcloud\/(?:index|remote|public|cron|core\/ajax\/update|status|ocs\/v[12]|updater\/.+|oc[ms]-provider\/.+|.+\/richdocumentscode\/proxy)\.php(?:$|\/) {
                            include snippets/fastcgi-php.conf;
                            fastcgi_pass unix:/run/php/nextcloud.sock;
                            fastcgi_param modHeadersAvailable true;
                            fastcgi_param front_controller_active true;
                            fastcgi_intercept_errors on;
                            fastcgi_request_buffering off;
              }
              location ~ ^\/nextcloud\/(?:updater|oc[ms]-provider)(?:$|\/) {
                            try_files $uri/ =404;
                            index index.php;
              }
              location ~ ^\/nextcloud\/.+[^\/]\.(?:css|js|woff2?|svg|gif|map)$ {
                            try_files $uri /nextcloud/index.php$request_uri;
                            add_header Cache-Control "public, max-age=15778463";
                            add_header Referrer-Policy "no-referrer" always;
                            add_header X-Content-Type-Options "nosniff" always;
                            add_header X-Download-Options "noopen" always;
                            add_header X-Frame-Options "SAMEORIGIN" always;
                            add_header X-Permitted-Cross-Domain-Policies "none" always;
                            add_header X-Robots-Tag "none" always;
                            add_header X-XSS-Protection "1; mode=block" always;
                            access_log off;
              }

              location ~ ^\/nextcloud\/.+[^\/]\.(?:png|html|ttf|ico|jpg|jpeg|bcmap|mp4|webm)$ {
                            try_files $uri /nextcloud/index.php$request_uri;
                            access_log off;
              }
        }

root@dlp:~#
wget https://download.nextcloud.com/server/releases/nextcloud-24.0.3.zip -P /var/www/html/

root@dlp:~#
unzip /var/www/html/nextcloud-24.0.3.zip -d /var/www/html/

root@dlp:~#
chown -R www-data. /var/www/html/nextcloud

root@dlp:~#
systemctl restart nginx

[8] Access to the URL [https://(Server's Hostname or IP address)/nextcloud/] with Web browser on any Client, then following screen is displayed. Configure Administrative user account and Database connection infomation. 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] By default, recommended applications are installed.
[10] After recommended apps successfully installed, NextCloud start page is displayed.
[11] After finishing Setup, it's possible to access to NextCloud to the URL [https://(Server's Hostname or IP address)/nextcloud/].
[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.
root@dlp:~#
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',
);

root@dlp:~#
systemctl restart nginx php8.1-fpm

Matched Content