Skip to content

Instantly share code, notes, and snippets.

@engmsaleh
Last active May 8, 2021 10:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save engmsaleh/bfdade7feaaf41cc3184902a62a0a360 to your computer and use it in GitHub Desktop.
Save engmsaleh/bfdade7feaaf41cc3184902a62a0a360 to your computer and use it in GitHub Desktop.
PhpStorm 2020.3 with Xdebug 2.9.8 Setup on Ubuntu 2020

Instruction collected from multiple sources, there may be unnecessary steps, but that what worked with me after 4 days of stuggling :), so I'm recording it all

Install Xdebug 2.9.8 using pecl

sudo apt -y install php7.4-dev php-pear
pecl install xdebug-2.9.8

Create xdebug.ini file in mods-available

touch /etc/php/7.4/mods-available/xdebug.ini
zend_extension=/usr/lib/php/20190902/xdebug.so

# automatically start debugger on every request
xdebug.remote_enable=1
xdebug.remote_autostart=1
xdebug.remote_port=9001
# send all debug requests to 127.0.0.1, remote_connect_back should be turned off
xdebug.remote_connect_back = 0
xdebug.remote_host=127.0.0.1
xdebug.remote_log=/var/log/xdebug.log

Add Xdebug to php.ini in php cli ini file

/etc/php/7.4/cli/php.ini

[xdebug]
zend_extension=/usr/lib/php/20190902/xdebug.so

Make the symbolic link for xdebug.ini

ln -s /etc/php/7.4/mods-available/xdebug.ini /etc/php/7.4/fpm/conf.d/20-xdebug.ini
ln -s /etc/php/7.4/mods-available/xdebug.ini /etc/php/7.4/cli/conf.d/20-xdebug.ini

Restart services

service nginx restart
service php7.4-fpm restart

PHPStorm side

Preferences > PHP > Debug

  • Make sure that port is 9001 as in xdebug.ini file
  • Uncheck the option Pass required configuration ... in advanced settings
  • Connect using SSH Tunnel ssh -R 9001:localhost:9001 root@example.com
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment