Running PHP via CLI after switching PHP versions shows some warnings. Broken symlink?

  • What version of apnscp are you running?
    cpcmd misc_cp_version
revision: 9af8ce4a35134e10e26e964b3002e73515848c08
timestamp: 1692984726
ver_maj: 3
ver_min: 2
ver_patch: 38
ver_pre: ''
dirty: false
debug: false
  • Which version of RHEL or CentOS are you using?
    cat /etc/redhat-release
Rocky Linux release 8.8 (Green Obsidian)
  • Can you reproduce this bug reliably? Provide steps. If not, provide steps to the best of your recollection.

First, after install. I added a new domain using the AddDomain helper with the default plan. After some testing with wordpress, I decided to enable multiphp.

  1. cpcmd scope:set cp.bootstrapper php_build_flags "--disable-sysvsem --enable-pcntl"
  2. cpcmd scope:set cp.bootstrapper pecl_extensions '[imagick,igbinary,redis]'
  3. cpcmd scope:set cp.bootstrapper php_multiphp '[7.4,8.1,8.2]'
  4. upcp -sb php/multiphp
  5. from my default php 8.2, I switch version to 8.1 cpcmd -d wp.example.test php:pool-set-version 8.1
  6. restart pool cpcmd -d wp.example.test php:pool-restart

I logged in as admin for the domain with su -l wp.example.com
wordpress site seems ok, no errors.
tried checking php version via cli but it returns php 8.2
so I tried the /.socket/php/multiphp/native/8.1/bin/php --version and encountered this warning

Failed loading /usr/lib64/20220829/ioncube_loader_lin_8.1.so:  /usr/lib64/20220829/ioncube_loader_lin_8.1.so

searching discord, I found the same problem with this solution

upcp -sb --var=multiphp_build=true --var=php_version=8.1 apnscp/php-filesystem-template

tried checking the php versions again via cli.

Failed loading /usr/lib64/20220829/ioncube_loader_lin_8.1.so:  /usr/lib64/20220829/ioncube_loader_lin_8.1.so: cannot open shared object file: Too many levels of symbolic links
Failed loading /usr/lib64/20220829/opcache.so:  /usr/lib64/20220829/opcache.so: cannot open shared object file: Too many levels of symbolic links

it didn’t fix the warning so I started to investigate.

/usr/lib64/20220829 seems to symlink to the same /usr/lib64/20220829 instead of /.socket/php/multiphp/native/8.1/usr/lib64/20210902 thats why the modules fails to load.

running the same php as root shows a different warning
/home/virtual/site2/fst/.socket/php/multiphp/native/8.1/bin/php --version

Failed loading /usr/lib64/20220829/opcache.so:  /usr/lib64/20220829/opcache.so: undefined symbol: zend_observer_class_linked_observed

Already tried reloading fsmount and droping caches.

systemctl reload fsmount
echo 2 > /proc/sys/vm/drop_caches

PS: not just php 8.1, tried switching to php 7.4 with the same warnings.

Here’s my results from your steps. Note this machine was built with PHP 7.0 instead of 8.2.

# Verify system PHP version 7.0
cpcmd php:version
cpcmd scope:set cp.bootstrapper php_multiphp '[7.4,7.0]'
upcp -sb php/multiphp

Results:

# ls -l /usr/lib64/20*
# 7.0
lrwxrwxrwx 1 root root 51 Aug 28 16:45 /usr/lib64/20151012 -> /.socket/php/multiphp/native/7.0/usr/lib64/20151012
# 7.4
lrwxrwxrwx 1 root root 51 Aug 28 16:42 /usr/lib64/20190902 -> /.socket/php/multiphp/native/7.4/usr/lib64/20190902

# ls -l /home/virtual/FILESYSTEMTEMPLATE/siteinfo/usr/lib64/20*
lrwxrwxrwx 1 root root 51 Aug 28 16:45 /home/virtual/FILESYSTEMTEMPLATE/siteinfo/usr/lib64/20151012 -> /.socket/php/multiphp/native/7.0/usr/lib64/20151012
lrwxrwxrwx 1 root root 51 Aug 28 16:42 /home/virtual/FILESYSTEMTEMPLATE/siteinfo/usr/lib64/20190902 -> /.socket/php/multiphp/native/7.4/usr/lib64/20190902

Do you see a different module layout in /home/virtual/FILESYSTEMTEMPLATE versus what’s in the account’s vfs? If so, it’s due to OverlayFS caching dentries. In order for a directory entry to fully update, all open file handles must be released to it. Sometimes you can get away with cpcmd admin:kill-site siteXX ; cpcmd -d siteXX file:purge to terminate all processes on the site, then force OverlayFS to dump its cache.

Additionally, in this situation 8.2 shouldn’t be built as multiPHP because it duplicates system PHP. Use `php.multi’ Scope to set these versions:

# Add 8.1
cpcmd scope:set php.multi 8.1
# Remove 8.0
cpcmd scope:set php.multi '[8.0:false]'

There are additional checks in the Scope to prevent building a system PHP version as multiPHP, plus it merges results into php_multiphp.