-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathrun.sh
executable file
·84 lines (64 loc) · 3.03 KB
/
run.sh
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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
#!/bin/bash
if [[ -z "$PHP_MEMORY_LIMIT" ]];
then
PHP_MEMORY_LIMIT=128M
fi
echo "Adjusting PHP memory limit to [$PHP_MEMORY_LIMIT]"
sed -i -r -e "s/^;?memory_limit =.*$/memory_limit = $PHP_MEMORY_LIMIT/g" /etc/php.ini
if [[ -z "$PHP_ERROR_REPORTING" ]];
then
PHP_ERROR_REPORTING="E_ALL \\& ~E_DEPRECATED \\& ~E_STRICT"
fi
echo "Adjusting PHP error reporting to [$PHP_ERROR_REPORTING]"
sed -i -r -e "s/^;?error_reporting =.*$/error_reporting = $PHP_ERROR_REPORTING/g" /etc/php.ini
if [[ -z "$PHP_POST_MAX_SIZE" ]];
then
PHP_POST_MAX_SIZE=8M
fi
if [[ -z "$PHP_UPLOAD_MAX_FILESIZE" ]];
then
PHP_UPLOAD_MAX_FILESIZE=8M
fi
echo "Adjusting PHP upload max file size to [$PHP_UPLOAD_MAX_FILESIZE]"
sed -i -r -e "s/^;?upload_max_filesize = .*$/upload_max_filesize = $PHP_UPLOAD_MAX_FILESIZE/g" /etc/php.ini
echo "Adjusting PHP post max size to [$PHP_POST_MAX_SIZE]"
sed -i -r -e "s/^;?post_max_size = .*$/post_max_size = $PHP_POST_MAX_SIZE/g" /etc/php.ini
if [[ -z "$PHP_MAX_EXECUTION_TIME" ]];
then
PHP_MAX_EXECUTION_TIME=30
fi
echo "Adjusting PHP max execution time to [$PHP_MAX_EXECUTION_TIME]"
sed -i -r -e "s/^;?max_execution_time = .*$/max_execution_time = $PHP_MAX_EXECUTION_TIME/g" /etc/php.ini
if [[ -z "$PHP_MAX_INPUT_VARS" ]];
then
PHP_MAX_INPUT_VARS=1000
fi
echo "Adjusting PHP max input vars to [$PHP_MAX_INPUT_VARS]"
sed -i -r -e "s/^;?max_input_vars = .*$/max_input_vars = $PHP_MAX_INPUT_VARS/g" /etc/php.ini
if [[ -z "$PHP_SESSION_SAVE_PATH" ]];
then
PHP_SESSION_SAVE_PATH="/var/lib/php/session"
fi
echo "Adjusting PHP session save path to [$PHP_SESSION_SAVE_PATH]"
sed -i -r -e "s~^;?session\.save_path = .*$~session\.save_path = $PHP_SESSION_SAVE_PATH~g" /etc/php.ini
mkdir -p $PHP_SESSION_SAVE_PATH
chown nobody: /var/lib/php -R
chown nobody: $PHP_SESSION_SAVE_PATH -R
echo "Configure Cache"
sed -i -r -e "s~^;?realpath_cache_size = .*$~realpath_cache_size = 4M~g" /etc/php.ini
sed -i -r -e "s~^;?realpath_cache_ttl = .*$~realpath_cache_ttl = 120~g" /etc/php.ini
sed -i -r -e "s~^;?expose_php = .*$~expose_php = Off~g" /etc/php.ini
sed -i -r -e "s~^;?opcache\.validate_timestamps=.*$~opcache\.validate_timestamps=1~g" /etc/php.d/10-opcache.ini
sed -i -r -e "s~^;?opcache\.revalidate_freq=.*$~opcache\.revalidate_freq=180~g" /etc/php.d/10-opcache.ini
# Removed due to (https://tideways.com/profiler/blog/fine-tune-your-opcache-configuration-to-avoid-caching-suprises)
#sed -i -r -e "s~^;?opcache\.fast_shutdown=.*$~opcache\.fast_shutdown=1~g" /etc/php.d/10-opcache.ini
sed -i -r -e "s~^;?opcache\.file_cache=.*$~opcache\.file_cache=/var/lib/php/opcache~g" /etc/php.d/10-opcache.ini
sed -i -r -e "s~^;?opcache\.file_cache_only=.*$~opcache\.file_cache_only=1~g" /etc/php.d/10-opcache.ini
sed -i -r -e "s~^;?opcache\.file_cache_consistency_checks=.*$~opcache\.file_cache_consistency_checks=1~g" /etc/php.d/10-opcache.ini
if [[ -z "$FPM_MAX_CHILDREN" ]];
then
FPM_MAX_CHILDREN=5
fi
echo "Adjusting PHP-FPM max children to [$FPM_MAX_CHILDREN]"
sed -i -r -e "s/^;?pm.max_children = .*$/pm.max_children = $FPM_MAX_CHILDREN/g" /etc/php-fpm.d/www.conf
/usr/sbin/php-fpm -F -R