Here’s an oddity which baffled me and kept me from being able to use xdebug with PhpStorm for a while.
I installed a bunch of different versions of php on my Ubuntu VM. I used Ondřej Surý’s repository, rigging my vm to install them like this.
sudo apt install software-properties-common
sudo add-apt-repository ppa:ondrej/php
sudo apt update
sudo apt install -y php8.{0,1,2,3,4}
sudo apt install -y php8.{0,1,2,3,4}-{cli,fpm,curl,mysqlnd,gd,opcache,zip,intl,common,bcmath,imagick,igbinary,xmlrpc,readline,memcached,redis,mbstring,apcu,xml,dom,memcache,sqlite3}
sudo apt install -y php8.{0,1,2,3,4}-xdebug
Then, I followed the directions emitted by the installer and gave these commands to let the web server use php’s Fast Process Manager (fpm). fpm is good for production use. But this is my development VM, and I need the debugger.
sudo a2enconf php8.3-fpm # Don't do this.
sudo apache2ctl restart # Don't do this.
Big mistake. I couldn’t get xdebug to work from PhpStorm after I did that, even when I put the correct configuration data in the various php.ini
files. And, of course, it just didn’t work. It didn’t say why.
I fixed it, getting php 8.3 to run in my web server, by doing this:
sudo a2disconf php8.{0,1,2,3,4}-fpm
sudo a2dismod php8.{0,1,2,3,4}
sudo a2enmod php8.3
sudo apachectl restart
This disables the fpm configuration and simply enables the appropriate php module in apache. It’s easy to switch php versions by mentioning another php version besides php8.3
.
Notice that it’s necessary to change the command-line version of php as well if you’re changing php versions. Do that with this command.
sudo update-alternatives --set php /usr/bin/php8.3