-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfix_php_fpm.sh
More file actions
executable file
·57 lines (49 loc) · 1.94 KB
/
fix_php_fpm.sh
File metadata and controls
executable file
·57 lines (49 loc) · 1.94 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
#!/bin/bash
# Fix PHP-FPM configuration for file uploads
# This script fixes common PHP-FPM settings that break file uploads
echo "Fixing PHP-FPM configuration..."
# Find all PHP versions and fix their FPM configs
for version in 8.3 8.2 8.1 8.0 7.4; do
ini_file="/etc/php/$version/fpm/php.ini"
if [ -f "$ini_file" ]; then
echo "Fixing $ini_file..."
# Fix post_max_size if it's 0
if grep -q "^post_max_size = 0" "$ini_file"; then
sed -i 's/^post_max_size = 0/post_max_size = 520M/' "$ini_file"
echo " - Fixed post_max_size (was 0)"
fi
# Ensure upload settings are reasonable (10GB for large OAR files etc)
sed -i 's/^upload_max_filesize.*/upload_max_filesize = 10G/' "$ini_file"
sed -i 's/^post_max_size.*/post_max_size = 10G/' "$ini_file"
# Ensure file_uploads is on
sed -i 's/^file_uploads = Off/file_uploads = On/' "$ini_file"
# Restart the corresponding PHP-FPM service
if systemctl is-active --quiet "php$version-fpm"; then
echo " - Restarting php$version-fpm..."
systemctl restart "php$version-fpm"
fi
fi
done
# Also fix CLI and phpdbg configs to keep them consistent
for version in 8.3 8.2 8.1 8.0 7.4; do
for sapi in cli phpdbg cgi; do
ini_file="/etc/php/$version/$sapi/php.ini"
if [ -f "$ini_file" ]; then
if grep -q "^post_max_size = 0" "$ini_file"; then
sed -i 's/^post_max_size = 0/post_max_size = 520M/' "$ini_file"
echo "Fixed $ini_file"
fi
fi
done
done
echo ""
echo "PHP-FPM configuration fixed!"
echo ""
echo "Current settings:"
for version in 8.3 8.2 8.1 8.0 7.4; do
ini_file="/etc/php/$version/fpm/php.ini"
if [ -f "$ini_file" ]; then
echo "PHP $version FPM:"
grep -E "^(post_max_size|upload_max_filesize|file_uploads)" "$ini_file" | sed 's/^/ /'
fi
done