Installing xdebug for lsphp81 on ubuntu 22.04

I'm using the litespeedtech/openlitespeed:1.7.16-lsphp81 docker image with ubuntu 22.04 and I'm trying to set up testing for Wordpress.
The tests run, now I need to set up coverage. This needs xdebug, so I need to install it.

The easy method would be to run apt install php-xdebug but this also installs php 8.1.2-1ubuntu2.8 replacing the previously installed php 8.1.9. This then breaks the tests (server cannot connect to the db).

Another option I found was to follow the xdebug installation wizard. This tells me to install apt-get install php-dev which also installs php 8.1.2-1ubuntu2.8 so I end up with the same problem. Then I found I can apt install lsphp81-dev but this also installs the ubuntu php version...

What would be the correct way to install xdebug for lsphp81 ?
I have tried the method from the first link, but compiling it requires php-dev, or lsphp81-dev in this case. But when I install lsphp81-dev from the package manager, it again installs php 8.1.2-1ubuntu2.8. I can't seem to be able to switch back to lsphp81 after that.

Is there another way to install lsphp81-dev on ubuntu so it does not switch to 8.1.2-1ubuntu2.8?

As for the second link, I don't understand what they are doing there :confused:


I just installed lsphp81-dev on a Ubuntu system, it may install some php8.1 packages, but it won't cause any issues. Not sure what's the switch bothers you? If you want to specify lsphp81, can also run lsphp with full command /usr/local/lsws/lsphp81/bin/php, or, set a soft link by pointing /usr/bin/php to /usr/local/lsws/lsphp81/bin/php