Skip to content

Commit aa5e499

Browse files
authored
PHP Default
Switched the default PHP version to 8.5. Added a version override for PHP 8.4 to ensure compatibility with older projects. New menu option added to allow users to easily switch between PHP versions.
1 parent b4adda1 commit aa5e499

10 files changed

Lines changed: 187 additions & 135 deletions

File tree

.github/ci-config/enginescript-variables-ci.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ NGINX_PURGE_VER="2.5.5"
1414
NGINX_VER="1.29.5"
1515
OPENSSL_VER="3.5.5"
1616
PCRE2_VER="10.47"
17-
PHP_VER="8.4"
17+
PHP_VER="8.5"
1818
PHPMYADMIN_VER="5.2.3"
1919
PNGOUT_VER="20200115"
2020
ZLIB_VER="1.3.1.2"

config/etc/php/php.ini

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -39,11 +39,6 @@
3939
; Development Value: 4096
4040
; Production Value: 4096
4141

42-
; register_argc_argv
43-
; Default Value: On
44-
; Development Value: Off
45-
; Production Value: Off
46-
4742
; request_order
4843
; Default Value: None
4944
; Development Value: "GP"
@@ -109,7 +104,6 @@ unserialize_callback_func =
109104
serialize_precision = -1
110105
;open_basedir =
111106
disable_functions = pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_get_handler,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,pcntl_async_signals,pcntl_unshare,
112-
disable_classes =
113107
;highlight.string = #DD0000
114108
;highlight.comment = #FF9900
115109
;highlight.keyword = #007700
@@ -154,7 +148,6 @@ log_errors = On
154148
log_errors_max_len = 1024
155149
ignore_repeated_errors = Off
156150
ignore_repeated_source = Off
157-
report_memleaks = On
158151
;report_zend_debug = 0
159152
xmlrpc_errors = 0
160153
;xmlrpc_error_number = 0
@@ -178,7 +171,6 @@ html_errors = Off
178171
;arg_separator.input = ";&"
179172
variables_order = "GPCS"
180173
request_order = "GP"
181-
register_argc_argv = Off
182174
auto_globals_jit = On
183175
;enable_post_data_reading = Off
184176
post_max_size = 128M
@@ -397,17 +389,17 @@ bcmath.scale = 0
397389
[Session]
398390
session.save_handler = files
399391
session.save_path = "/var/cache/php-sessions"
400-
session.use_strict_mode = 0
392+
session.use_strict_mode = 1
401393
session.use_cookies = 1
402-
;session.cookie_secure =
394+
session.cookie_secure = 1
403395
session.use_only_cookies = 1
404396
session.name = PHPSESSID
405397
session.auto_start = 0
406398
session.cookie_lifetime = 0
407399
session.cookie_path = /
408400
session.cookie_domain =
409401
session.cookie_httponly = 1
410-
session.cookie_samesite =
402+
session.cookie_samesite = Lax
411403
session.serialize_handler = php
412404
session.gc_probability = 1
413405
session.gc_divisor = 1000
@@ -416,10 +408,8 @@ session.referer_check =
416408
session.cache_limiter = nocache
417409
session.cache_expire = 180
418410
session.use_trans_sid = 0
419-
session.sid_length = 26
420411
session.trans_sid_tags = "a=href,area=href,frame=src,form="
421412
;session.trans_sid_hosts=""
422-
session.sid_bits_per_character = 5
423413
;session.upload_progress.enabled = On
424414
;session.upload_progress.cleanup = On
425415
;session.upload_progress.prefix = "upload_progress_"
@@ -545,3 +535,10 @@ opcache.validate_timestamps=1
545535
[ffi]
546536
;ffi.enable=preload
547537
;ffi.preload=
538+
539+
; References:
540+
; WordPress does not use PHP native sessions. It uses authentication cookies and
541+
; database-backed session tokens (WP_Session_Tokens). However, some plugins and
542+
; admin tools (e.g., phpMyAdmin) may use PHP sessions, so these settings are
543+
; configured securely as defense-in-depth.
544+
; https://www.iflair.com/how-wordpress-handles-sessions-and-user-data-in-the-database/

config/home/enginescript-install-options.txt

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -54,10 +54,12 @@ INSTALL_HTTP3=0
5454
# SOAP, SQLite3
5555
INSTALL_EXPANDED_PHP=0
5656

57-
## Keep PHP 8.3 Installation ##
58-
# Set to 1 to keep PHP 8.3 alongside PHP 8.4 during upgrade
59-
# Set to 0 to remove PHP 8.3 after upgrading to PHP 8.4 (recommended)
60-
INSTALL_PHP83=0
57+
## PHP Version Override ##
58+
# Leave empty to use the default PHP version (currently 8.5)
59+
# Set to "8.4" or "8.3" to install an older version instead
60+
# This affects all PHP installation, configuration, and service management
61+
# You can also switch versions at any time via: es.menu > Update Software > Switch PHP Version
62+
PHP_VERSION_OVERRIDE=""
6163

6264
## Automatic Lossless Image Optimization ##
6365
# Automatically perform lossless compression on all images on each domain.

enginescript-variables.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ NGINX_PURGE_VER="2.5.5"
1414
NGINX_VER="1.29.5"
1515
OPENSSL_VER="3.5.5"
1616
PCRE2_VER="10.47"
17-
PHP_VER="8.4"
17+
PHP_VER="8.5"
1818
PHPMYADMIN_VER="5.2.3"
1919
PNGOUT_VER="20200115"
2020
ZLIB_VER="1.3.1.2"

scripts/functions/alias/alias-debug.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -320,7 +320,7 @@ debug_print "Redis: $(redis-server --version)" "Redis: \`$(redis-server --versio
320320
debug_print "\n## Service Status\n" "\n## Service Status\n"
321321
debug_print "| Service | Status |" "| Service | Status |"
322322
debug_print "|---------|---------|" "|---------|---------|"
323-
services=("nginx" "php8.3-fpm" "mariadb" "redis-server")
323+
services=("nginx" "php${PHP_VER}-fpm" "mariadb" "redis-server")
324324
for service in "${services[@]}"; do
325325
status=$(systemctl is-active "$service")
326326
if [[ "$status" == "active" ]]; then

scripts/functions/shared/enginescript-common.sh

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -241,6 +241,36 @@ function clear_all_system_caches() {
241241
}
242242

243243

244+
# ----------------------------------------------------------------
245+
# Resolve PHP version from override or default
246+
# If PHP_VERSION_OVERRIDE is set in install options, use it instead of the default PHP_VER
247+
# Validates that the override is a supported version (8.3, 8.4, 8.5)
248+
function resolve_php_version() {
249+
local supported_versions=("8.3" "8.4" "8.5")
250+
251+
if [[ -n "${PHP_VERSION_OVERRIDE}" ]]; then
252+
local valid=false
253+
for ver in "${supported_versions[@]}"; do
254+
if [[ "${PHP_VERSION_OVERRIDE}" == "${ver}" ]]; then
255+
valid=true
256+
break
257+
fi
258+
done
259+
260+
if [[ "${valid}" == true ]]; then
261+
PHP_VER="${PHP_VERSION_OVERRIDE}"
262+
echo "PHP version override active: using PHP ${PHP_VER}"
263+
else
264+
echo "Warning: Invalid PHP_VERSION_OVERRIDE '${PHP_VERSION_OVERRIDE}'. Supported: ${supported_versions[*]}"
265+
echo "Falling back to default PHP ${PHP_VER}"
266+
fi
267+
fi
268+
}
269+
270+
# Apply PHP version override if set
271+
resolve_php_version
272+
273+
244274
# ----------------------------------------------------------------
245275
# Function to restart a service
246276
function restart_service() {
@@ -255,7 +285,7 @@ function restart_service() {
255285
# ----------------------------------------------------------------
256286
# Function to restart PHP-FPM service
257287
function restart_php_fpm() {
258-
local php_versions=("8.1" "8.2" "8.3" "8.4")
288+
local php_versions=("8.3" "8.4" "8.5")
259289
for version in "${php_versions[@]}"; do
260290
if systemctl is-active --quiet "php${version}-fpm"; then
261291
restart_service "php${version}-fpm"

scripts/install/block/package-block.sh

Lines changed: 12 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -30,26 +30,15 @@ echo -e "Package: nginx*\nPin: release *\nPin-Priority: -1" > nginx-block
3030
echo -e "Package: openlitespeed*\nPin: release *\nPin-Priority: -1" > litespeed-block
3131
echo -e "Package: lighttpd*\nPin: release *\nPin-Priority: -1" > litespeed-block2
3232

33-
# Block PHP 5.x from APT
34-
echo -e "Package: php5*\nPin: release *\nPin-Priority: -1" > php5-block
35-
36-
# Block PHP 7.0 from APT
37-
echo -e "Package: php7.0*\nPin: release *\nPin-Priority: -1" > php70-block
38-
39-
# Block PHP 7.1 from APT
40-
echo -e "Package: php7.1*\nPin: release *\nPin-Priority: -1" > php71-block
41-
42-
# Block PHP 7.2 from APT
43-
echo -e "Package: php7.2*\nPin: release *\nPin-Priority: -1" > php72-block
44-
45-
# Block PHP 7.3 from APT
46-
echo -e "Package: php7.3*\nPin: release *\nPin-Priority: -1" > php73-block
47-
48-
# Block PHP 7.4 from APT
49-
echo -e "Package: php7.4*\nPin: release *\nPin-Priority: -1" > php74-block
50-
51-
# Block PHP 8.0 from APT
52-
echo -e "Package: php8.0*\nPin: release *\nPin-Priority: -1" > php80-block
53-
54-
# Block PHP 8.1 from APT
55-
echo -e "Package: php8.1*\nPin: release *\nPin-Priority: -1" > php81-block
33+
# Block all PHP versions except the selected one
34+
# Always block legacy versions
35+
block_versions=("5" "7.0" "7.1" "7.2" "7.3" "7.4" "8.0" "8.1" "8.2" "8.3" "8.4" "8.5")
36+
37+
for ver in "${block_versions[@]}"; do
38+
# Skip the selected PHP version
39+
if [[ "${ver}" == "${PHP_VER}" ]]; then
40+
continue
41+
fi
42+
sanitized="${ver//.}"
43+
echo -e "Package: php${ver}*\nPin: release *\nPin-Priority: -1" > "php${sanitized}-block"
44+
done

scripts/install/php/php-install.sh

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,12 +33,17 @@ php${PHP_VER}-imagick
3333
php${PHP_VER}-intl
3434
php${PHP_VER}-mbstring
3535
php${PHP_VER}-mysql
36-
php${PHP_VER}-opcache
3736
php${PHP_VER}-redis
3837
php${PHP_VER}-ssh2
3938
php${PHP_VER}-xml
4039
php${PHP_VER}-zip"
4140

41+
# PHP 8.5+ has opcache built-in; older versions need the separate package
42+
if [[ "$(echo "${PHP_VER} < 8.5" | bc -l)" -eq 1 ]]; then
43+
php_packages="${php_packages}
44+
php${PHP_VER}-opcache"
45+
fi
46+
4247
# Install the packages with error checking
4348
# Unquoted expansion relies on word splitting (spaces and newlines)
4449
apt install -qy $php_packages || {

scripts/menu/update-menu.sh

Lines changed: 53 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ while true
2727
echo ""
2828

2929
PS3='Please enter your choice: '
30-
options=("Update EngineScript" "Update Kernel (experimental)" "Update MariaDB" "Update Nginx" "Update OpenSSL" "Update PHP" "Update Server Tools" "Update Ubuntu Distribution (apt full-upgrade)" "Update Ubuntu Software (apt upgrade)" "Exit Update Software Menu")
30+
options=("Update EngineScript" "Update Kernel (experimental)" "Update MariaDB" "Update Nginx" "Update OpenSSL" "Update PHP" "Switch PHP Version" "Update Server Tools" "Update Ubuntu Distribution (apt full-upgrade)" "Update Ubuntu Software (apt upgrade)" "Exit Update Software Menu")
3131
select opt in "${options[@]}"
3232
do
3333
case $opt in
@@ -57,6 +57,58 @@ while true
5757
/usr/local/bin/enginescript/scripts/update/php-update.sh
5858
break
5959
;;
60+
"Switch PHP Version")
61+
echo ""
62+
echo "Switch PHP Version"
63+
echo "=================="
64+
echo ""
65+
# Detect currently installed PHP-FPM version
66+
CURRENT_PHP=""
67+
for ver in 8.3 8.4 8.5; do
68+
if dpkg -l 2>/dev/null | grep -q "php${ver}-fpm"; then
69+
CURRENT_PHP="${ver}"
70+
fi
71+
done
72+
if [[ -n "${CURRENT_PHP}" ]]; then
73+
echo "Currently installed: PHP ${CURRENT_PHP}"
74+
else
75+
echo "No PHP-FPM installation detected."
76+
fi
77+
echo ""
78+
echo "Select the PHP version to switch to:"
79+
PS3='Choose a version: '
80+
select php_choice in "PHP 8.5" "PHP 8.4" "PHP 8.3" "Cancel"; do
81+
case $php_choice in
82+
"PHP 8.5")
83+
TARGET_VER="8.5"
84+
break
85+
;;
86+
"PHP 8.4")
87+
TARGET_VER="8.4"
88+
break
89+
;;
90+
"PHP 8.3")
91+
TARGET_VER="8.3"
92+
break
93+
;;
94+
"Cancel")
95+
TARGET_VER=""
96+
break
97+
;;
98+
*) echo "Invalid option";;
99+
esac
100+
done
101+
if [[ -n "${TARGET_VER}" ]]; then
102+
if [[ "${TARGET_VER}" == "${CURRENT_PHP}" ]]; then
103+
echo ""
104+
echo "PHP ${TARGET_VER} is already installed. No changes needed."
105+
sleep 3
106+
else
107+
/usr/local/bin/enginescript/scripts/update/php-update.sh "${TARGET_VER}"
108+
fi
109+
fi
110+
break
111+
;;
60112
"Update Server Tools")
61113
/usr/local/bin/enginescript/scripts/update/software-update.sh
62114
break

0 commit comments

Comments
 (0)