fix: bypass /tmp tmpfs for file uploads by redirecting PHP upload_tmp_dir to storage partition

This commit is contained in:
Pontoporeia
2026-07-10 15:42:07 +02:00
parent 1293b1be6c
commit c1a05efcda
5 changed files with 35 additions and 4 deletions
+1
View File
@@ -4,3 +4,4 @@
- [x] Website iframe overlay: remove blur, move button to bottom-right, replace text with SVG icon + tooltip
- [x] Fix "Copier" button in logs section scrolling out of view on horizontal scroll
- [x] Remove TOC temporary debug error_log calls
- [x] Fix PeerTube upload failure: PHP /tmp tmpfs too small for large video files
@@ -0,0 +1,12 @@
; Bypass /tmp tmpfs (987MB) for large video/audio uploads.
; /tmp defaults to a small tmpfs; this points PHP's upload temp
; directory to the storage partition which has 20GB free.
upload_tmp_dir = /var/www/xamxam/storage/tmp/php-uploads
; These mirror the nginx fastcgi_param PHP_VALUE overrides
; as a belt-and-suspenders safety net.
upload_max_filesize = 8192M
post_max_size = 8192M
memory_limit = 256M
max_execution_time = 600
max_input_time = 600
@@ -0,0 +1,12 @@
; Bypass /tmp tmpfs (987MB) for large video/audio uploads.
; /tmp defaults to a small tmpfs; this points PHP's upload temp
; directory to the storage partition which has 20GB free.
upload_tmp_dir = /var/www/xamxam/storage/tmp/php-uploads
; These mirror the nginx fastcgi_param PHP_VALUE overrides
; as a belt-and-suspenders safety net.
upload_max_filesize = 8192M
post_max_size = 8192M
memory_limit = 256M
max_execution_time = 600
max_input_time = 600
+4 -4
View File
@@ -156,7 +156,7 @@ server {
fastcgi_pass unix:/var/run/php/php8.4-fpm.sock;
# Security parameters (must be <= client_max_body_size)
fastcgi_param PHP_VALUE "upload_max_filesize=8192M \n post_max_size=8192M";
fastcgi_param PHP_VALUE "upload_max_filesize=8192M \n post_max_size=8192M \n upload_tmp_dir=/var/www/xamxam/storage/tmp/php-uploads";
# Timeouts
fastcgi_read_timeout 600;
@@ -176,7 +176,7 @@ server {
location ~ \.php$ {
include snippets/fastcgi-php.conf;
fastcgi_pass unix:/var/run/php/php8.4-fpm.sock;
fastcgi_param PHP_VALUE "upload_max_filesize=8192M \n post_max_size=8192M";
fastcgi_param PHP_VALUE "upload_max_filesize=8192M \n post_max_size=8192M \n upload_tmp_dir=/var/www/xamxam/storage/tmp/php-uploads";
fastcgi_read_timeout 600;
fastcgi_send_timeout 600;
}
@@ -199,7 +199,7 @@ server {
fastcgi_param SCRIPT_FILENAME $document_root/index.php;
fastcgi_param SCRIPT_NAME /index.php;
fastcgi_pass unix:/var/run/php/php8.4-fpm.sock;
fastcgi_param PHP_VALUE "upload_max_filesize=8192M \n post_max_size=8192M";
fastcgi_param PHP_VALUE "upload_max_filesize=8192M \n post_max_size=8192M \n upload_tmp_dir=/var/www/xamxam/storage/tmp/php-uploads";
fastcgi_read_timeout 600;
fastcgi_send_timeout 600;
}
@@ -220,7 +220,7 @@ server {
fastcgi_pass unix:/var/run/php/php8.4-fpm.sock;
# Security parameters (must be <= client_max_body_size)
fastcgi_param PHP_VALUE "upload_max_filesize=8192M \n post_max_size=8192M";
fastcgi_param PHP_VALUE "upload_max_filesize=8192M \n post_max_size=8192M \n upload_tmp_dir=/var/www/xamxam/storage/tmp/php-uploads";
# Timeouts
fastcgi_read_timeout 600;
+6
View File
@@ -83,6 +83,12 @@ chown -R www-data:xamxam /var/www/xamxam/storage/cache
chmod -R 2775 /var/www/xamxam/storage/cache
ok "Cache dirs: created and owned by www-data:xamxam"
# Ensure PHP upload temp dir exists on storage partition (not /tmp tmpfs)
mkdir -p /var/www/xamxam/storage/tmp/php-uploads
chown www-data:xamxam /var/www/xamxam/storage/tmp/php-uploads
chmod 2775 /var/www/xamxam/storage/tmp/php-uploads
ok "PHP upload temp dir: /var/www/xamxam/storage/tmp/php-uploads"
# ── Step 2: Nginx config ──────────────────────────────────────────────────────
printf "\n📋 Step 2: Deploying nginx configuration...\n"
echo "--------------------------------------------"