Selectable versions of php

I have a new Mythic vm running Sympl 12. I have attempted to configure PHP5.6 for example.co.uk without success.

Output from phpinfo.php unexpectedly shows PHP version: 8.2.25 rather than 5.6

Outputs are as follows:

Domain: example.co.uk
Configuring site for PHP 5.6
Installing php5.6 …
Installing php5.6-cli …
Installing php5.6-fpm …
Installing php5.6-common …
Installing new package: php5.6-bz2
Installing new package: php5.6-curl
Installing new package: php5.6-gd
Installing new package: php5.6-imagick
E: Sub-process /usr/bin/dpkg returned an error code (1)
Installing new package: php5.6-intl
Installing new package: php5.6-mbstring
Installing new package: php5.6-mcrypt
Installing new package: php5.6-mysql
Installing new package: php5.6-xml
Installing new package: php5.6-xmlrpc
Installing new package: php5.6-zip
Configured with ‘default’ pool
Created pool link for domain
PHP-FPM enabled on example.co.uk
Pool configuration changed, will reload PHP 5.6

Applying configuration… done

//////

sympl@hillcrest:~$ sudo sympl-php-configure
[sudo] password for sympl:

Domain: example.co.uk
Configuring site for PHP 5.6
Configured with ‘default’ pool

Applying configuration… done

sympl@hillcrest:~$

//////

sympl@hillcrest:~$ sudo sympl-web-configure --verbose example.co.uk
Domain: example.co.uk
SSL is not enabled – using non-SSL template
Adding to configurations
Configuration: example.co.uk.conf
Configuration is up-to date.
Already enabled.
sympl@hillcrest:~$

//////

sympl@hillcrest:~$ sudo apachectl -t
Syntax OK
sympl@hillcrest:~$

/////

sympl@hillcrest:~$ sudo service apache2 status
● apache2.service - The Apache HTTP Server
Loaded: loaded (/lib/systemd/system/apache2.service; enabled; preset: enabled)
Active: active (running) since Thu 2024-11-14 20:45:00 UTC; 1h 13min ago
Docs: Apache HTTP Server Version 2.4 Documentation - Apache HTTP Server Version 2.4
Process: 768644 ExecStart=/usr/sbin/apachectl start (code=exited, status=0/SUCCESS)
Tasks: 20 (limit: 1141)
Memory: 41.3M
CPU: 936ms
CGroup: /system.slice/apache2.service
├─768661 /usr/sbin/apache2 -k start
├─768662 /usr/sbin/sympl-web-logger -l ssl_access.log /var/log/apache2/zz-mass-hosting.ssl_access.log
├─768663 /usr/sbin/sympl-web-logger -l access.log /var/log/apache2/zz-mass-hosting.access.log
├─768674 /usr/sbin/apache2 -k start
├─768675 /usr/sbin/apache2 -k start
├─768676 /usr/sbin/apache2 -k start
├─768677 /usr/sbin/apache2 -k start
├─768678 /usr/sbin/apache2 -k start
├─768683 /usr/sbin/apache2 -k start
└─768719 /usr/sbin/apache2 -k start

Nov 14 20:45:00 hillcrest.vs.mythic-beasts.com systemd[1]: Starting apache2.service - The Apache HTTP Server…
Nov 14 20:45:00 hillcrest.vs.mythic-beasts.com systemd[1]: Started apache2.service - The Apache HTTP Server.
sympl@hillcrest:~$

/////

So surely phpinfo.php should display PHP5.6 at this stage?

Check the generated Apache .conf file in /etc/apache2/conf-enabled.

It should contain a line starting:

SetHandler "proxy:unix:/etc/sympl/php/domain/...

Tvm for the response. Is the suggested file path above correct? There’s just a bunch of symlinks in that directory. However, I can see the following line in /etc/apache2/sites-enabled/exampledomain.co.uk.conf

  # Pass PHP files to relevant PHP-FPM socket via symlink
  SetHandler "proxy:unix:/etc/sympl/php/domain/exampledomain.co.uk|fcgi://127.0.0.1"

Yes, that’s correct, and what you should expect to see.

I’ve replicated your setup with a simple phpinfo() file in the webroot, and a single config/php configuration file for a new domain, and it’s working as expected.

If the domain you’re using has HSTS enabled (which I suspect it has as I think you’re migrating an existing site), then your browser/client will:

  1. Force ‘upgrade’ the connection to HTTPS, so not connect to the HTTP site you have configured.
  2. Connect to the ‘fallback’ site instead, which provides HTTPS, although with the default server certificate.
  3. Serve the traffic using the fallback (AKA zz-mass-hosting) Apache configuration, which only provides the server-default PHP version.

You can test this on regular HTTP with something like:

curl --silent --hsts /dev/null --resolve exampledomain.co.uk:80:$(sympl-ip) http://exampledomain.co.uk/php-info.php

Alternatively, as you’re migrating from elsewhere, you can copy the SSL certificates from the old server and run sudo sympl-web-configure - Sympl will configure itself using the existing SSL certificates, which then allow your client to access the site via the HTTPS URL.

Thank you so much for the pointers above. Allow me to do a little more testing and I’ll revert…

Selectable versions of php is a real game changer when it comes to migrating sites.
However, I am receiving this error message this morning:

Domain: example.co.uk
Configuring site for PHP 7.3
Installing php7.3 …
E: Could not get lock /var/lib/dpkg/lock-frontend. It is held by process 23012 (apt-get)
E: Unable to acquire the dpkg frontend lock (/var/lib/dpkg/lock-frontend), is another process using it?
/usr/sbin/sympl-php-configure: line 143: /usr/sbin/php-fpm7.3: No such file or directory
Error encountered setting up default configuration for default. Skipping.

Applying configuration… done

I would have expected the output to be:

Domain: example.co.uk
Configuring site for PHP 7.3
Installing php7.3 …
Installing php7.3-cli …
Installing php7.3-fpm …
Installing php7.3-common …
Installing new package: php7.3-bz2
Installing new package: php7.3-curl
Installing new package: php7.3-gd
Installing new package: php7.3-imagick
Installing new package: php7.3-intl
Installing new package: php7.3-mbstring
Installing new package: php7.3-mysql
Installing new package: php7.3-xml
Installing new package: php7.3-xmlrpc
Installing new package: php7.3-zip
Configured with ‘default’ pool
Created pool link for domain
PHP-FPM enabled on example.co.uk
Pool configuration changed, will reload PHP 7.3

However the output from the command sudo update-alternatives --list php

/usr/bin/php5.6
/usr/bin/php7.3
/usr/bin/php8.2
/usr/bin/php8.3
/usr/bin/php8.4
/usr/bin/sympl-php-wrapper
sympl@sfbreathe:~$

But the error message above suggests that 7.3 wasn’t intalled correctly right?
Anyone else encountered this issue?

That’s correct.

As the error message states, apt was busy when it tried to install some of the needed packages - you should check what it was doing (possibly other installations have stalled) and then try running it again.

Ah right thanks, I’ve rebooted the server since to kill any stalled processes. Does Debian have a process history log? I’ve looked in apt history and it looks as though there were unattended upgrades in progress.

I’ve tried re-runing sudo sympl-php-configure
but I don’t see the expected output when running that command.
I get the impression the config files are in place but in reality the 7.3 packages haven’t been installed for use by example.com

A suggested way forward would be most appreciated?!

What output do you see? What output would you expect?

What gives you that impression?

If config/php-fpm exists, then the site will have an FPM config built using the relevant PHP version you’ve got configured.

You can use a typical phpinfo() against the domain (using hosts file entries or testing subdomain if the real domain is not pointed at the server at present) to confirm its working with the expected PHP version.

It would have been great to have seen something akin to the following from the onset albeit for PHP 7.3

Domain: example.co.uk
Configuring site for PHP 5.6
Installing php5.6 …
Installing php5.6-cli …
Installing php5.6-fpm …
Installing php5.6-common …
Installing new package: php5.6-bz2
Installing new package: php5.6-curl
Installing new package: php5.6-gd
Installing new package: php5.6-imagick
E: Sub-process /usr/bin/dpkg returned an error code (1)
Installing new package: php5.6-intl
Installing new package: php5.6-mbstring
Installing new package: php5.6-mcrypt
Installing new package: php5.6-mysql
Installing new package: php5.6-xml
Installing new package: php5.6-xmlrpc
Installing new package: php5.6-zip
Configured with ‘default’ pool
Created pool link for domain
PHP-FPM enabled on example.co.uk
Pool configuration changed, will reload PHP 5.6

Applying configuration… done

Instead, during the initial install, I received the following error message:

Configuring site for PHP 7.3
Installing php7.3 …
E: Could not get lock /var/lib/dpkg/lock-frontend. It is held by process 23012 (apt-get)
E: Unable to acquire the dpkg frontend lock (/var/lib/dpkg/lock-frontend), is another process using it?
/usr/sbin/sympl-php-configure: line 143: /usr/sbin/php-fpm7.3: No such file or directory
Error encountered setting up default configuration for default. Skipping.

Applying configuration… done

So I rebooted the server to kill any stalled processes. Apt history shows there were unattended upgrades in progress. Thereafter I tried re-running installation of 7.3 again; the result was no output but no error either which kinda led me to think that 7.3 hadn’t been installed or was broken.

However the presence of config/php-fpm did suggest the relevant PHP version had actually been installed.

I have since loaded the PHP 7.3 dependant site and surprisingly it works.

The inclusion of PHP FPM is a game changer when hosting dated sites, for me the configuration was a little quirky.

A big thanks to Paul for generating the replacement for Symbiosis

You’ll only get the notification that new packages are being installed when they’re installed. If you want to see what’s already been installed, you can use dpkg -l 'php*'.

Well there was certainly no indication that PHP 7.3 was being installed correctly whatsoever. I received the following:

Domain: example.co.uk
Configuring site for PHP 7.3
Installing php7.3 …
E: Could not get lock /var/lib/dpkg/lock-frontend. It is held by process 23012 (apt-get)
E: Unable to acquire the dpkg frontend lock (/var/lib/dpkg/lock-frontend), is another process using it?
/usr/sbin/sympl-php-configure: line 143: /usr/sbin/php-fpm7.3: No such file or directory
Error encountered setting up default configuration for default. Skipping.

Applying configuration… done

Ironically though, the output of the command dpkg -l ‘php*’ does show that 7.3 was installed.
I’m unsure why or what happened but at least I have selectable versions of PHP (5.6 and 7.3) working for 2 sites which is brilliant.

Update. I’ve just installed 7.3 for a separate domain on a separate server and the expected output showed without issue.

sympl@example:~$ sudo sympl-php-configure

Domain: example.co
Configuring site for PHP 7.3
Installing php7.3 …
Installing php7.3-cli …
Installing php7.3-fpm …
Installing php7.3-common …
Installing new package: php7.3-bz2
Installing new package: php7.3-curl
Installing new package: php7.3-gd
Installing new package: php7.3-imagick
Installing new package: php7.3-intl
Installing new package: php7.3-mbstring
Installing new package: php7.3-mysql
Installing new package: php7.3-xml
Installing new package: php7.3-xmlrpc
Installing new package: php7.3-zip
Configured with ‘default’ pool
Created pool link for domain
PHP-FPM enabled on example.co
Pool configuration changed, will reload PHP 7.3

Applying configuration… done