Environment:
- Ubuntu 26.04 LTS x86_64
- PHP 8.5.8 installed by aaPanel
- Script: /www/server/panel/install/mbstring.sh
Problem:
aaPanel builds PHP 8.5 with --enable-mbstring, so mbstring is already
available even when PHP is started with -n.
Reproduction:
/www/server/php/85/bin/php -n -r
'echo extension_loaded("mbstring") ? "loaded\n" : "missing\n";'
Output:
loaded
After installing mbstring from aaPanel, mbstring.sh appends:
extension = /www/server/php/85/lib/php/extensions/no-debug-non-zts-20250925/mbstring.so
to both php.ini and php-cli.ini.
Every PHP invocation then prints:
PHP Warning: Module "mbstring" is already loaded in Unknown on line 0
Root cause:
Install_mbstring() only treats mbstring as installed when both a
/mbstring.so configuration line and php -m output exist. It does not
detect a statically compiled mbstring module.
Suggested fix:
Before building or appending mbstring.so, test the no-configuration PHP
binary:
/www/server/php/$version/bin/php -n -r
'exit(extension_loaded("mbstring") ? 0 : 1);'
If it returns 0, report mbstring as built in and do not append the
dynamic extension line.
Environment:
Problem:
aaPanel builds PHP 8.5 with --enable-mbstring, so mbstring is already
available even when PHP is started with -n.
Reproduction:
/www/server/php/85/bin/php -n -r
'echo extension_loaded("mbstring") ? "loaded\n" : "missing\n";'
Output:
loaded
After installing mbstring from aaPanel, mbstring.sh appends:
extension = /www/server/php/85/lib/php/extensions/no-debug-non-zts-20250925/mbstring.so
to both php.ini and php-cli.ini.
Every PHP invocation then prints:
PHP Warning: Module "mbstring" is already loaded in Unknown on line 0
Root cause:
Install_mbstring() only treats mbstring as installed when both a
/mbstring.so configuration line and php -m output exist. It does not
detect a statically compiled mbstring module.
Suggested fix:
Before building or appending mbstring.so, test the no-configuration PHP
binary:
/www/server/php/$version/bin/php -n -r
'exit(extension_loaded("mbstring") ? 0 : 1);'
If it returns 0, report mbstring as built in and do not append the
dynamic extension line.