-
-
Notifications
You must be signed in to change notification settings - Fork 159
/
php_configure.inc
2520 lines (2408 loc) · 117 KB
/
php_configure.inc
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
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
max_spawn_rate_check() {
if [[ "$CENTOS_SEVEN" -eq '7' && ! "$(grep 'pm.max_spawn_rate' /usr/local/etc/php-fpm.conf)" ]] && [[ "$PHPMVER" = '8.1' && "$INITIALINSTALL" = [yY] ]]; then
if [[ "$FPM_MAX_SPAWN_RATE" -ge '32' && -f /usr/local/etc/php-fpm.conf ]]; then
echo
echo "adjust PHP 8.1.x pm.max_spawn_rate for /usr/local/etc/php-fpm.conf"
sed -i "s|^pm.max_children|pm.max_spawn_rate = $FPM_MAX_SPAWN_RATE\npm.max_children|" /usr/local/etc/php-fpm.conf
grep 'pm.max_spawn_rate' /usr/local/etc/php-fpm.conf
echo
fi
elif [[ "$CENTOS_SEVEN" -eq '7' && ! "$(grep 'pm.max_spawn_rate' /usr/local/etc/php-fpm.conf)" ]] && [[ "$PHPMUVER" = '8.1' && "$INITIALINSTALL" != [yY] ]]; then
if [[ "$FPM_MAX_SPAWN_RATE" -ge '32' && -f /usr/local/etc/php-fpm.conf ]]; then
echo
echo "adjust PHP 8.1.x pm.max_spawn_rate for /usr/local/etc/php-fpm.conf"
sed -i "s|^pm.max_children|pm.max_spawn_rate = $FPM_MAX_SPAWN_RATE\npm.max_children|" /usr/local/etc/php-fpm.conf
grep 'pm.max_spawn_rate' /usr/local/etc/php-fpm.conf
echo
fi
elif [[ "$CENTOS_SEVEN" -eq '7' && "$(grep 'pm.max_spawn_rate' /usr/local/etc/php-fpm.conf)" ]] && [[ "$PHPMUVER" != '8.1' && "$INITIALINSTALL" != [yY] ]]; then
echo
echo "remove unsupported pm.max_spawn_rate from /usr/local/etc/php-fpm.conf"
sed -i "/pm.max_spawn_rate/d" /usr/local/etc/php-fpm.conf
grep 'pm.max_spawn_rate' /usr/local/etc/php-fpm.conf
echo
fi
}
pgo_version_edit() {
if [[ "$PHP_PGO_APPEND_LABEL" = [yY] ]]; then
echo "---------------------------"
echo "PGO binary labelling"
echo "---------------------------"
if [[ "$PHP_PGO" = [yY] ]]; then
# modifying php -v command to add PGO indicator
# allowing end users to easily see if PHP-FPM
# was built with PGO or not
if [ -f ../sapi/cgi/cgi_main.c ]; then
echo "append PGO label to php-cgi binary version"
sed -i 's|PHP %s (%s) (built: %s %s)|PHP %s (%s) (built: %s %s) PGO|g' ../sapi/cgi/cgi_main.c
else
echo "../sapi/cgi/cgi_main.c not found"
pwd
ls -lah ../sapi/cgi/cgi_main.c
fi
if [ -f ../sapi/cli/php_cli.c ]; then
echo "append PGO label to php cli binary version"
sed -i 's|PHP %s (%s) (built: %s %s)|PHP %s (%s) (built: %s %s) PGO|g' ../sapi/cli/php_cli.c
else
echo "../sapi/cli/php_cli.c not found"
pwd
ls -lah ../sapi/cli/php_cli.c
fi
if [ -f ../sapi/fpm/fpm/fpm_main.c ]; then
echo "append PGO label to php-fpm binary version"
sed -i 's|PHP %s (%s) (built: %s %s)|PHP %s (%s) (built: %s %s) PGO|g' ../sapi/fpm/fpm/fpm_main.c
else
echo "../sapi/fpm/fpm/fpm_main.c not found"
pwd
ls -lah ../sapi/fpm/fpm/fpm_main.c
fi
else
if [ -f ../sapi/cgi/cgi_main.c ]; then
echo "remove PGO label to php-cgi binary version"
sed -i 's|PHP %s (%s) (built: %s %s) PGO|PHP %s (%s) (built: %s %s)|g' ../sapi/cgi/cgi_main.c
else
echo "../sapi/cgi/cgi_main.c not found"
pwd
ls -lah ../sapi/cgi/cgi_main.c
fi
if [ -f ../sapi/cli/php_cli.c ]; then
echo "remove PGO label to php cli binary version"
sed -i 's|PHP %s (%s) (built: %s %s) PGO|PHP %s (%s) (built: %s %s)|g' ../sapi/cli/php_cli.c
else
echo "../sapi/cli/php_cli.c not found"
pwd
ls -lah ../sapi/cli/php_cli.c
fi
if [ -f ../sapi/fpm/fpm/fpm_main.c ]; then
echo "remove PGO label to php-fpm binary version"
sed -i 's|PHP %s (%s) (built: %s %s) PGO|PHP %s (%s) (built: %s %s)|g' ../sapi/fpm/fpm/fpm_main.c
else
echo "../sapi/fpm/fpm/fpm_main.c not found"
pwd
ls -lah ../sapi/fpm/fpm/fpm_main.c
fi
fi
echo
fi
}
php_pcrejit_stacksize() {
if [[ "$PHP_PCREJIT_STACKSIZE_ADJUST" = [yY] ]]; then
pushd ../
get_php_pcrejit_stacksize=$(awk '/#define PCRE_JIT_STACK_MAX_SIZE/ {print $3}' ext/pcre/php_pcre.c | sed -e 's|(||g')
echo "existing PHP PCRE_JIT_STACK_MAX_SIZE = $get_php_pcrejit_stacksize * 1024"
if [[ "$get_php_pcrejit_stacksize" -eq '64' || "$get_php_pcrejit_stacksize" -eq '192' || "$get_php_pcrejit_stacksize" -eq '256' ]] && [ -f ext/pcre/php_pcre.c ]; then
# only change if php 7.2 (64) or 7.3 (192) or 7.4 (256) defaults are for
# PHP 7+ PCRE JIT when pcre.jit=1 enabled https://www.php.net/manual/en/pcre.configuration.php
grep -w 'PCRE_JIT_STACK_MAX_SIZE' ext/pcre/php_pcre.c
echo
sed -i "s|#define PCRE_JIT_STACK_MAX_SIZE .*|#define PCRE_JIT_STACK_MAX_SIZE ($PHP_PCREJIT_STACKSIZE * 1024)|" ext/pcre/php_pcre.c
echo
grep -w 'PCRE_JIT_STACK_MAX_SIZE' ext/pcre/php_pcre.c
echo
fi
popd
fi
}
pgophpbench() {
echo
echo "PGO phpbench setup start"
rm -rf "${DIR_TMP}/phpbench"
mkdir -p "${DIR_TMP}/phpbench" /opt/phpbench
wget${ipv_forceopt_wget} -O "${DIR_TMP}/phpbench/phpbench-0.8.1.zip" https://github.com/centminmod/centminmod-php71/raw/master/scripts/phpbench-0.8.1.zip
wget${ipv_forceopt_wget} -O /opt/phpbench/detailed_benchmark.php https://github.com/centminmod/centminmod-php71/raw/master/scripts/detailed_benchmark.php
pushd "${DIR_TMP}/phpbench"
unzip phpbench-0.8.1.zip
\cp -af tests /opt/phpbench/tests
popd
echo "PGO phpbench setup end"
echo
}
oniguruma_check() {
if [[ "$(rpm -qa oniguruma5 oniguruma5-devel | wc -l)" -eq '2' ]]; then
echo
echo "swap oniguruma5 oniguruma5php"
echo
yum -y swap oniguruma5 oniguruma5php --enablerepo=remi
echo
echo "swap oniguruma5-devel oniguruma5php-devel"
echo
yum -y swap oniguruma5-devel oniguruma5php-devel --enablerepo=remi
fi
if [[ "$(rpm -qa oniguruma5php oniguruma5php-devel | wc -l)" -lt '2' ]]; then
echo
echo "install oniguruma5php oniguruma5php-devel"
echo
yum -y install oniguruma5php oniguruma5php-devel --enablerepo=remi
fi
}
function funct_phpconfigure {
# set locale temporarily to english
# for php compile due to some non-english
# locale compilation issues i.e. Turkish
export LC_ALL=en_US.UTF-8
export LANG=en_US.UTF-8
export LANGUAGE=en_US.UTF-8
export LC_CTYPE=en_US.UTF-8
# debugging
# echo "CM_INSTALLDIR=${CM_INSTALLDIR}"
# exit
if [ -f "${CM_INSTALLDIR}/inc/custom_config.inc" ]; then
if [ -f /usr/bin/dos2unix ]; then
dos2unix -q "inc/custom_config.inc"
fi
source "inc/custom_config.inc"
if [ -d "${CENTMINLOGDIR}" ]; then
cat "inc/custom_config.inc" > "${CENTMINLOGDIR}/inc-custom-config-settings_${DT}.log"
fi
fi
if [ -f "${CONFIGSCANBASE}/custom_config.inc" ]; then
# default is at /etc/centminmod/custom_config.inc
if [ -f /usr/bin/dos2unix ]; then
dos2unix -q "${CONFIGSCANBASE}/custom_config.inc"
fi
source "${CONFIGSCANBASE}/custom_config.inc"
if [ -d "${CENTMINLOGDIR}" ]; then
cat "${CONFIGSCANBASE}/custom_config.inc" > "${CENTMINLOGDIR}/etc-centminmod-custom-config-settings_${DT}.log"
fi
fi
if [ -f "${CM_INSTALLDIR}/inc/z_custom.inc" ]; then
if [ -f /usr/bin/dos2unix ]; then
dos2unix -q "${CM_INSTALLDIR}/inc/z_custom.inc"
fi
source "${CM_INSTALLDIR}/inc/z_custom.inc"
if [ -d "${CENTMINLOGDIR}" ]; then
cat "${CM_INSTALLDIR}/inc/z_custom.inc" > "${CENTMINLOGDIR}/inc-zcustom-config-settings_${DT}.log"
fi
fi
fpmconfdir
if [[ "$FORCE_IPVFOUR" != [yY] ]]; then
ipv_forceopt=""
ipv_forceopt_wget=""
WGETOPT="-cnv --no-dns-cache${ipv_forceopt_wget}"
else
ipv_forceopt='4'
ipv_forceopt_wget=' -4'
WGETOPT="-cnv --no-dns-cache${ipv_forceopt_wget}"
fi
#############################################################
TOTALMEM=$(awk '/MemTotal/ {print $2}' /proc/meminfo)
TOTALSWAPMEM=$(awk '/SwapTotal: / {print $2}' /proc/meminfo | head -n1)
ISLOWMEMPHP='780000'
#############################################################
# Formulas
TOTALMEMMB=`echo "scale=0;$TOTALMEM/1024" | bc`
ISLOWMEMPHPMB=`echo "scale=0;$ISLOWMEMPHP/1024" | bc`
CHECKLOWMEMPHP=`expr $TOTALMEM \< $ISLOWMEMPHP`
#############################################################
PLIBDIR='/usr'
PHPMVER=$(echo "$PHP_VERSION" | cut -d . -f1,2)
echo "PHP configure stage"
echo
# compiling PHP with LTO support takes 2-4x times the memory
# and cpu resources to do and takes 2-4x times longer to compile
# so only do it for servers with enough cpu cores and memory
CPUS_LTO=$(grep -c "processor" /proc/cpuinfo)
if [[ "$CPUS_LTO" -lt '16' && "$TOTALMEMMB" -lt '31000' ]]; then
PHP_LTO='n'
elif [[ "$CPUS_LTO" -lt '16' && "$TOTALMEMMB" -gt '31000' ]]; then
PHP_LTO='n'
fi
install_libgd_external() {
# using --with-external-gd flag only supported in PHP 7.4+ and PHP 8.0+
if [[ "$CENTOS_SEVEN" -eq '7' && "$PHP_LIBGD_EXTERNAL" = [yY] ]] && [[ "$PHPMVER" = '7.0' || "$PHPMUVER" = '7.0' || "$PHPMVER" = '7.1' || "$PHPMUVER" = '7.1' || "$PHPMVER" = '7.2' || "$PHPMUVER" = '7.2' || "$PHPMVER" = '7.3' || "$PHPMUVER" = '7.3' || "$PHPMVER" = '7.4' || "$PHPMUVER" = '7.4' || "$PHPMVER" = '8.0' || "$PHPMUVER" = '8.0' || "$PHPMVER" = '8.1' || "$PHPMUVER" = '8.1' || "$PHPVER_ID" -ge '80000' ]]; then
echo
echo "Internal libgd ${LIBGD_EXTERNAL_VER} external PHP version"
echo
pushd "$DIR_TMP"
if [ ! -f "libgd-${LIBGD_EXTERNAL_VER}.tar.gz" ]; then
wget${ipv_forceopt_wget} "https://github.com/libgd/libgd/releases/download/gd-${LIBGD_EXTERNAL_VER}/libgd-${LIBGD_EXTERNAL_VER}.tar.gz"
tar xvfz "libgd-${LIBGD_EXTERNAL_VER}.tar.gz"
fi
cd "libgd-${LIBGD_EXTERNAL_VER}"
if [[ "$LIBGD_EXTERNAL_VER" = '2.3.3' ]]; then
wget${ipv_forceopt_wget} https://github.com/libgd/libgd/commit/f4bc1f5c26925548662946ed7cfa473c190a104a.patch -O gdflip.patch
patch -p1 < gdflip.patch
fi
make clean
./configure --prefix="/usr/local/libgd/${LIBGD_EXTERNAL_VER}"
make -j$(nproc)
make install
check_libgd_external=$?
if [[ "$check_libgd_external" -eq '0' ]]; then
echo "export GDLIB_CFLAGS='-I/usr/local/libgd/${LIBGD_EXTERNAL_VER}/include'"
export GDLIB_CFLAGS="-I/usr/local/libgd/${LIBGD_EXTERNAL_VER}/include"
echo "export GDLIB_LIBS='-L/usr/local/libgd/${LIBGD_EXTERNAL_VER}/lib -lgd'"
export GDLIB_LIBS="-L/usr/local/libgd/${LIBGD_EXTERNAL_VER}/lib -lgd"
# if [[ "$PHPMVER" = '7.0' || "$PHPMUVER" = '7.0' || "$PHPMVER" = '7.1' || "$PHPMUVER" = '7.1' || "$PHPMVER" = '7.2' || "$PHPMUVER" = '7.2' || "$PHPMVER" = '7.3' || "$PHPMUVER" = '7.3' ]]; then
# echo "export LD_LIBRARY_PATH=/usr/local/libgd/${LIBGD_EXTERNAL_VER}/lib:$LD_LIBRARY_PATH"
# export LD_LIBRARY_PATH=/usr/local/libgd/${LIBGD_EXTERNAL_VER}/lib:$LD_LIBRARY_PATH
# echo "export PKG_CONFIG_PATH=/usr/local/libgd/${LIBGD_EXTERNAL_VER}/lib/pkgconfig:/usr/local/lib/pkgconfig:/usr/lib64/pkgconfig:/usr/share/pkgconfig:$PKG_CONFIG_PATH"
# export PKG_CONFIG_PATH=/usr/local/libgd/${LIBGD_EXTERNAL_VER}/lib/pkgconfig:/usr/local/lib/pkgconfig:/usr/lib64/pkgconfig:/usr/share/pkgconfig:$PKG_CONFIG_PATH
# fi
fi
# ls -lAhR "/usr/local/libgd/${LIBGD_EXTERNAL_VER}"
# PKG_CONFIG_PATH="/usr/local/libgd/${LIBGD_EXTERNAL_VER}/lib/pkgconfig" pkg-config --modversion gdlib
# PKG_CONFIG_PATH="/usr/local/libgd/${LIBGD_EXTERNAL_VER}/lib/pkgconfig" pkg-config gdlib --cflags
# PKG_CONFIG_PATH="/usr/local/libgd/${LIBGD_EXTERNAL_VER}/lib/pkgconfig" pkg-config gdlib --libs
popd
fi
}
if [[ "$CENTOS_SEVEN" -eq '7' && "$PHPSWOOLE" = [yY] ]] && [[ "$PHPMVER" = '7.0' || "$PHPMUVER" = '7.0' || "$PHPMVER" = '7.1' || "$PHPMUVER" = '7.1' || "$PHPMVER" = '7.2' || "$PHPMUVER" = '7.2' || "$PHPMVER" = '7.3' || "$PHPMUVER" = '7.3' || "$PHPMVER" = '7.4' || "$PHPMUVER" = '7.4' || "$PHPMVER" = '8.0' || "$PHPMUVER" = '8.0' || "$PHPMVER" = '8.1' || "$PHPMUVER" = '8.1' || "$PHPVER_ID" -ge '80000' ]]; then
SWOOLE_OPT=' --with-swoole'
else
SWOOLE_OPT=""
fi
# Enable Foreign Function Interface FFI extension
# for PHP 7.4+ https://wiki.php.net/rfc/ffi
if [[ "$CENTOS_SEVEN" -eq '7' ]] && [[ "$PHPMVER" = '7.4' || "$PHPMUVER" = '7.4' || "$PHPMVER" = '8.0' || "$PHPMUVER" = '8.0' || "$PHPMVER" = '8.1' || "$PHPMUVER" = '8.1' || "$PHPVER_ID" -ge '80000' ]]; then
if [[ -z "$(rpm -qa libffi-devel)" ]]; then
yum -q -y install libffi-devel
fi
FFI_OPT=' --with-ffi'
else
FFI_OPT=""
fi
# enable CentOS 7 systemd integration for PHP-FPM versions 5.5 and higher
# http://www.php.net/ChangeLog-5.php#5.5.0
if [[ "$CENTOS_SEVEN" -eq '7' ]]; then
if [[ "$PHPMVER" = 5.5 || "$PHPMUVER" = 5.5 || "$PHPMVER" = 5.6 || "$PHPMUVER" = 5.6 || "$PHPMVER" = 7.0 || "$PHPMUVER" = 7.0 || "$PHPMVER" = 7.1 || "$PHPMUVER" = 7.1 || "$PHPMVER" = 7.2 || "$PHPMUVER" = 7.2 || "$PHPMVER" = 7.3 || "$PHPMUVER" = 7.3 || "$PHPMVER" = 7.4 || "$PHPMUVER" = 7.4 || "$PHPMVER" = 7.5 || "$PHPMUVER" = 7.5 || "$PHPMVER" = 8.0 || "$PHPMUVER" = 8.0 || "$PHPMVER" = 8.1 || "$PHPMUVER" = 8.1 || "$PHPVER_ID" -ge '80000' ]]; then
if [[ $(rpm -q systemd-devel >/dev/null 2>&1; echo $?) != '0' ]]; then
yum -y -q install systemd-devel >/dev/null 2>&1
fi
FPMSYSTEMD_INTEGRATEOPT=' --with-fpm-systemd'
else
FPMSYSTEMD_INTEGRATEOPT=""
fi
else
FPMSYSTEMD_INTEGRATEOPT=""
fi
# Disabled by default as currently PHP seems to fail to
# compile some of the PHP extensions with GCC 8
# if [[ "$DEVTOOLSETEIGHT" = [yY] ]]; then
# DEVTOOLSETEIGHT='n'
# fi
# If PHP 5.3 detected disable PHP EMBED SAPI
# https://community.centminmod.com/posts/63877/
if [[ "$PHPMVER" = 5.3 || "$PHPMUVER" = 5.3 ]]; then
PHPEMBED='n'
GCCINTEL_PHP='n'
fi
# separate make threads for PHP compiles
if [ -f /proc/user_beancounters ]; then
# CPUS='1'
# MAKETHREADS_PHP=" -j$CPUS"
# speed up make
CPUS_MAKEPHP=$(grep -c "processor" /proc/cpuinfo)
if [[ "$(grep -o 'AMD EPYC 7601' /proc/cpuinfo | sort -u)" = 'AMD EPYC 7601' ]]; then
# 7601 at 12 cpu cores has 3.20hz clock frequency https://en.wikichip.org/wiki/amd/epyc/7601
# while greater than 12 cpu cores downclocks to 2.70Ghz
CPUS_MAKEPHP=12
elif [[ "$(grep -o 'AMD EPYC 7551' /proc/cpuinfo | sort -u)" = 'AMD EPYC 7551' ]]; then
# 7551P at 12 cpu cores has 3.0Ghz clock frequency https://en.wikichip.org/wiki/amd/epyc/7551p
# while greater than 12 cpu cores downclocks to 2.55Ghz
CPUS_MAKEPHP=12
elif [[ "$(grep -o 'AMD EPYC 7401' /proc/cpuinfo | sort -u)" = 'AMD EPYC 7401' ]]; then
# 7401P at 12 cpu cores has 3.0Ghz clock frequency https://en.wikichip.org/wiki/amd/epyc/7401p
# while greater than 12 cpu cores downclocks to 2.8Ghz
CPUS_MAKEPHP=12
elif [[ "$(grep -o 'AMD EPYC 7371' /proc/cpuinfo | sort -u)" = 'AMD EPYC 7371' ]]; then
# 7371 at 8 cpu cores has 3.8Ghz clock frequency https://en.wikichip.org/wiki/amd/epyc/7371
# while greater than 8 cpu cores downclocks to 3.6Ghz
CPUS_MAKEPHP=8
fi
if [[ "$CPUS_MAKEPHP" -gt '8' ]]; then
if [[ "$PHP_LTO" = [yY] ]]; then
CPUS_MAKEPHP=$(echo "$CPUS_MAKEPHP" | bc)
CPUS_MAKEPHPLTO=$(echo "$CPUS_MAKEPHP/4" | bc)
if [[ "$(echo "$CPUS_MAKEPHP/2" | bc)" -lt '2' ]]; then
CPUS_MAKEPHPLTO='2'
elif [[ "$CPUS_MAKEPHPLTO" -lt '1' ]]; then
CPUS_MAKEPHPLTO='1'
fi
else
CPUS_MAKEPHP=$(echo "$CPUS_MAKEPHP+2" | bc)
fi
elif [[ "$CPUS_MAKEPHP" -eq '8' ]]; then
if [[ "$PHP_LTO" = [yY] ]]; then
CPUS_MAKEPHP=$(echo "$CPUS_MAKEPHP" | bc)
CPUS_MAKEPHPLTO=$(echo "$CPUS_MAKEPHP/4" | bc)
if [[ "$CPUS_MAKEPHPLTO" -lt '1' ]]; then
CPUS_MAKEPHPLTO='1'
fi
else
CPUS_MAKEPHP=$(echo "$CPUS_MAKEPHP+1" | bc)
fi
else
if [[ "$PHP_LTO" = [yY] ]]; then
CPUS_MAKEPHP=$(echo "$CPUS_MAKEPHP" | bc)
CPUS_MAKEPHPLTO=$(echo "$CPUS_MAKEPHP/4" | bc)
if [[ "$CPUS_MAKEPHPLTO" -lt '1' ]]; then
CPUS_MAKEPHPLTO='1'
fi
else
CPUS_MAKEPHP=$(echo "$CPUS_MAKEPHP" | bc)
fi
fi
MAKETHREADS_PHP=" -j$CPUS_MAKEPHP"
else
# speed up make
CPUS_MAKEPHP=$(grep -c "processor" /proc/cpuinfo)
if [[ "$CPUS_MAKEPHP" -eq '64' ]]; then
if [[ "$PHP_LTO" = [yY] ]]; then
CPUS_MAKEPHP=$(echo "$CPUS_MAKEPHP" | bc)
CPUS_MAKEPHPLTO=$(echo "$CPUS_MAKEPHP/32" | bc)
if [[ "$CPUS_MAKEPHPLTO" -lt '1' ]]; then
CPUS_MAKEPHPLTO='1'
fi
else
CPUS_MAKEPHP=$(echo "$CPUS_MAKEPHP" | bc)
fi
elif [[ "$CPUS_MAKEPHP" -eq '56' ]]; then
if [[ "$PHP_LTO" = [yY] ]]; then
CPUS_MAKEPHP=$(echo "$CPUS_MAKEPHP" | bc)
CPUS_MAKEPHPLTO=$(echo "$CPUS_MAKEPHP/28" | bc)
if [[ "$CPUS_MAKEPHPLTO" -lt '1' ]]; then
CPUS_MAKEPHPLTO='1'
fi
else
CPUS_MAKEPHP=$(echo "$CPUS_MAKEPHP" | bc)
fi
elif [[ "$CPUS_MAKEPHP" -eq '48' ]]; then
if [[ "$PHP_LTO" = [yY] ]]; then
CPUS_MAKEPHP=$(echo "$CPUS_MAKEPHP" | bc)
CPUS_MAKEPHPLTO=$(echo "$CPUS_MAKEPHP/24" | bc)
if [[ "$CPUS_MAKEPHPLTO" -lt '1' ]]; then
CPUS_MAKEPHPLTO='1'
fi
else
CPUS_MAKEPHP=$(echo "$CPUS_MAKEPHP" | bc)
fi
elif [[ "$CPUS_MAKEPHP" -eq '40' ]]; then
if [[ "$PHP_LTO" = [yY] ]]; then
CPUS_MAKEPHP=$(echo "$CPUS_MAKEPHP" | bc)
CPUS_MAKEPHPLTO=$(echo "$CPUS_MAKEPHP/20" | bc)
if [[ "$CPUS_MAKEPHPLTO" -lt '1' ]]; then
CPUS_MAKEPHPLTO='1'
fi
else
CPUS_MAKEPHP=$(echo "$CPUS_MAKEPHP" | bc)
fi
elif [[ "$CPUS_MAKEPHP" -eq '32' ]]; then
if [[ "$PHP_LTO" = [yY] ]]; then
CPUS_MAKEPHP=$(echo "$CPUS_MAKEPHP" | bc)
CPUS_MAKEPHPLTO=$(echo "$CPUS_MAKEPHP/16" | bc)
if [[ "$CPUS_MAKEPHPLTO" -lt '1' ]]; then
CPUS_MAKEPHPLTO='1'
fi
else
CPUS_MAKEPHP=$(echo "$CPUS_MAKEPHP" | bc)
fi
elif [[ "$CPUS_MAKEPHP" -eq '24' ]]; then
if [[ "$PHP_LTO" = [yY] ]]; then
CPUS_MAKEPHP=$(echo "$CPUS_MAKEPHP" | bc)
CPUS_MAKEPHPLTO=$(echo "$CPUS_MAKEPHP/12" | bc)
if [[ "$CPUS_MAKEPHPLTO" -lt '1' ]]; then
CPUS_MAKEPHPLTO='1'
fi
else
CPUS_MAKEPHP=$(echo "$CPUS_MAKEPHP" | bc)
fi
elif [[ "$CPUS_MAKEPHP" -eq '16' ]]; then
if [[ "$PHP_LTO" = [yY] ]]; then
CPUS_MAKEPHP=$(echo "$CPUS_MAKEPHP" | bc)
CPUS_MAKEPHPLTO=$(echo "$CPUS_MAKEPHP/8" | bc)
if [[ "$CPUS_MAKEPHPLTO" -lt '1' ]]; then
CPUS_MAKEPHPLTO='1'
fi
else
CPUS_MAKEPHP=$(echo "$CPUS_MAKEPHP" | bc)
fi
elif [[ "$CPUS_MAKEPHP" -eq '12' ]]; then
if [[ "$PHP_LTO" = [yY] ]]; then
CPUS_MAKEPHP=$(echo "$CPUS_MAKEPHP" | bc)
CPUS_MAKEPHPLTO=$(echo "$CPUS_MAKEPHP/6" | bc)
if [[ "$CPUS_MAKEPHPLTO" -lt '1' ]]; then
CPUS_MAKEPHPLTO='1'
fi
else
CPUS_MAKEPHP=$(echo "$CPUS_MAKEPHP" | bc)
fi
elif [[ "$CPUS_MAKEPHP" -eq '10' ]]; then
if [[ "$PHP_LTO" = [yY] ]]; then
CPUS_MAKEPHP=$(echo "$CPUS_MAKEPHP" | bc)
CPUS_MAKEPHPLTO=$(echo "$CPUS_MAKEPHP/5" | bc)
if [[ "$CPUS_MAKEPHPLTO" -lt '1' ]]; then
CPUS_MAKEPHPLTO='1'
fi
else
CPUS_MAKEPHP=$(echo "$CPUS_MAKEPHP" | bc)
fi
elif [[ "$CPUS_MAKEPHP" -eq '8' ]]; then
if [[ "$PHP_LTO" = [yY] ]]; then
CPUS_MAKEPHP=$(echo "$CPUS_MAKEPHP" | bc)
CPUS_MAKEPHPLTO=$(echo "$CPUS_MAKEPHP/4" | bc)
if [[ "$CPUS_MAKEPHPLTO" -lt '1' ]]; then
CPUS_MAKEPHPLTO='1'
fi
else
CPUS_MAKEPHP=$(echo "$CPUS_MAKEPHP+1" | bc)
fi
elif [[ "$CPUS_MAKEPHP" -gt '8' ]]; then
if [[ "$PHP_LTO" = [yY] ]]; then
CPUS_MAKEPHP=$(echo "$CPUS_MAKEPHP" | bc)
CPUS_MAKEPHPLTO=$(echo "$CPUS_MAKEPHP/4" | bc)
if [[ "$(echo "$CPUS_MAKEPHP/2" | bc)" -lt '2' ]]; then
CPUS_MAKEPHPLTO='2'
elif [[ "$CPUS_MAKEPHPLTO" -lt '1' ]]; then
CPUS_MAKEPHPLTO='1'
fi
else
CPUS_MAKEPHP=$(echo "$CPUS_MAKEPHP+2" | bc)
fi
else
if [[ "$PHP_LTO" = [yY] ]]; then
CPUS_MAKEPHP=$(echo "$CPUS_MAKEPHP" | bc)
CPUS_MAKEPHPLTO=$(echo "$CPUS_MAKEPHP/4" | bc)
if [[ "$CPUS_MAKEPHPLTO" -lt '1' ]]; then
CPUS_MAKEPHPLTO='1'
fi
else
CPUS_MAKEPHP=$(echo "$CPUS_MAKEPHP" | bc)
fi
fi
MAKETHREADS_PHP=" -j$CPUS_MAKEPHP"
fi
oniguruma_check
if [[ "$PHP_LDMOLD" = [yY] && -s /usr/local/libexec/mold ]]; then
PHP_MOLDOPT=' -B/usr/local/libexec/mold'
else
PHP_MOLDOPT=""
fi
# whether to switch from system used zlib to cloudflare zlib performance
# fork for php conmpilations for cpus supporting SSE4.2 at least
CHECK_PCLMUL=$(gcc -c -Q -march=native --help=target | egrep '\[enabled\]|mtune|march' | grep 'mpclmul' | grep -o enabled)
CLOUDFLARE_ZLIBPHP='n'
if [[ "$CLOUDFLARE_ZLIBPHP" = [yY] && "$(cat /proc/cpuinfo | grep -o 'sse4_2' | uniq)" = 'sse4_2' && "$CHECK_PCLMUL" = 'enabled' ]]; then
# check if static libz.a installed usually as result of compiling nginx with
# CLOUDFLARE_ZLIB='y' set but if not installed run install function from inc/zlib.inc
if [[ "$(uname -m)" = 'x86_64' ]]; then
ZLIBLIBDIR='lib64'
else
ZLIBLIBDIR='lib'
fi
if [ ! -f "/usr/local/zlib-cf/${ZLIBLIBDIR}/libz.a" ]; then
install_cfzlibstartdir=$(pwd)
install_cfzlib
cd $install_cfzlibstartdir
ZLIBPHP_OPT='--with-zlib-dir=/usr/local/zlib-cf'
# export CFLAGS="-I/usr/local/zlib-cf/include";
# export LDFLAGS="-L/usr/local/zlib-cf/lib"
# export LD_LIBRARY_PATH="/usr/local/zlib-cf/lib";
# export PHP_RPATH="/usr/local/zlib-cf/lib";
elif [ -f "/usr/local/zlib-cf/${ZLIBLIBDIR}/libz.a" ]; then
ZLIBPHP_OPT='--with-zlib-dir=/usr/local/zlib-cf'
if [[ "$(uname -m)" = 'x86_64' ]]; then
ln -sf /usr/local/zlib-cf/lib /usr/local/zlib-cf/lib64
fi
fi
else
ZLIBPHP_OPT='--with-zlib'
fi
# php modules to disable for low memory installs if
# LOWMEM_INSTALL='y' is set
# https://community.centminmod.com/posts/46321/
if [[ "$LOWMEM_INSTALL" = [yY] ]]; then
SQLLITEOPT=' --without-sqlite3'
PDOSQLLITE_OPT=' --without-pdo-sqlite'
else
PDOSQLLITE_OPT=' --with-pdo-sqlite'
if [[ -z "$(rpm -qa sqlite-devel)" ]]; then
yum -q -y install sqlite-devel
fi
fi
# php 7.2 & 7.3 specific config options
# Argon2 passwords https://wiki.php.net/rfc/argon2_password_hash
# libsodium https://wiki.php.net/rfc/libsodium
# https://github.com/jedisct1/libsodium
# disable temporarily for php 7.2.0 due to libzip compile errors
# https://gist.github.com/centminmod/d1b48ef88bda29a7e352b90fd7111ac1
if [[ "$CENTOS_SIX" = '6' ]] && [[ "$PHPMVER" = '7.4' || "$PHPMUVER" = '7.4' || "$PHPMVER" = '8.0' || "$PHPMUVER" = '8.0' || "$PHPMVER" = '8.1' || "$PHPMUVER" = '8.1' || "$PHPVER_ID" -ge '80000' ]]; then
DEVTOOLSET_PHP='y'
GCCINTEL_PHP='y'
# kerberos / krb5 and krb5-gasspi YUM packages on CentOS 6 is missing .pc files
# required for pkg-config to find location of dependency libraries for PHP 7.4+
if [[ "$(uname -m)" = 'x86_64' ]]; then
LIBDIR_KERBEROS='lib64'
LIBDIR_JPEG='lib64'
LIBDIR_SASL='lib64'
LIBDIR_GD='lib64'
else
LIBDIR_KERBEROS='lib'
LIBDIR_JPEG='lib'
LIBDIR_SASL='lib'
LIBDIR_GD='lib'
fi
export KERBEROS_CFLAGS='-I/usr/include'
export KERBEROS_LIBS="-L/usr/${LIBDIR_KERBEROS} -lkrb5 -lk5crypto -lgssapi_krb5"
export JPEG_CFLAGS='-I/usr/include'
export JPEG_LIBS="-L/usr/${LIBDIR_JPEG} -ljpeg"
export SASL_CFLAGS='-I/usr/include'
export SASL_LIBS="-L/usr/${LIBDIR_SASL}"
export GD_CFLAGS='-I/usr/include'
export GD_LIBS="-L/usr/${LIBDIR_GD} -lgd"
# PHP 7.4 sqlite requires >3.7 but centos 6 only has sqlite 3.6.20
if [[ "$(uname -m)" = 'x86_64' && ! -f "$DIR_TMP/sqlite-3.7.9-1.el6.art.x86_64.rpm" ]]; then
wget${ipv_forceopt_wget} http://www6.atomicorp.com/channels/atomic/centos/6/x86_64/RPMS/sqlite-3.7.9-1.el6.art.x86_64.rpm -O "$DIR_TMP/sqlite-3.7.9-1.el6.art.x86_64.rpm"
# yum -y localinstall $DIR_TMP/sqlite-3.7.9-1.el6.art.x86_64.rpm
elif [[ "$(uname -m)" != 'x86_64' && ! -f "$DIR_TMP/sqlite-3.7.9-1.el6.art.i686.rpm" ]]; then
wget${ipv_forceopt_wget} http://www6.atomicorp.com/channels/atomic/centos/6/x86_64/RPMS/sqlite-3.7.9-1.el6.art.i686.rpm -O "$DIR_TMP/sqlite-3.7.9-1.el6.art.i686.rpm"
# yum -y localinstall $DIR_TMP/sqlite-3.7.9-1.el6.art.i686.rpm
fi
if [[ "$(uname -m)" = 'x86_64' && ! -f "$DIR_TMP/sqlite-devel-3.7.9-1.el6.art.x86_64.rpm" ]]; then
wget${ipv_forceopt_wget} http://www6.atomicorp.com/channels/atomic/centos/6/x86_64/RPMS/sqlite-devel-3.7.9-1.el6.art.x86_64.rpm -O "$DIR_TMP/sqlite-devel-3.7.9-1.el6.art.x86_64.rpm"
# yum -y localinstall $DIR_TMP/sqlite-devel-3.7.9-1.el6.art.x86_64.rpm
elif [[ "$(uname -m)" != 'x86_64' && ! -f "$DIR_TMP/sqlite-devel-3.7.9-1.el6.art.i686.rpm" ]]; then
wget${ipv_forceopt_wget} http://www6.atomicorp.com/channels/atomic/centos/6/x86_64/RPMS/sqlite-devel-3.7.9-1.el6.art.i686.rpm -O "$DIR_TMP/sqlite-devel-3.7.9-1.el6.art.i686.rpm"
# yum -y localinstall $DIR_TMP/sqlite-devel-3.7.9-1.el6.art.i686.rpm
fi
if [[ "$(uname -m)" = 'x86_64' && -f "$DIR_TMP/sqlite-3.7.9-1.el6.art.x86_64.rpm" && -f "$DIR_TMP/sqlite-devel-3.7.9-1.el6.art.x86_64.rpm" ]]; then
yum -y localinstall $DIR_TMP/sqlite-3.7.9-1.el6.art.x86_64.rpm $DIR_TMP/sqlite-devel-3.7.9-1.el6.art.x86_64.rpm
fi
if [[ "$(uname -m)" != 'x86_64' && -f "$DIR_TMP/sqlite-3.7.9-1.el6.art.i686.rpm" && -f "$DIR_TMP/sqlite-devel-3.7.9-1.el6.art.i686.rpm" ]]; then
yum -y localinstall $DIR_TMP/sqlite-3.7.9-1.el6.art.i686.rpm $DIR_TMP/sqlite-devel-3.7.9-1.el6.art.i686.rpm
fi
fi
if [[ "$PHPDEBUGMODE" = [yY] ]]; then
PHPDEBUGOPT=' --enable-debug'
else
PHPDEBUGOPT=''
fi
# ZOPCACHE_OVERRIDE=y allows you to override PHP 5.5-7.x's inbuilt included Zend Opcache version with one available from pecl site
if [[ -n "$PHPMUVER" && "$PHPMUVER" = 5.[234] || "$PHPMVER" = 5.[234] ]]; then
OPCACHEOPT=''
elif [[ "$ZOPCACHE_OVERRIDE" = [yY] || "$ZOPCACHEDFT" = [nN] || "$zendopcacheon" = [nN] ]]; then
OPCACHEOPT=' --disable-opcache'
else
OPCACHEOPT=' --enable-opcache'
fi
if [[ ! -f /usr/include/readline/readline.h || ! -f /usr/include/editline/readline.h ]]; then
if [ -f /etc/yum.repos.d/rpmforge.repo ]; then
time yum${CACHESKIP} -q -y install readline-devel libedit-devel --disablerepo=rpmforge,epel
sar_call
else
time yum${CACHESKIP} -q -y install readline-devel libedit-devel --disablerepo=epel
sar_call
fi
fi
# Microsoft SQL Server PHP driver support
if [[ ! -f /usr/include/sql.h && "$PHPMSSQL" = [yY] ]] && [[ ! -f /usr/include/sqldb.h && "$PHPMSSQL" = [yY] ]]; then
yum -q -y install unixODBC-devel freetds-devel
sar_call
elif [[ ! -f /usr/include/sql.h && "$PHPMSSQL" = [yY] ]] && [[ -f /usr/include/sqldb.h && "$PHPMSSQL" = [yY] ]]; then
yum -q -y install unixODBC-devel
sar_call
elif [[ ! -f /usr/include/sqldb.h && "$PHPMSSQL" = [yY] ]] && [[ -f /usr/include/sql.h && "$PHPMSSQL" = [yY] ]]; then
yum -q -y install freetds-devel
sar_call
fi
if [[ ! -f /usr/bin/xslt-config ]]; then
yum -q -y install libxslt libxslt-devel
sar_call
fi
# for PHP versions lower than 7.1 switch back to system libicu versions for compatibility
if [[ "$PHPMVER" = 5.[23456] ]]; then
NEWLIBICU='n'
echo "NEWLIBICU=$NEWLIBICU"
fi
if [[ "$PHPMVER" = '7.0' ]]; then
NEWLIBICU='n'
echo "NEWLIBICU=$NEWLIBICU"
fi
if [[ "$PHPMVER" = '7.1' ]]; then
NEWLIBICU='n'
echo "NEWLIBICU=$NEWLIBICU"
fi
if [[ "$PHPMVER" = '7.2' ]]; then
NEWLIBICU='n'
echo "NEWLIBICU=$NEWLIBICU"
fi
if [[ "$PHPMVER" = '7.3' ]]; then
NEWLIBICU='y'
echo "NEWLIBICU=$NEWLIBICU"
fi
if [[ "$PHPMVER" = '7.4' ]]; then
NEWLIBICU='y'
echo "NEWLIBICU=$NEWLIBICU"
fi
if [[ "$PHPMVER" = '8.0' || "$PHPMVER" = '8.1' || "$PHPVER_ID" -ge '80000' ]]; then
NEWLIBICU='y'
echo "NEWLIBICU=$NEWLIBICU"
fi
if [[ "$PHPMUVER" = 5.[23456] ]]; then
NEWLIBICU='n'
echo "NEWLIBICU=$NEWLIBICU"
fi
if [[ "$PHPMUVER" = '7.0' ]]; then
NEWLIBICU='n'
echo "NEWLIBICU=$NEWLIBICU"
fi
if [[ "$PHPMUVER" = '7.1' ]]; then
NEWLIBICU='n'
echo "NEWLIBICU=$NEWLIBICU"
fi
if [[ "$PHPMUVER" = '7.2' ]]; then
NEWLIBICU='n'
echo "NEWLIBICU=$NEWLIBICU"
fi
if [[ "$PHPMUVER" = '7.3' ]]; then
NEWLIBICU='y'
echo "NEWLIBICU=$NEWLIBICU"
fi
if [[ "$PHPMUVER" = '7.4' ]]; then
NEWLIBICU='y'
echo "NEWLIBICU=$NEWLIBICU"
fi
if [[ "$PHPMUVER" = '8.0' || "$PHPMUVER" = '8.1' || "$PHPVER_ID" -ge '80000' ]]; then
NEWLIBICU='y'
echo "NEWLIBICU=$NEWLIBICU"
fi
if [[ ! -f /usr/bin/icu-config ]]; then
if [[ "$NEWLIBICU" = [yY] && "$CENTOS_SEVEN" = '7' && -f /etc/yum.repos.d/remi.repo && -f /etc/yum.repos.d/rpmforge.repo ]]; then
echo "yum -q -y install libicu62 libicu62-devel --enablerepo=remi --disablerepo=rpmforge,epel"
yum -q -y install libicu62 libicu62-devel --enablerepo=remi --disablerepo=rpmforge,epel
sar_call
elif [[ "$NEWLIBICU" = [yY] && "$CENTOS_SEVEN" = '7' && -f /etc/yum.repos.d/remi.repo && ! -f /etc/yum.repos.d/rpmforge.repo ]]; then
echo "yum -q -y install libicu62 libicu62-devel --enablerepo=remi --disablerepo=epel"
yum -q -y install libicu62 libicu62-devel --enablerepo=remi --disablerepo=epel
sar_call
elif [[ "$CENTOS_SIX" = '6' && -f /etc/yum.repos.d/remi.repo && -f /etc/yum.repos.d/rpmforge.repo ]]; then
echo "yum -q -y install libicu-last libicu-last-devel --enablerepo=remi --disablerepo=rpmforge,epel"
yum -q -y install libicu-last libicu-last-devel --enablerepo=remi --disablerepo=rpmforge,epel
sar_call
elif [[ "$CENTOS_SIX" = '6' && -f /etc/yum.repos.d/remi.repo && ! -f /etc/yum.repos.d/rpmforge.repo ]]; then
echo "yum -q -y install libicu-last libicu-last-devel --enablerepo=remi --disablerepo=epel"
yum -q -y install libicu-last libicu-last-devel --enablerepo=remi --disablerepo=epel
sar_call
elif [ -f /etc/yum.repos.d/rpmforge.repo ]; then
echo "yum -q -y install libicu libicu-devel --disablerepo=rpmforge,epel"
yum -q -y install libicu libicu-devel --disablerepo=rpmforge,epel
sar_call
else
echo "yum -q -y install libicu libicu-devel --disablerepo=epel"
yum -q -y install libicu libicu-devel --disablerepo=epel
sar_call
fi
fi
# echo "NEWLIBICU=$NEWLIBICU PHPMVER=$PHPMVER PHPMUVER=$PHPMUVER sleep 60"
# sleep 60
if [[ "$NEWLIBICU" = [yY] && "$CENTOS_SEVEN" = '7' && -f /etc/yum.repos.d/remi.repo && -f /usr/bin/icu-config && "$(/usr/bin/icu-config --version| cut -d . -f1)" -lt '62' ]]; then
# update centos 7 libicu 50.1 version to remi yum repo provided libicu 62.1 version
echo "yum -y install libicu62 --enablerepo=remi"
yum -y install libicu62 --enablerepo=remi
echo "yum -y swap libicu-devel libicu62-devel --enablerepo=remi"
yum -y swap libicu-devel libicu62-devel --enablerepo=remi
fi
# for PHP versions lower than 7.1 switch back to system libicu versions for compatibility
if [[ "$NEWLIBICU" = [nN] && "$CENTOS_SEVEN" = '7' && -f /etc/yum.repos.d/remi.repo && -f /usr/bin/icu-config ]] && [[ "$(/usr/bin/icu-config --version| cut -d . -f1)" -gt '50' ]]; then
echo "downgrade libicu back from $(/usr/bin/icu-config --version| cut -d . -f1) to earlier version"
# update centos 7 libicu 50.1 version to remi yum repo provided libicu 62.1 version
if [ "$(rpm -ql libicu62)" ]; then
echo "yum -y remove libicu62 --enablerepo=remi"
yum -y remove libicu62 --enablerepo=remi
if [ -f /etc/yum.repos.d/rpmforge.repo ]; then
echo "yum -q -y install libicu-devel --disablerepo=rpmforge,epel"
yum -q -y install libicu-devel --disablerepo=rpmforge,epel
else
echo "yum -q -y install libicu-devel --disablerepo=epel"
yum -q -y install libicu-devel --disablerepo=epel
fi
fi
if [ "$(rpm -ql libicu62-devel)" ]; then
echo "yum -y swap libicu62-devel libicu-devel --enablerepo=remi"
yum -y swap libicu62-devel libicu-devel --enablerepo=remi
else
if [ -f /etc/yum.repos.d/rpmforge.repo ]; then
echo "yum -q -y install libicu-devel --disablerepo=rpmforge,epel"
yum -q -y install libicu-devel --disablerepo=rpmforge,epel
else
echo "yum -q -y install libicu-devel --disablerepo=epel"
yum -q -y install libicu-devel --disablerepo=epel
fi
fi
fi
if [[ "$CENTOS_SIX" = '6' && -f /etc/yum.repos.d/remi.repo && -f /usr/bin/icu-config && "$(/usr/bin/icu-config --version| cut -d . -f1)" -lt '50' ]]; then
# update centos 7 libicu 50.1 version to remi yum repo provided libicu 62.1 version
echo "yum -y install libicu-last --enablerepo=remi"
yum -y install libicu-last --enablerepo=remi
echo "yum -y remove libicu-devel"
yum -y remove libicu-devel
echo "yum -y install libicu-last-devel --enablerepo=remi"
yum -y install libicu-last-devel --enablerepo=remi
fi
if [[ "$PHPMVER" = '7.4' || "$PHPMUVER" = '7.4' || "$PHPMVER" = '8.0' || "$PHPMUVER" = '8.0' || "$PHPMVER" = '8.1' || "$PHPMUVER" = '8.1' || "$PHPVER_ID" -ge '80000' ]]; then
if [[ "$(uname -m)" = 'x86_64' ]]; then
LIBDIR_LIBICU='lib64'
else
LIBDIR_LIBICU='lib'
fi
export ICU_CFLAGS='-I/usr/include'
export ICU_LIBS="-L/usr/${LIBDIR_LIBICU} -licuio -licui18n -licuuc -licudata"
fi
if [[ ! -f /usr/bin/pspell-config ]]; then
if [ -f /etc/yum.repos.d/rpmforge.repo ]; then
yum -q -y install aspell aspell-devel --disablerepo=rpmforge,epel
sar_call
else
yum -q -y install aspell aspell-devel --disablerepo=epel
sar_call
fi
fi
if [[ ! -f /usr/include/recode.h ]]; then
if [ -f /etc/yum.repos.d/rpmforge.repo ]; then
yum -q -y install recode recode-devel --disablerepo=rpmforge,epel
sar_call
else
yum -q -y install recode recode-devel --disablerepo=epel
sar_call
fi
fi
if [[ ! -f /usr/include/tidy.h ]]; then
yum -q -y install libtidy libtidy-devel --disablerepo=rpmforge
sar_call
fi
if [[ ! -d /usr/include/enchant ]]; then
if [ -f /etc/yum.repos.d/rpmforge.repo ]; then
yum -q -y install enchant enchant-devel --disablerepo=rpmforge,epel
sar_call
else
yum -q -y install enchant enchant-devel --disablerepo=epel
sar_call
fi
fi
if [[ ! -d /usr/include/net-snmp ]]; then
if [ -f /etc/yum.repos.d/rpmforge.repo ]; then
yum -q -y install net-snmp net-snmp-devel net-snmp-libs net-snmp-utils --disablerepo=rpmforge,epel
sar_call
else
yum -q -y install net-snmp net-snmp-devel net-snmp-libs net-snmp-utils --disablerepo=epel
sar_call
fi
fi
if [[ ! -f /usr/include/expect.h ]]; then
if [ -f /etc/yum.repos.d/rpmforge.repo ]; then
yum -q -y install expect-devel --disablerepo=rpmforge,epel
sar_call
else
yum -q -y install expect-devel --disablerepo=epel
sar_call
fi
fi
if [ "$PHPEMBED" == 'y' ]; then
PHPEMBEDOPT=" --enable-embed=shared"
else
PHPEMBEDOPT=""
fi
if [ "$PHPMSSQL" == 'y' ]; then
MSSQLOPT=" --with-pdo-odbc=unixODBC,/usr"
else
MSSQLOPT=""
fi
if [[ -f /usr/include/ldap.h ]]; then
LDAPOPT=' --with-ldap --with-ldap-sasl'
else
LDAPOPT=""
fi
if [[ "$PHPMVER" > 7 || "$PHPMUVER" > 7 ]]; then
if [[ "$(rpm -ql libwebp | grep libwebp.so >/dev/null 2>&1; echo $?)" -eq '0' ]]; then
if [[ "$PHPMVER" = '7.4' || "$PHPMUVER" = '7.4' || "$PHPMVER" = '8.0' || "$PHPMUVER" = '8.0' || "$PHPMVER" = '8.1' || "$PHPMUVER" = '8.1' || "$PHPVER_ID" -ge '80000' ]]; then
LIBVPXOPT=' --with-webp'
else
LIBVPXOPT=' --with-webp-dir=/usr'
fi
else
time yum${CACHESKIP} -y install libwebp libwebp-devel
if [[ "$PHPMVER" = '7.4' || "$PHPMUVER" = '7.4' || "$PHPMVER" = '8.0' || "$PHPMUVER" = '8.0' || "$PHPMVER" = '8.1' || "$PHPMUVER" = '8.1' || "$PHPVER_ID" -ge '80000' ]]; then
LIBVPXOPT=' --with-webp'
else
LIBVPXOPT=' --with-webp-dir=/usr'
fi
fi
elif [[ "$PHPMVER" = 5.[56] || "$PHPMUVER" = 5.[56] ]] && [[ "$PHPMVER" < 7 || "$PHPMUVER" < 7 ]]; then
if [[ -d /usr/include/vpx ]]; then
LIBVPXOPT=" --with-vpx-dir=${PLIBDIR}"
else
if [ -f /etc/yum.repos.d/rpmforge.repo ]; then
time yum${CACHESKIP} -y install libvpx libvpx-devel --disablerepo=rpmforge,epel
sar_call
else
time yum${CACHESKIP} -y install libvpx libvpx-devel --disablerepo=epel
sar_call
fi
LIBVPXOPT=" --with-vpx-dir=${PLIBDIR}"
fi
else
LIBVPXOPT=''
fi
if [[ -f /usr/include/t1lib.h ]]; then
TLIBOPT=" --with-t1lib=${PLIBDIR}"
else
if [ -f /etc/yum.repos.d/rpmforge.repo ]; then
time yum${CACHESKIP} -y install t1lib t1lib-devel --disablerepo=rpmforge,epel
sar_call
else
time yum${CACHESKIP} -y install t1lib t1lib-devel --disablerepo=epel
sar_call
fi
TLIBOPT=" --with-t1lib=${PLIBDIR}"
fi
if [ "$PHPPCNTL" == 'y' ]; then
PCNTLOPT=" --enable-pcntl"
else
PCNTLOPT=""
fi
if [ "$PHPINTL" == 'y' ]; then
PHPINTLOPT=" --enable-intl"
else
PHPINTLOPT=""
fi
if [ "$PHPRECODE" == 'y' ]; then
RECODEOPT=" --with-recode"
else
RECODEOPT=""
fi
if [ "$PHPSNMP" == 'y' ]; then
SNMPOPT=" --with-snmp"
else
SNMPOPT=""
fi
if [ "$PHP_FTPEXT" == 'y' ]; then
FTPEXTOPT=" --enable-ftp"
else
FTPEXTOPT=""
fi
# let centmin.sh set PHPFINFO variable override the
# low memory CHECKLOWMEMPHP variable check
if [[ "$PHPFINFO_STANDALONE" = [yY] ]]; then
PHPFINFO='y'
fi
if [[ "$PHPFINFO" = [yY] ]] && [[ "$CHECKLOWMEMPHP" = "1" && "$TOTALSWAPMEM" -ge '1023000' && "$PHPFINFO_STANDALONE" = [yY] ]]; then
# PHPFINFO yes + low mem install + swap space enough = enable file info php extension
FILEINFOOPT=" --disable-fileinfo"
elif [[ "$PHPFINFO" = [yY] ]] && [[ "$CHECKLOWMEMPHP" = "1" && "$TOTALSWAPMEM" -ge '1023000' && "$PHPFINFO_STANDALONE" = [nN] ]]; then
# PHPFINFO yes + low mem install + swap space enough = enable file info php extension
FILEINFOOPT=""
elif [[ "$PHPFINFO" = [yY] ]] && [[ "$CHECKLOWMEMPHP" != "1" && "$PHPFINFO_STANDALONE" = [yY] ]]; then
# PHPFINFO yes + enough mem install = enable file info php extension
FILEINFOOPT=" --disable-fileinfo"
elif [[ "$PHPFINFO" = [yY] ]] && [[ "$CHECKLOWMEMPHP" != "1" && "$PHPFINFO_STANDALONE" = [nN] ]]; then
# PHPFINFO yes + enough mem install = enable file info php extension
FILEINFOOPT=""
elif [[ "$PHPFINFO" = [yY] ]] && [[ "$CHECKLOWMEMPHP" = "1" && "$TOTALSWAPMEM" -lt '1023000' ]]; then
# PHPFINFO yes + low mem install + low swap space = disable file info php extension
FILEINFOOPT=" --disable-fileinfo"
elif [[ "$PHPFINFO" = [nN] ]]; then
# PHPFINFO no
FILEINFOOPT=" --disable-fileinfo"
fi
if [[ "$PHPIMAP" = [yY] ]]; then
IMAPOPT=' --with-imap --with-imap-ssl'
else
IMAPOPT=""
fi
phpimap_install
if [[ "$CENTOS_SEVEN" = '7' || "$CENTOS_SIX" = '6' ]]; then
if [[ "$POSTGRESQL" = [yY] ]]; then
# to allow to persist on centmin mod code updates
# create persistent config file at /etc/centminmod/custom_config.inc
# and add to it the line:
# POSTGRESQL=y
postgresqlinstall
PDOPGSQL_OPT=" --with-pgsql=/usr/pgsql-${PDOPGSQL_PHPVER} --with-pdo-pgsql=/usr/pgsql-${PDOPGSQL_PHPVER}"
else
PDOPGSQL_OPT=""
fi
if [[ ! -f /usr/bin/libmcrypt-config ]]; then
# double check mcrypt has been installed
CHECKMCRYPT='libmcrypt libmcrypt-devel'
declare -a arraysm
arraysm=(${CHECKMCRYPT})
for pkg in ${arraysm[@]}
do
echo Processing package: $pkg
MCRYPTRPMCHECKS=`yum${CACHESKIP} -q list installed $pkg | awk '/Installed/ {print $1}' &>/dev/null`
#echo $MCRYPTRPMCHECKS
if [ "$MCRYPTRPMCHECKS" != 'Installed' ]; then
echo "----------------------------------------------------------------------------------"
cecho "Installing $pkg" $boldyellow
echo "----------------------------------------------------------------------------------"
time $YUMDNFBIN${CACHESKIP} -q -y install $pkg${DISABLEREPO_DNF}
# time $YUMDNFBIN${CACHESKIP} -q list $pkg
echo "----------------------------------------------------------------------------------"