Skip to content

Instantly share code, notes, and snippets.

@henryonsoftware
Last active February 3, 2024 21:31
Show Gist options
  • Star 8 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save henryonsoftware/066d8282daaf8c2ae281ce010e3e5404 to your computer and use it in GitHub Desktop.
Save henryonsoftware/066d8282daaf8c2ae281ce010e3e5404 to your computer and use it in GitHub Desktop.
Install xdebug on Ubuntu

Install Xdebug on Ubuntu.

Install xdebug

Run php -i and copy the output of the following command and paste it on https://xdebug.org/wizard.php. Follow the instructions there to install xDebug.

Example:

  1. Download xdebug-2.6.0.tgz: wget http://xdebug.org/files/xdebug-2.6.0.tgz

  2. Unpack the downloaded file with tar -xvzf xdebug-2.6.0.tgz

  3. Run: cd xdebug-2.6.0

  4. Run: phpize

    As part of its output it should show:

    Configuring for:

    ...

    Zend Module Api No: 20170718

    Zend Extension Api No: 320170718

    If it does not, you are using the wrong phpize. Please follow this FAQ entry and skip the next step.

  5. Run: ./configure

  6. Run: make

  7. Run: cp modules/xdebug.so /usr/lib/php/20170718

  8. Edit /etc/php/7.2/cli/php.ini and add the line zend_extension = /usr/lib/php/20170718/xdebug.so

Config xdebug

Open sudo vi /etc/php/7.2/fpm/conf.d/20-xdebug.ini and add some lines

zend_extension = /usr/lib/php/20170718/xdebug.so
xdebug.remote_enable = 1
xdebug.remote_connect_back = 1
xdebug.remote_port = 9000

Note:

  • 20170718 can change depend on your xdebug version. Get it on xdebug wizard above.
  • If 20-xdebug.ini wasn't in /etc/php/7.2/fpm/conf.d/20-xdebug.ini. Try find it at /etc/php/7.2/mods-available/xdebug.ini, edit xdebug.ini and run sudo ln -s /etc/php/7.2/mods-available/xdebug.ini /etc/php/7.2/fpm/conf.d/20-xdebug.ini to create symlink between them.

Restart the server

Run sudo service php7.2-fpm restart command.

@thinhphamwiki
Copy link

thanks, it works

@zaratedev
Copy link

Awesome, it works for me!

@thanosasimo
Copy link

works on debian (rasbian) too! Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment