Устанавливаем последнюю стабильную версию PHP
# apt install software-properties-common ca-certificates lsb-release apt-transport-https
# add-apt-repository ppa:ondrej/php
Обновление дистрибутива и установка необходимых для работы пакетов
# apt update && sudo apt upgrade
# apt install php8.1-fpm php8.1-gd php8.1-mysql php8.1-curl php8.1-mbstring php8.1-intl php8.1-gmp php8.1-bcmath php8.1-xml php8.1-imagick php8.1-zip php8.1-pgsql
# apt install libmagickcore-6.q16-6-extra
Скачиваем и распаковываем
# cd /root/
# wget https://download.nextcloud.com/server/releases/latest.tar.bz2
# mkdir -p /var/www/vhosts/cloud.aagt.ru
# tar -xvf ./latest.tar.bz2
# rsync -av ./nextcloud/ /var/www/vhosts/cloud.aagt.ru/
# chown -R www-data:www-data /var/www/vhosts/cloud.aagt.ru/
Конфигурация Nginx и SSL
Все достаточно типовое и уже много раз описывал.
Последовательность:
- Получаем SSL-серт от Let’s Encrypt
- Создаем пользователя и базу данных в Postgresql
Правки в файле /etc/php/8.1/fpm/pool.d/www.conf:
php_admin_value[memory_limit] = 1024M
env[PATH] = /usr/local/bin:/usr/bin:/bin
В случае переноса данных обязательно меняем владельца и права доступа на каталог с данным:
# chown -R www-data:www-data /opt/nextcloud-data/
# chmod 770 /opt/nextcloud-data
Конфигурация vhost-окружения для запуска
upstream php-handler {
server unix:/var/run/php/php8.1-fpm.sock;
}
server {
listen 80;
server_name cloud.aagt.ru;
return 301 https://$server_name$request_uri;
}
server {
listen 443 ssl http2;
server_name cloud.aagt.ru;
add_header X-Content-Type-Options nosniff;
add_header X-Frame-Options “SAMEORIGIN”;
add_header X-XSS-Protection “1; mode=block”;
add_header X-Robots-Tag none;
add_header X-Download-Options noopen;
add_header X-Permitted-Cross-Domain-Policies none;
add_header Referrer-Policy no-referrer always;
# Path to the root of your installation
root /var/www/vhosts/cloud.aagt.ru/;
access_log /var/log/nginx/cloud.aagt.ru-access.log;
error_log /var/log/nginx/cloud.aagt.ru-error.log warn;
ssl_certificate /etc/letsencrypt/live/cloud.aagt.ru/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/cloud.aagt.ru/privkey.pem;
ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem;
include /etc/letsencrypt/options-ssl-nginx.conf;
add_header Strict-Transport-Security “max-age=15768000; includeSubDomains; preload;” always;
client_max_body_size 1024M;
fastcgi_buffers 64 4K;
proxy_connect_timeout 600;
proxy_send_timeout 600;
proxy_read_timeout 600;
send_timeout 600;
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;
if ($host ~ ^www\.(?<domain>.+)$) {
return 301 $scheme://$domain$request_uri;
}
location = /robots.txt {
allow all;
}
rewrite ^/.well-known/host-meta /public.php?service=host-meta last;
rewrite ^/.well-known/host-meta.json /public.php?service=host-meta-json last;
location ^~ /.well-known {
location = /.well-known/carddav { return 301 /remote.php/dav/; }
location = /.well-known/caldav { return 301 /remote.php/dav/; }
location /.well-known/acme-challenge { try_files $uri $uri/ =404; }
location /.well-known/pki-validation { try_files $uri $uri/ =404; }
return 301 /index.php$request_uri;
}
error_page 403 /core/templates/403.php;
error_page 404 /core/templates/404.php;
location / {
rewrite ^ /index.php$uri;
}
location ~ ^/(?:build|tests|config|lib|3rdparty|templates|data)/ {
deny all;
}
location ~ ^/(?:\.|autotest|occ|issue|indie|db_|console) {
deny all;
}
location ~ ^/(?:index|remote|public|cron|core/ajax/update|status|ocs/v[12]|updater/.+|ocs-provider/.+|core/templates/40[34])\.php(?:$|/) {
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection $connection_upgrade;
include fastcgi_params;
fastcgi_split_path_info ^(.+\.php)(/.*)$;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param PATH_INFO $fastcgi_path_info;
fastcgi_param HTTPS on;
fastcgi_param modHeadersAvailable true;
fastcgi_param front_controller_active true;
fastcgi_pass php-handler;
fastcgi_intercept_errors on;
fastcgi_request_buffering off;
}
location ~ ^/(?:updater|ocs-provider)(?:$|/) {
try_files $uri/ =404;
index index.php;
}
location ~* \.(?:svg|gif|png|html|ttf|woff|ico|jpg|jpeg|js|css)$ {
try_files $uri /index.php$uri$is_args$args;
}
}
Настройка почтового сервера и региона звонков
В конфигурации config.php добавляем параметры:
‘mail_smtpmode’ => ‘smtp’,
‘mail_smtpsecure’ => ‘tls’,
‘mail_sendmailmode’ => ‘smtp’,
‘mail_from_address’ => ‘nextcloud’,
‘mail_domain’ => ‘aagt.ru’,
‘mail_smtpauthtype’ => ‘PLAIN’,
‘mail_smtpauth’ => 1,
‘mail_smtphost’ => ‘mail.bds.su’,
‘mail_smtpport’ => ’25’,
‘mail_smtpname’ => ‘nextcloud@aagt.ru’,
‘mail_smtppassword’ => ‘xxxSecretPasswordxxx’,
‘default_phone_region’ => ‘RU’,
Настройка кэширования при помощи Redis
Устанавливаем Redis-сервер и php-redis модуль:
# aptitude install redis-server php8.1-redis php8.1-apcu
Параметры кэширования в config.php:
‘memcache.local’ => ‘\OC\Memcache\APCu’,
‘memcache.distributed’ => ‘\OC\Memcache\Redis’,
‘redis’ => [
‘host’ => ‘127.0.0.1’,
‘port’ => 6379,
],