-
-
Notifications
You must be signed in to change notification settings - Fork 112
/
ss-install-php-config.txt
653 lines (529 loc) · 25.4 KB
/
ss-install-php-config.txt
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
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
#!/bin/bash
####################################################################################################
#### author: SlickStack ############################################################################
#### link: https://slickstack.io ###################################################################
#### mirror: littlebizzy/slickstack/blob/master/bash/ss-install-php-config.txt #####################
#### path: /var/www/ss-install-php-config ##########################################################
#### destination: n/a (not a boilerplate) ##########################################################
#### purpose: Reinstalls the PHP-FPM module config files based on ss-config (idempotent) ###########
#### module version: PHP-FPM 8.3.x #################################################################
#### sourced by: ss-install ########################################################################
#### bash aliases: ss install php config ###########################################################
####################################################################################################
## SS-CONFIG MUST BE PROPERLY CONFIGURED AND ON CURRENT BUILD BEFORE RUNNING SS-INSTALL ##
## ENSURE YOUR SS-CONFIG BUILD REMAINS CURRENT BY RUNNING SS-UPDATE OCCASIONALLY ##
####################################################################################################
#### TABLE OF CONTENTS (SS-Install-PHP-Config) #####################################################
####################################################################################################
## this is a brief summary of the different code snippets you will find in this script ##
## each section should be commented so you understand what is being accomplished ##
## A. Source SS-Config + SS-Functions
## B. Touch Timestamp File
## C. Message (Begin Script)
## D. Retrieve Latest Boilerplates
## E. Configure PHP.ini Boilerplate
## F. Configure PHP-FPM.conf Boilerplate
## G. Configure WWW.conf Boilerplate
## H. Configure Opcache.ini Boilerplate
## I. Install PHP Config Files
## J. Install Adminer.php
## K. Reset Permissions (PHP Config)
## L. Restart Modules (PHP-FPM)
## M. Cleanup Temporary Files
####################################################################################################
#### A. SS-Install-Nginx-Adminer: Source SS-Config + SS-Functions ##################################
####################################################################################################
## before anything else we must source the critical variables that power this script ##
## ss-config is setup during ss-install wizard but ss-functions is hardcoded ##
## source ss-config ##
source /var/www/ss-config
## source ss-functions ##
source /var/www/ss-functions
## BELOW THIS RELIES ON SS-CONFIG AND SS-FUNCTIONS
####################################################################################################
#### B. SS-Install-PHP-Config: Touch Timestamp File ################################################
####################################################################################################
## this is a dummy timestamp file that will remember the last time this script was run ##
## it can be useful for developer reference and is sometimes used by SlickStack ##
ss_touch "${TIMESTAMP_SS_INSTALL_PHP_CONFIG}"
####################################################################################################
#### C. SS-Install-PHP-Config: Message (Begin Script) ##############################################
####################################################################################################
## this is a simple message that announces to the shell the purpose of this bash script ##
## it will only be seen by sudo users who manually run this script in the shell ##
ss_echo "${COLOR_INFO}Running ss-install-php-config... ${COLOR_RESET}"
####################################################################################################
#### D. SS-Install-PHP-Config: Retrieve Latest Boilerplates ########################################
####################################################################################################
## next we optimize the PHP-FPM configuration files based on settings from ss-config ##
## several common PHP settings are hardcoded to improve LEMP server stability ##
## ubuntu 24.04 (php 8.3) ##
if [[ "${SYSTEM_UBUNTU_VERSION}" == "24.04" ]]; then
ss_wget "${TMP_PHP_FPM_CONF}" "${GITHUB_PHP_FPM_CONF_83}"
VALIDATE_TMP_PHP_FPM_CONF=$(grep 'SS_EOF' "${TMP_PHP_FPM_CONF}" 2> /dev/null)
if [[ -z "${VALIDATE_TMP_PHP_FPM_CONF}" ]]; then
ss_wget "${TMP_PHP_FPM_CONF}" "${GITLAB_PHP_FPM_CONF_83}"
fi
ss_wget "${TMP_PHP_INI}" "${GITHUB_PHP_INI_83}"
VALIDATE_TMP_PHP_INI=$(grep 'SS_EOF' "${TMP_PHP_INI}" 2> /dev/null)
if [[ -z "${VALIDATE_TMP_PHP_INI}" ]]; then
ss_wget "${TMP_PHP_INI}" "${GITLAB_PHP_INI_83}"
fi
## opcache.ini new in php 8.3 ##
ss_wget "${TMP_OPCACHE_INI}" "${GITHUB_OPCACHE_INI_83}"
ss_wget "${TMP_WWW_CONF}" "${GITHUB_WWW_CONF_83}"
VALIDATE_TMP_WWW_CONF=$(grep 'SS_EOF' "${TMP_WWW_CONF}" 2> /dev/null)
if [[ -z "${VALIDATE_TMP_WWW_CONF}" ]]; then
ss_wget "${TMP_WWW_CONF}" "${GITLAB_WWW_CONF_83}"
fi
fi
## ubuntu 22.04 (php 8.1) ##
if [[ "${SYSTEM_UBUNTU_VERSION}" == "22.04" ]]; then
ss_wget "${TMP_PHP_FPM_CONF}" "${GITHUB_PHP_FPM_CONF_81}"
VALIDATE_TMP_PHP_FPM_CONF=$(grep 'SS_EOF' "${TMP_PHP_FPM_CONF}" 2> /dev/null)
if [[ -z "${VALIDATE_TMP_PHP_FPM_CONF}" ]]; then
ss_wget "${TMP_PHP_FPM_CONF}" "${GITLAB_PHP_FPM_CONF_81}"
fi
ss_wget "${TMP_PHP_INI}" "${GITHUB_PHP_INI_81}"
VALIDATE_TMP_PHP_INI=$(grep 'SS_EOF' "${TMP_PHP_INI}" 2> /dev/null)
if [[ -z "${VALIDATE_TMP_PHP_INI}" ]]; then
ss_wget "${TMP_PHP_INI}" "${GITLAB_PHP_INI_81}"
fi
ss_wget "${TMP_WWW_CONF}" "${GITHUB_WWW_CONF_81}"
VALIDATE_TMP_WWW_CONF=$(grep 'SS_EOF' "${TMP_WWW_CONF}" 2> /dev/null)
if [[ -z "${VALIDATE_TMP_WWW_CONF}" ]]; then
ss_wget "${TMP_WWW_CONF}" "${GITLAB_WWW_CONF_81}"
fi
fi
## ubuntu 20.04 (php 7.4) ##
if [[ "${SYSTEM_UBUNTU_VERSION}" == "20.04" ]]; then
ss_wget "${TMP_PHP_FPM_CONF}" "${GITHUB_PHP_FPM_CONF_74}"
VALIDATE_TMP_PHP_FPM_CONF=$(grep 'SS_EOF' "${TMP_PHP_FPM_CONF}" 2> /dev/null)
if [[ -z "${VALIDATE_TMP_PHP_FPM_CONF}" ]]; then
ss_wget "${TMP_PHP_FPM_CONF}" "${GITLAB_PHP_FPM_CONF_74}"
fi
ss_wget "${TMP_PHP_INI}" "${GITHUB_PHP_INI_74}"
VALIDATE_TMP_PHP_INI=$(grep 'SS_EOF' "${TMP_PHP_INI}" 2> /dev/null)
if [[ -z "${VALIDATE_TMP_PHP_INI}" ]]; then
ss_wget "${TMP_PHP_INI}" "${GITLAB_PHP_INI_74}"
fi
ss_wget "${TMP_WWW_CONF}" "${GITHUB_WWW_CONF_74}"
VALIDATE_TMP_WWW_CONF=$(grep 'SS_EOF' "${TMP_WWW_CONF}" 2> /dev/null)
if [[ -z "${VALIDATE_TMP_WWW_CONF}" ]]; then
ss_wget "${TMP_WWW_CONF}" "${GITLAB_WWW_CONF_74}"
fi
fi
## ubuntu 18.04 (php 7.2) ##
if [[ "${SYSTEM_UBUNTU_VERSION}" == "18.04" ]]; then
ss_wget "${TMP_PHP_FPM_CONF}" "${GITHUB_PHP_FPM_CONF_72}"
VALIDATE_TMP_PHP_FPM_CONF=$(grep 'SS_EOF' "${TMP_PHP_FPM_CONF}" 2> /dev/null)
if [[ -z "${VALIDATE_TMP_PHP_FPM_CONF}" ]]; then
ss_wget "${TMP_PHP_FPM_CONF}" "${GITLAB_PHP_FPM_CONF_72}"
fi
ss_wget "${TMP_PHP_INI}" "${GITHUB_PHP_INI_72}"
VALIDATE_TMP_PHP_INI=$(grep 'SS_EOF' "${TMP_PHP_INI}" 2> /dev/null)
if [[ -z "${VALIDATE_TMP_PHP_INI}" ]]; then
ss_wget "${TMP_PHP_INI}" "${GITLAB_PHP_INI_72}"
fi
ss_wget "${TMP_WWW_CONF}" "${GITHUB_WWW_CONF_72}"
VALIDATE_TMP_WWW_CONF=$(grep 'SS_EOF' "${TMP_WWW_CONF}" 2> /dev/null)
if [[ -z "${VALIDATE_TMP_WWW_CONF}" ]]; then
ss_wget "${TMP_WWW_CONF}" "${GITLAB_WWW_CONF_72}"
fi
fi
####################################################################################################
#### E. SS-Install-PHP-Config: Configure PHP.ini Boilerplate #######################################
####################################################################################################
## max execution time ##
if [[ -z "${PHP_MAX_EXECUTION_TIME}" ]]; then
ss_sed "s/@PHP_MAX_EXECUTION_TIME/60/g" "${TMP_PHP_INI}"
else
ss_sed "s/@PHP_MAX_EXECUTION_TIME/${PHP_MAX_EXECUTION_TIME}/g" "${TMP_PHP_INI}"
fi
## max input time ##
if [[ -z "${PHP_MAX_INPUT_TIME}" ]]; then
ss_sed "s/@PHP_MAX_INPUT_TIME/60/g" "${TMP_PHP_INI}"
else
ss_sed "s/@PHP_MAX_INPUT_TIME/${PHP_MAX_INPUT_TIME}/g" "${TMP_PHP_INI}"
fi
## memory limit ##
if [[ -z "${PHP_MEMORY_LIMIT}" ]]; then
ss_sed "s/@PHP_MEMORY_LIMIT/512M/g" "${TMP_PHP_INI}"
else
ss_sed "s/@PHP_MEMORY_LIMIT/${PHP_MEMORY_LIMIT}/g" "${TMP_PHP_INI}"
fi
## max input vars ##
if [[ -z "${PHP_MAX_INPUT_VARS}" ]]; then
ss_sed "s/@PHP_MAX_INPUT_VARS/5000/g" "${TMP_PHP_INI}"
else
ss_sed "s/@PHP_MAX_INPUT_VARS/${PHP_MAX_INPUT_VARS}/g" "${TMP_PHP_INI}"
fi
## max multipart body parts ##
if [[ -z "${PHP_MAX_MULTIPART_BODY_PARTS}" ]]; then
ss_sed "s/@PHP_MAX_MULTIPART_BODY_PARTS/1500/g" "${TMP_PHP_INI}"
else
ss_sed "s/@PHP_MAX_MULTIPART_BODY_PARTS/${PHP_MAX_MULTIPART_BODY_PARTS}/g" "${TMP_PHP_INI}"
fi
## max input nesting level ##
if [[ -z "${PHP_MAX_INPUT_NESTING_LEVEL}" ]]; then
ss_sed "s/@PHP_MAX_INPUT_NESTING_LEVEL/64/g" "${TMP_PHP_INI}"
else
ss_sed "s/@PHP_MAX_INPUT_NESTING_LEVEL/${PHP_MAX_INPUT_NESTING_LEVEL}/g" "${TMP_PHP_INI}"
fi
## upload max filesize ##
if [[ -z "${PHP_UPLOAD_MAX_FILESIZE}" ]]; then
ss_sed "s/@PHP_UPLOAD_MAX_FILESIZE/512M/g" "${TMP_PHP_INI}"
else
ss_sed "s/@PHP_UPLOAD_MAX_FILESIZE/${PHP_UPLOAD_MAX_FILESIZE}/g" "${TMP_PHP_INI}"
fi
## max file uploads ##
if [[ -z "${PHP_MAX_FILE_UPLOADS}" ]]; then
ss_sed "s/@PHP_MAX_FILE_UPLOADS/100/g" "${TMP_PHP_INI}"
else
ss_sed "s/@PHP_MAX_FILE_UPLOADS/${PHP_MAX_FILE_UPLOADS}/g" "${TMP_PHP_INI}"
fi
## php precision ##
if [[ -z "${PHP_PRECISION}" ]]; then
ss_sed "s/@PHP_PRECISION/14/g" "${TMP_PHP_INI}"
else
ss_sed "s/@PHP_PRECISION/${PHP_PRECISION}/g" "${TMP_PHP_INI}"
fi
## php output buffering ##
if [[ -z "${PHP_OUTPUT_BUFFERING}" ]]; then
ss_sed "s/@PHP_OUTPUT_BUFFERING/4096/g" "${TMP_PHP_INI}"
else
ss_sed "s/@PHP_OUTPUT_BUFFERING/${PHP_OUTPUT_BUFFERING}/g" "${TMP_PHP_INI}"
fi
## php unserialize max depth ##
if [[ -z "${PHP_UNSERIALIZE_MAX_DEPTH}" ]]; then
ss_sed "s/@PHP_UNSERIALIZE_MAX_DEPTH/4096/g" "${TMP_PHP_INI}"
else
ss_sed "s/@PHP_UNSERIALIZE_MAX_DEPTH/${PHP_UNSERIALIZE_MAX_DEPTH}/g" "${TMP_PHP_INI}"
fi
## php serialize precision ##
if [[ -z "${PHP_SERIALIZE_PRECISION}" ]]; then
ss_sed "s/@PHP_SERIALIZE_PRECISION/-1/g" "${TMP_PHP_INI}"
else
ss_sed "s/@PHP_SERIALIZE_PRECISION/${PHP_SERIALIZE_PRECISION}/g" "${TMP_PHP_INI}"
fi
## php allow url fopen ##
if [[ -z "${PHP_ALLOW_URL_FOPEN}" ]]; then
ss_sed "s/@PHP_ALLOW_URL_FOPEN/On/g" "${TMP_PHP_INI}"
elif [[ "${PHP_ALLOW_URL_FOPEN}" == "true" ]]; then
ss_sed "s/@PHP_ALLOW_URL_FOPEN/On/g" "${TMP_PHP_INI}"
elif [[ "${PHP_ALLOW_URL_FOPEN}" == "On" ]]; then
ss_sed "s/@PHP_ALLOW_URL_FOPEN/On/g" "${TMP_PHP_INI}"
elif [[ "${PHP_ALLOW_URL_FOPEN}" == "false" ]]; then
ss_sed "s/@PHP_ALLOW_URL_FOPEN/Off/g" "${TMP_PHP_INI}"
elif [[ "${PHP_ALLOW_URL_FOPEN}" == "Off" ]]; then
ss_sed "s/@PHP_ALLOW_URL_FOPEN/Off/g" "${TMP_PHP_INI}"
fi
## php default socket timeout ##
if [[ -z "${PHP_DEFAULT_SOCKET_TIMEOUT}" ]]; then
ss_sed "s/@PHP_DEFAULT_SOCKET_TIMEOUT/60/g" "${TMP_PHP_INI}"
else
ss_sed "s/@PHP_DEFAULT_SOCKET_TIMEOUT/${PHP_DEFAULT_SOCKET_TIMEOUT}/g" "${TMP_PHP_INI}"
fi
## php post max size ##
if [[ -z "${PHP_POST_MAX_SIZE}" ]]; then
ss_sed "s/@PHP_POST_MAX_SIZE/512M/g" "${TMP_PHP_INI}"
else
ss_sed "s/@PHP_POST_MAX_SIZE/${PHP_POST_MAX_SIZE}/g" "${TMP_PHP_INI}"
fi
## php disable classes ##
if [[ -z "${PHP_DISABLE_CLASSES}" ]]; then
ss_sed "s/@PHP_DISABLE_CLASSES//g" "${TMP_PHP_INI}"
else
ss_sed "s/@PHP_DISABLE_CLASSES/${PHP_DISABLE_CLASSES}/g" "${TMP_PHP_INI}"
fi
## php disable functions ##
if [[ -z "${PHP_DISABLE_FUNCTIONS}" ]]; then
ss_sed "s/@PHP_DISABLE_FUNCTIONS//g" "${TMP_PHP_INI}"
else
ss_sed "s/@PHP_DISABLE_FUNCTIONS/${PHP_DISABLE_FUNCTIONS}/g" "${TMP_PHP_INI}"
fi
## opcache huge code pages ##
if [[ -z "${OPCACHE_HUGE_CODE_PAGES}" ]]; then
ss_sed "s/@OPCACHE_HUGE_CODE_PAGES/0/g" "${TMP_PHP_INI}"
elif [[ "${OPCACHE_HUGE_CODE_PAGES}" == "true" ]]; then
ss_sed "s/@OPCACHE_HUGE_CODE_PAGES/1/g" "${TMP_PHP_INI}"
elif [[ "${OPCACHE_HUGE_CODE_PAGES}" == "On" ]]; then
ss_sed "s/@OPCACHE_HUGE_CODE_PAGES/1/g" "${TMP_PHP_INI}"
elif [[ "${OPCACHE_HUGE_CODE_PAGES}" == "false" ]]; then
ss_sed "s/@OPCACHE_HUGE_CODE_PAGES/0/g" "${TMP_PHP_INI}"
elif [[ "${OPCACHE_HUGE_CODE_PAGES}" == "Off" ]]; then
ss_sed "s/@OPCACHE_HUGE_CODE_PAGES/0/g" "${TMP_PHP_INI}"
fi
## opcache revalidate frequency ##
if [[ -z "${OPCACHE_REVALIDATE_FREQUENCY}" ]]; then
ss_sed "s/@OPCACHE_REVALIDATE_FREQUENCY/2/g" "${TMP_PHP_INI}"
else
ss_sed "s/@OPCACHE_REVALIDATE_FREQUENCY/${OPCACHE_REVALIDATE_FREQUENCY}/g" "${TMP_PHP_INI}"
fi
## opcache max wasted percentage ##
if [[ -z "${OPCACHE_MAX_WASTED_PERCENTAGE}" ]]; then
ss_sed "s/@OPCACHE_MAX_WASTED_PERCENTAGE/5/g" "${TMP_PHP_INI}"
else
ss_sed "s/@OPCACHE_MAX_WASTED_PERCENTAGE/${OPCACHE_MAX_WASTED_PERCENTAGE}/g" "${TMP_PHP_INI}"
fi
## opcache max accelerated files ##
if [[ -z "${OPCACHE_MAX_ACCELERATED_FILES}" ]]; then
ss_sed "s/@OPCACHE_MAX_ACCELERATED_FILES/10000/g" "${TMP_PHP_INI}"
else
ss_sed "s/@OPCACHE_MAX_ACCELERATED_FILES/${OPCACHE_MAX_ACCELERATED_FILES}/g" "${TMP_PHP_INI}"
fi
## opcache interned strings buffer ##
if [[ -z "${OPCACHE_INTERNED_STRINGS_BUFFER}" ]]; then
ss_sed "s/@OPCACHE_INTERNED_STRINGS_BUFFER/64/g" "${TMP_PHP_INI}"
else
ss_sed "s/@OPCACHE_INTERNED_STRINGS_BUFFER/${OPCACHE_INTERNED_STRINGS_BUFFER}/g" "${TMP_PHP_INI}"
fi
## opcache memory consumption ##
if [[ -z "${OPCACHE_MEMORY_CONSUMPTION}" ]]; then
ss_sed "s/@OPCACHE_MEMORY_CONSUMPTION/256/g" "${TMP_PHP_INI}"
else
ss_sed "s/@OPCACHE_MEMORY_CONSUMPTION/${OPCACHE_MEMORY_CONSUMPTION}/g" "${TMP_PHP_INI}"
fi
## newer stuff ##
## opcache preload ##
if [[ -z "${OPCACHE_PRELOAD}" ]]; then
ss_sed "s/@OPCACHE_PRELOAD/0/g" "${TMP_PHP_INI}"
else
ss_sed "s/@OPCACHE_PRELOAD/${OPCACHE_PRELOAD}/g" "${TMP_PHP_INI}"
fi
## opcache blacklist filename ##
if [[ -z "${OPCACHE_BLACKLIST_FILENAME}" ]]; then
ss_sed "s/@OPCACHE_BLACKLIST_FILENAME//g" "${TMP_PHP_INI}"
else
ss_sed "s/@OPCACHE_BLACKLIST_FILENAME/${OPCACHE_BLACKLIST_FILENAME}/g" "${TMP_PHP_INI}"
fi
####################################################################################################
#### F. SS-Install-PHP-Config: Configure PHP-FPM.conf Boilerplate ##################################
####################################################################################################
## emerg restart threshold ##
if [[ -z "${FPM_EMERGENCY_RESTART_THRESHOLD}" ]]; then
ss_sed "s/@FPM_EMERGENCY_RESTART_THRESHOLD/10/g" "${TMP_PHP_FPM_CONF}"
else
ss_sed "s/@FPM_EMERGENCY_RESTART_THRESHOLD/${FPM_EMERGENCY_RESTART_THRESHOLD}/g" "${TMP_PHP_FPM_CONF}"
fi
## emerg restart time ##
if [[ -z "${FPM_EMERGENCY_RESTART_INTERVAL}" ]]; then
ss_sed "s/@FPM_EMERGENCY_RESTART_INTERVAL/1m/g" "${TMP_PHP_FPM_CONF}"
else
ss_sed "s/@FPM_EMERGENCY_RESTART_INTERVAL/${FPM_EMERGENCY_RESTART_INTERVAL}/g" "${TMP_PHP_FPM_CONF}"
fi
## process control timeout ##
if [[ -z "${FPM_PROCESS_CONTROL_TIMEOUT}" ]]; then
ss_sed "s/@FPM_PROCESS_CONTROL_TIMEOUT/10s/g" "${TMP_PHP_FPM_CONF}"
else
ss_sed "s/@FPM_PROCESS_CONTROL_TIMEOUT/${FPM_PROCESS_CONTROL_TIMEOUT}/g" "${TMP_PHP_FPM_CONF}"
fi
## process max ##
if [[ -z "${FPM_PROCESS_MAX}" ]]; then
ss_sed "s/@FPM_PROCESS_MAX/128/g" "${TMP_PHP_FPM_CONF}"
else
ss_sed "s/@FPM_PROCESS_MAX/${FPM_PROCESS_MAX}/g" "${TMP_PHP_FPM_CONF}"
fi
## process priority ##
if [[ -z "${FPM_PROCESS_PRIORITY}" ]]; then
ss_sed "s/@FPM_PROCESS_PRIORITY/-19/g" "${TMP_PHP_FPM_CONF}"
else
ss_sed "s/@FPM_PROCESS_PRIORITY/${FPM_PROCESS_PRIORITY}/g" "${TMP_PHP_FPM_CONF}"
fi
## rlimit files ##
if [[ -z "${FPM_RLIMIT_FILES}" ]]; then
ss_sed "s/@FPM_RLIMIT_FILES/1024/g" "${TMP_PHP_FPM_CONF}"
else
ss_sed "s/@FPM_RLIMIT_FILES/${FPM_RLIMIT_FILES}/g" "${TMP_PHP_FPM_CONF}"
fi
## rlimit core ##
if [[ -z "${FPM_RLIMIT_CORE}" ]]; then
ss_sed "s/@FPM_RLIMIT_CORE/0/g" "${TMP_PHP_FPM_CONF}"
else
ss_sed "s/@FPM_RLIMIT_CORE/${FPM_RLIMIT_CORE}/g" "${TMP_PHP_FPM_CONF}"
fi
## systemd interval ##
if [[ -z "${FPM_SYSTEMD_INTERVAL}" ]]; then
ss_sed "s/@FPM_SYSTEMD_INTERVAL/10/g" "${TMP_PHP_FPM_CONF}"
else
ss_sed "s/@FPM_SYSTEMD_INTERVAL/${FPM_SYSTEMD_INTERVAL}/g" "${TMP_PHP_FPM_CONF}"
fi
####################################################################################################
#### G. SS-Install-PHP-Config: Configure WWW.conf Boilerplate ######################################
####################################################################################################
## pool listen backlog ##
if [[ -z "${WWW_LISTEN_BACKLOG}" ]]; then
ss_sed "s/@WWW_LISTEN_BACKLOG/65535/g" "${TMP_WWW_CONF}"
else
ss_sed "s/@WWW_LISTEN_BACKLOG/${WWW_LISTEN_BACKLOG}/g" "${TMP_WWW_CONF}"
fi
## pool type ##
if [[ -z "${WWW_PM_MODE}" ]]; then
ss_sed "s/@WWW_PM_MODE/ondemand/g" "${TMP_WWW_CONF}"
else
ss_sed "s/@WWW_PM_MODE/${WWW_PM_MODE}/g" "${TMP_WWW_CONF}"
fi
## pool max children ##
if [[ -z "${WWW_PM_MAX_CHILDREN}" ]]; then
ss_sed "s/@WWW_PM_MAX_CHILDREN/20/g" "${TMP_WWW_CONF}"
else
ss_sed "s/@WWW_PM_MAX_CHILDREN/${WWW_PM_MAX_CHILDREN}/g" "${TMP_WWW_CONF}"
fi
## pool start servers ##
if [[ -z "${WWW_PM_START_SERVERS}" ]]; then
ss_sed "s/@WWW_PM_START_SERVERS/2/g" "${TMP_WWW_CONF}"
else
ss_sed "s/@WWW_PM_START_SERVERS/${WWW_PM_START_SERVERS}/g" "${TMP_WWW_CONF}"
fi
## pool min spare servers ##
if [[ -z "${WWW_PM_MIN_SPARE_SERVERS}" ]]; then
ss_sed "s/@WWW_PM_MIN_SPARE_SERVERS/1/g" "${TMP_WWW_CONF}"
else
ss_sed "s/@WWW_PM_MIN_SPARE_SERVERS/${WWW_PM_MIN_SPARE_SERVERS}/g" "${TMP_WWW_CONF}"
fi
## pool max spare servers ##
if [[ -z "${WWW_PM_MAX_SPARE_SERVERS}" ]]; then
ss_sed "s/@WWW_PM_MAX_SPARE_SERVERS/3/g" "${TMP_WWW_CONF}"
else
ss_sed "s/@WWW_PM_MAX_SPARE_SERVERS/${WWW_PM_MAX_SPARE_SERVERS}/g" "${TMP_WWW_CONF}"
fi
## pool max spawn rate ##
if [[ -z "${WWW_PM_MAX_SPAWN_RATE}" ]]; then
ss_sed "s/@WWW_PM_MAX_SPAWN_RATE/32/g" "${TMP_WWW_CONF}"
else
ss_sed "s/@WWW_PM_MAX_SPAWN_RATE/${WWW_PM_MAX_SPAWN_RATE}/g" "${TMP_WWW_CONF}"
fi
## pool process idle timeout ##
if [[ -z "${WWW_PM_PROCESS_IDLE_TIMEOUT}" ]]; then
ss_sed "s/@WWW_PM_PROCESS_IDLE_TIMEOUT/10s/g" "${TMP_WWW_CONF}"
else
ss_sed "s/@WWW_PM_PROCESS_IDLE_TIMEOUT/${WWW_PM_PROCESS_IDLE_TIMEOUT}/g" "${TMP_WWW_CONF}"
fi
## pool max requests ##
if [[ -z "${WWW_PM_MAX_REQUESTS}" ]]; then
ss_sed "s/@WWW_PM_MAX_REQUESTS/500/g" "${TMP_WWW_CONF}"
else
ss_sed "s/@WWW_PM_MAX_REQUESTS/${WWW_PM_MAX_REQUESTS}/g" "${TMP_WWW_CONF}"
fi
## pool request terminate timeout ##
if [[ -z "${WWW_REQUEST_TERMINATE_TIMEOUT}" ]]; then
ss_sed "s/@WWW_REQUEST_TERMINATE_TIMEOUT/300/g" "${TMP_WWW_CONF}"
else
ss_sed "s/@WWW_REQUEST_TERMINATE_TIMEOUT/${WWW_REQUEST_TERMINATE_TIMEOUT}/g" "${TMP_WWW_CONF}"
fi
## pool rlimit files ##
if [[ -z "${WWW_RLIMIT_FILES}" ]]; then
ss_sed "s/@WWW_RLIMIT_FILES/65535/g" "${TMP_WWW_CONF}"
else
ss_sed "s/@WWW_RLIMIT_FILES/${WWW_RLIMIT_FILES}/g" "${TMP_WWW_CONF}"
fi
## pool rlimit core ##
if [[ -z "${WWW_RLIMIT_CORE}" ]]; then
ss_sed "s/@WWW_RLIMIT_CORE/0/g" "${TMP_WWW_CONF}"
else
ss_sed "s/@WWW_RLIMIT_CORE/${WWW_RLIMIT_CORE}/g" "${TMP_WWW_CONF}"
fi
####################################################################################################
#### H. SS-Install-PHP-Config: Configure Opcache.ini Boilerplate ###################################
####################################################################################################
## ubuntu 24.04 (php 8.3) ##
if [[ "${SYSTEM_UBUNTU_VERSION}" == "24.04" ]]; then
if [[ -z "${OPCACHE_JIT_CRTO}" ]]; then
ss_sed "s/@OPCACHE_JIT_CRTO/1255/g" "${TMP_OPCACHE_INI}"
else
ss_sed "s/@OPCACHE_JIT_CRTO/${OPCACHE_JIT_CRTO}/g" "${TMP_OPCACHE_INI}"
fi
if [[ -z "${OPCACHE_JIT_BUFFER_SIZE}" ]]; then
ss_sed "s/@OPCACHE_JIT_BUFFER_SIZE/0/g" "${TMP_OPCACHE_INI}"
else
ss_sed "s/@OPCACHE_JIT_BUFFER_SIZE/${OPCACHE_JIT_BUFFER_SIZE}/g" "${TMP_OPCACHE_INI}"
fi
fi
####################################################################################################
#### I. SS-Install-PHP-Config: Install PHP Config Files ############################################
####################################################################################################
## note: ss_cp must be used for the ini files because ss_mv not working for some reason ##
## ubuntu 24.04 (php 8.3) ##
if [[ "${SYSTEM_UBUNTU_VERSION}" == "24.04" ]]; then
ss_mv "${TMP_PHP_FPM_CONF}" "${PATH_PHP_FPM_CONF_83}"
ss_cp "${TMP_PHP_INI}" "${PATH_PHP_INI_FPM_83}"
ss_cp "${TMP_PHP_INI}" "${PATH_PHP_INI_CLI_83}"
ss_mv "${TMP_WWW_CONF}" "${PATH_WWW_CONF_83}"
## php 8.3 only ##
ss_mv "${TMP_OPCACHE_INI}" /etc/php/8.3/mods-available/opcache.ini
fi
## ubuntu 22.04 (php 8.1) ##
if [[ "${SYSTEM_UBUNTU_VERSION}" == "22.04" ]]; then
ss_mv "${TMP_PHP_FPM_CONF}" "${PATH_PHP_FPM_CONF_81}"
ss_cp "${TMP_PHP_INI}" "${PATH_PHP_INI_FPM_81}"
ss_cp "${TMP_PHP_INI}" "${PATH_PHP_INI_CLI_81}"
ss_mv "${TMP_WWW_CONF}" "${PATH_WWW_CONF_81}"
fi
## ubuntu 20.04 (php 7.4) ##
if [[ "${SYSTEM_UBUNTU_VERSION}" == "20.04" ]]; then
ss_mv "${TMP_PHP_FPM_CONF}" "${PATH_PHP_FPM_CONF_74}"
ss_cp "${TMP_PHP_INI}" "${PATH_PHP_INI_FPM_74}"
ss_cp "${TMP_PHP_INI}" "${PATH_PHP_INI_CLI_74}"
ss_mv "${TMP_WWW_CONF}" "${PATH_WWW_CONF_74}"
fi
## ubuntu 18.04 (php 7.2) ##
if [[ "${SYSTEM_UBUNTU_VERSION}" == "18.04" ]]; then
ss_mv "${TMP_PHP_FPM_CONF}" "${PATH_PHP_FPM_CONF_72}"
ss_cp "${TMP_PHP_INI}" "${PATH_PHP_INI_FPM_72}"
ss_cp "${TMP_PHP_INI}" "${PATH_PHP_INI_CLI_72}"
ss_mv "${TMP_WWW_CONF}" "${PATH_WWW_CONF_72}"
fi
####################################################################################################
#### J. SS-Install-PHP-Config: Install Adminer.php #################################################
####################################################################################################
## here we retrieve the latest version of adminer.php from our mirrors and install it ##
## note that adminer.php cannot be converted to UTF-8 or else it will break ##
## retrieve adminer.php ##
ss_wget "${TMP_ADMINER_PHP}" "${GITHUB_ADMINER_PHP}"
VALIDATE_TMP_ADMINER_PHP=$(grep 'Jakub Vrana' "${TMP_ADMINER_PHP}" 2> /dev/null)
if [[ -z "${VALIDATE_TMP_ADMINER_PHP}" ]]; then
ss_wget "${TMP_ADMINER_PHP}" "${GITLAB_ADMINER_PHP}"
fi
## install adminer.php ##
VALIDATE2_TMP_ADMINER_PHP=$(grep 'Jakub Vrana' "${TMP_ADMINER_PHP}" 2> /dev/null)
if [[ -n "${VALIDATE2_TMP_ADMINER_PHP}" ]]; then
if [[ "${ADMINER_PUBLIC}" == "false" ]]; then
ss_rm "${PATH_ADMINER_PHP}"
ss_echo "${COLOR_WARN}Skipping install of adminer.php because ADMINER_PUBLIC set to false... ${COLOR_RESET}"
else
ss_mv "${TMP_ADMINER_PHP}" "${PATH_ADMINER_PHP}"
fi
fi
####################################################################################################
#### K. SS-Install-PHP-Config: Reset Permissions (PHP Config) ######################################
####################################################################################################
source "${PATH_SS_PERMS_PHP_CONFIG}"
####################################################################################################
#### L. SS-Install-PHP-Config: Restart Modules (PHP-FPM) ###########################################
####################################################################################################
source "${PATH_SS_RESTART_PHP}"
####################################################################################################
#### M. SS-Install-PHP-Config: Cleanup Temporary Files #############################################
####################################################################################################
ss_rm "${TMP_PHP_FPM_CONF}"
ss_rm "${TMP_PHP_INI}"
ss_rm "${TMP_WWW_CONF}"
####################################################################################################
#### SlickStack: Reset Permissions (SlickStack Scripts) ############################################
####################################################################################################
## we include this permissions reset in all cron jobs and bash scripts for redundancy ##
## chmod 0700 means only the root/sudo users can execute any SlickStack scripts ##
## THIS SNIPPET DOES NOT RELY ON SS-CONFIG OR SS-FUNCTIONS
## SNIPPET: ss bash scripts, ss cron jobs
## UPDATED: 02JUL2022
chown root:root /var/www/ss* ## must be root:root
chown root:root /var/www/crons/*cron* ## must be root:root
chown root:root /var/www/crons/custom/*cron* ## must be root:root
chmod 0700 /var/www/ss* ## 0700 means only root/sudo can execute
chmod 0700 /var/www/crons/*cron* ## 0700 means only root/sudo can execute
chmod 0700 /var/www/crons/custom/*cron* ## 0700 means only root/sudo can execute
####################################################################################################
#### SlickStack: External References Used To Improve This Script (Thanks, Interwebz) ###############
####################################################################################################
## Ref:
## SS_EOF