Install Xdebug extension only for PHP7.1

2019-07-13 12:28发布

问题:

I have PHP 7.1 on Ubuntu 16.04 installed. When I'm trying to install Xdebug by using apt-get install php-xdebug, I'm getting xdebug.ini in directories 5.6, 7.0 and 7.1.

I don't need /php/5.6/mods-available/xdebug.ini and /php/7.0/mods-available/xdebug.ini extensions, because I'm using only PHP 7.1 version.

Any ideas?

Thanks.

回答1:

It's because php-xdebug is ambiguous and will download the default package which will contain multiple versions for php compatibility, try going to xdebug site and download the code, then make/build it https://xdebug.org/



回答2:

I used these commands to get xdebug installed and running on 7.2

git clone git://github.com/xdebug/xdebug.git && cd xdebug 
apt-get install -y php7.2-dev && ./rebuild.sh
service php7.2-fpm restart


回答3:

Xdebug has an awesome wizard(form) where you can just paste the content of your php.ini or results of php -i command and get step by step instructions on how to go about setting it up.

In my experience, it's the most reliable and error-free method and I have used in vagrant instances with both mod-php and php-fpm 7.1 & 7.2 versions without any issues.

https://xdebug.org/wizard.php



回答4:

try:

apt install php7.1-xdebug

If I good understood, you don't want to have many xdebug ini files. Ubuntu supports many php versions, which you can switch if you need. If you want to have single xdebug configuration file, I recommend to create catalog mods-available in /etc/php, move xdebug.ini there and make symbolic link from all required paths (for apache2, cli for every php version you need) - for example, for PHP 7.1 with Apache

ln -s /etc/php/mods-available/xdebug.ini /etc/php/7.1/apache2/conf.d/20-xdebug.ini