I think that my server became slow since I installed XDebug. So, in order to test my hypothesis I want to disable XDebug completely. I've been searching for tutorials on how to do this but I can't find such information.
27 Answers
Find your php.ini
and look for XDebug.
Set xdebug autostart to false
xdebug.remote_autostart=0
xdebug.remote_enable=0
Disable your profiler
xdebug.profiler_enable=0
Note that there can be a performance loss even with xdebug disabled but loaded. To disable loading of the extension itself, you need to comment it in your php.ini. Find an entry looking like this:
zend_extension = "/path/to/php_xdebug.dll"
and put a ;
to comment it, e.g. ;zend_extension = …
.
Check out this post XDebug, how to disable remote debugging for single .php file?

- 9,036
- 2
- 44
- 49

- 5,748
- 3
- 32
- 45
-
Thanks! I found that my problem was APC, my memory was low apparently. You are right, xdebug is part of PHP, not a module of Apache. Now everything is running fine. – Beto Aveiga Jan 06 '12 at 09:21
-
1@Uday and what if I can't find any of this in my php.ini. I've checked everywhere inside /etc/php including with grep search. – Haralan Dobrev Mar 15 '13 at 10:03
-
1@HaralanDobrev Check phpinfo() to see if xdebug is actually enabled. if it is, check if you have any additional ini files attached to php.ini file. Additionally make sure you are editing correct ini file. it is possible to have these files at multiple locations. – Uday Sawant Mar 15 '13 at 11:01
-
18@UdaySawant I was able to disable it after commenting the line `zend_extension=/usr/lib/php5/20090626+lfs/xdebug.so` from `/etc/php5/conf.d/xdebug.ini`. However neither in `/usr/lib/php5` nor in `/etc` the lines specified in the answer are available. – Haralan Dobrev Mar 15 '13 at 14:58
-
7Actually, it's better to not load the extension at all, and only load it, if needed. XDebug actually slows things down a lot, even if disabled. One might not feel performance has degraded that much, when debugging/profiling some scripts that create a web page, but with daemon scripts, it shows a lot. I just wrote a blog post on why not loading it at all, is better, here: http://bit.ly/14SaWpp – thesilentman Aug 18 '13 at 10:24
-
@thesilentman I read your blog post. Need to test this on my own. Just for a cross check, EasyPHP uses two separate files one for web pages (apache) and one for console apps. Hope you have edited correct ini file. – Uday Sawant Aug 19 '13 at 07:09
-
@UdaySawant Hmm... In my installation (dev 13.1) there's only one ini. The one in runningversion (for the active version) folder. However every time I changed something, I also did a php -i to check. BTW, the testfiles are in this gist:https://gist.github.com/frankmayer/6268139 I've updated the Blog post accordingly – thesilentman Aug 19 '13 at 11:48
-
Thats not the full solution for me... see here which Flag was missing: http://stackoverflow.com/a/30189745/1256697 – suther Nov 11 '15 at 11:16
-
That no longer is the correct answer. See mine down below. – theking2 Jul 19 '22 at 11:56
An easy solution working on Linux distributions similar to Ubuntu
sudo php5dismod xdebug
sudo service apache2 restart

- 7,369
- 8
- 45
- 72

- 1,057
- 1
- 7
- 2
-
11Could you please elaborate more your answer adding a little more description about the solution you provide? – abarisone Apr 13 '15 at 11:37
-
3That command is for ubuntu not centOS. Should provide that explanation because you are not the only person use the same linux distro. – MaXi32 Dec 08 '15 at 07:06
-
You should really note that this only works on certain OSes, in this case it appears to be Ubuntu. It definitely doesn't work on my Mac either way. – Matt Fletcher Jun 03 '16 at 08:27
-
1this is for apache2 and not for CLI. These might have different php.ini files – Adib Aroui Nov 18 '16 at 17:17
-
6Depending of your PHP version, you should enter `$ sudo phpdismod xdebug` – alexandre-rousseau Aug 29 '17 at 08:35
-
2This answer only applies to PHP when it's being used with Apache's mod-php. – John Hunt Oct 23 '18 at 08:21
In Linux Ubuntu(maybe also another - it's not tested) distribution with PHP 5 on board, you can use:
sudo php5dismod xdebug
And with PHP 7
sudo phpdismod xdebug
And after that, please restart the server:
sudo service apache2 restart

- 2,178
- 23
- 28
-
1PHP 7 removed xdebug from the ini file, I believe. So this answer helped me. – Keith Holliday Nov 11 '16 at 15:41
-
1Worked for PHP7. Commenting the xdebug settings out in the php.ini didn't work. – Kalob Taulien Jul 25 '17 at 14:57
-
1Didn't work. WARNING: Module xdebug ini file doesn't exist under /etc/php/7.1/mods-available – dxvargas Apr 09 '19 at 20:00
-
php -v; phpdismod -v 7.4 xdebug; Change 7.4 to php version according to echo first command. – Oleg Apanovich Nov 12 '20 at 13:54
Also, you can add xdebug_disable()
to your code. Try:
if(function_exists('xdebug_disable')) { xdebug_disable(); }

- 1,310
- 11
- 9
-
39This only disables displaying stacktraces, it does not actually disable xdebug (terribly named function, I know) – BlueRaja - Danny Pflughoeft Jun 05 '13 at 22:16
-
This is an awesome way to deal with a lot of situations. Thanks for this even if it doesn't really meat OP's needs. – Jake Jan 29 '16 at 23:28
-
6
-
-
1
-
-
1@BinarWeb because people could think this function disables the whole xdebug and improves performance, but it's not – Fogus Mar 19 '20 at 08:44
I renamed the config file and restarted server:
$ mv /etc/php/7.0/fpm/conf.d/20-xdebug.ini /etc/php/7.0/fpm/conf.d/20-xdebug.ini.bak
$ sudo service php7.0-fpm restart && sudo service nginx restart
It did work for me.

- 5,564
- 3
- 36
- 37
-
This worked for me, except in /etc/php/7.0/cli/conf.d instead of /etc/php/7.0/fpm/conf.d – Will May 02 '16 at 15:53
-
This will also work on php 7.2,9 on mac osx or on centos vagrant. Just rename to xdebug.ini to xdebug.ini.old or something else – vknyvz Aug 30 '18 at 21:34
-
-
1For the non-fpm PHP: sudo mv /etc/php/7.4/apache2/conf.d/20-xdebug.ini /etc/php/7.4/apache2/conf.d/20-xdebug.ini.bak – Vlad Pavlov Oct 13 '20 at 09:16
Comment extension in php.ini and restart Apache. Here is a simple script (you can assign shortcut to it)
xdebug-toggle.php
define('PATH_TO_PHP_INI', 'c:/xampp/php/php.ini');
define('PATH_TO_HTTPD', 'c:/xampp/apache/bin/httpd.exe');
define('REXP_EXTENSION', '(zend_extension\s*=.*?php_xdebug)');
$s = file_get_contents(PATH_TO_PHP_INI);
$replaced = preg_replace('/;' . REXP_EXTENSION . '/', '$1', $s);
$isOn = $replaced != $s;
if (!$isOn) {
$replaced = preg_replace('/' . REXP_EXTENSION . '/', ';$1', $s);
}
echo 'xdebug is ' . ($isOn ? 'ON' : 'OFF') . " now. Restarting apache...\n\n";
file_put_contents(PATH_TO_PHP_INI, $replaced);
passthru(PATH_TO_HTTPD . ' -k restart');

- 443
- 4
- 9
-
In order to really disable XDebug completely, this one is the correct answer, see my comment in @UdaySawant's answer. – thesilentman Aug 18 '13 at 10:27
in xubuntu I totally disabled xdebug for the CLI with this...
sudo rm /etc/php5/cli/conf.d/*xdebug*

- 1,982
- 22
- 33
-
note: this really helped me out for composer updates. needed to disable xdebug for performance issues. – Artistan May 08 '14 at 13:11
-
3this works for laravel homestead, too. to disable xdebug in homestead / laravel simply comment out the section in the file `/etc/php5/cli/conf.d/20-xdebug.ini` – ulkas Oct 14 '14 at 08:41
-
Worth mentioning if you run php script from terminal that runs another php script from terminal via `passthru` function with xdebug enabled, xdebug might hang and stop the execution. – Gherman Apr 09 '15 at 08:14
-
1Not sure what the downvote was for, this appears to be the only way to disable xdebug for the CLI and not other environments. Although I'd use `unlink` over `rm` if it's available. – Andy Feb 05 '16 at 00:03
-
4I wouldn't rm/unlink the ini, instead do as ulkas suggested, `sudo nano /etc/php/7.0/cli/conf.d/20-xdebug.ini` and comment it out. – Justin Jun 02 '16 at 16:02
On Windows (WAMP) in CLI ini file:
X:\wamp\bin\php\php5.x.xx\php.ini
comment line
; XDEBUG Extension
;zend_extension = "X:/wamp/bin/php/php5.x.xx/zend_ext/php_xdebug-xxxxxx.dll"
Apache will process xdebug
, and composer will not.

- 944
- 16
- 29
If you are using php-fpm
the following should be sufficient:
sudo phpdismod xdebug
sudo service php-fpm restart
Notice, that you will need to tweak this depending on your php version. For instance running php 7.0 you would do:
sudo phpdismod xdebug
sudo service php7.0-fpm restart
Since, you are running php-fpm there should be no need to restart the actual webserver. In any case if you don't use fpm then you could simply restart your webserver using any of the below commands:
sudo service apache2 restart
sudo apache2ctl restart

- 29,115
- 11
- 72
- 93
-
1Greate!! sudo phpdismod xdebug sudo service php7.2-fpm restart this solved my problem – matinict Dec 30 '20 at 08:57
Ubuntu 16.04 remove xdebug from PHP.
Find your php.ini file and make sure xdebug is there:
grep -r "xdebug" /etc/php/
This might come up with different versions, if so run php -v
to find your version.
Edit the php.ini file, like:
sudo vi /etc/php/5.6/mods-available/xdebug.ini
Comment the line:
//zend_extension=xdebug.so
Save the file

- 4,103
- 5
- 44
- 48
-
Yes, you definitely need the first command to find out all the (wrong) xdebug configurations you did. Thanks! – Aaron Liu Feb 18 '20 at 04:31
-
Inspired by PHPStorm right click on a file -> debug -> ...
www-data@3bd1617787db:~/symfony$
php
-dxdebug.remote_enable=0
-dxdebug.remote_autostart=0
-dxdebug.default_enable=0
-dxdebug.profiler_enable=0
test.php
the important stuff is -dxdebug.remote_enable=0 -dxdebug.default_enable=0

- 11,909
- 13
- 77
- 115
-
1All the other solutions about faffing with filesystem and then this. :raised_hands: True legend! This will even work in a `docker exec` and `docker run`. – MrMesees May 27 '21 at 07:31
-
1for xdebug 3, use `xdebug.mode=off` or, in this case `-dxdebug.mode=off` – Sandra Aug 04 '22 at 08:20
Since xdebug 3 came out the settings in pnp.ini
have slightly changed.
Setting:
xdebug.mode=off
Will disable all processing According to the docs:
Nothing is enabled. Xdebug does no work besides checking whether functionality is enabled. Use this setting if you want close to 0 overhead.

- 2,174
- 1
- 27
- 36
Two options:
1: Add following code in the initialization Script:
if (function_exists('xdebug_disable')) {
xdebug_disable();
}
2: Add following flag to php.ini
xdebug.remote_autostart=0
xdebug.remote_enable=0
1st option is recommended.

- 8,835
- 2
- 47
- 46
Find your PHP.ini and look for XDebug.
normally in Ubuntu its path is
/etc/php5/apache2/php.ini
Make following changes (Better to just comment them by adding ; at the beginning )
xdebug.remote_autostart=0
xdebug.remote_enable=0
xdebug.profiler_enable=0
then restart your server again for Ubuntu
sudo service apache2 restart

- 61
- 1
- 5
Disable xdebug
For PHP 7: sudo nano /etc/php/7.0/cli/conf.d/20-xdebug.ini
For PHP 5: sudo nano /etc/php5/cli/conf.d/20-xdebug.ini
Then comment out everything and save.
UPDATE -- Disable for CLI only
As per @igoemon's comment, this is a better method:
PHP 7.0 (NGINX)
sudo mv /etc/php/7.0/cli/conf.d/20-xdebug.ini /etc/php/7.0/cli/conf.d/20-xdebug.ini.old
sudo service nginx restart
Note: Update the path to your version of PHP.

- 26,443
- 16
- 111
- 128
-
Is is not a solution, because /etc/php/7.0/cli/conf.d/20-xdebug.ini is just a symlink and if you edit it, you edit the original file which is common for cli and non-cli. I think the right solution is simple delete the symlink. – igoemon Sep 03 '16 at 18:37
-
I created this bash script for toggling xdebug. I think it should work at least on Ubuntu / Debian. This is for PHP7+. For PHP5 use php5dismod / php5enmod.
#!/bin/bash
#
# Toggles xdebug
#
if [ ! -z $(php -m | grep "xdebug") ] ; then
phpdismod xdebug
echo "xdebug is now disabled"
else
phpenmod xdebug
echo "xdebug is now enabled"
fi
# exit success
exit 0

- 3,939
- 6
- 48
- 61
-
Very helpful script. You could mention that a service restart is required for the changes to take effect, which isn't immediately obvious (at least, it was required for my system). – Katai Sep 02 '22 at 08:13
You can disable Xdebug on PHP CLI on runtime using the -d
flag:
php -d xdebug.mode=off -i | grep xdebug.mode
Result: xdebug.mode => off => off
Example, running unit tests with Xdebug disabled, so it's faster:
php -d xdebug.mode=off ./vendor/bin/phpunit
You can also create an alias for it to make it easier to use.

- 15,821
- 7
- 92
- 86
I ran into a similar issue. Sometimes, you wont find xdebug.so in php.ini. In which case, execute phpinfo()
in a php file and check for Additional .ini files parsed
. Here you'll see more ini files. One of these will be xdebug's ini file. Just remove (or rename) this file, restart apache, and this extension will be removed.

- 16,964
- 16
- 76
- 97
I had following Problem: Even if I set
xdebug.remote_enable=0
Xdebug-Error-Message-Decoration was shown.
My solution:
xdebug.default_enable=0
Only if I use this Flag, Xdebug was disabled.

- 12,600
- 4
- 62
- 99
(This is for CentOS)
Rename the config file and restart apache.
sudo mv /etc/php.d/xdebug.ini /etc/php.d/xdebug.ini.old
sudo service httpd restart
Do the reverse to re-enable.

- 16,605
- 26
- 134
- 210
Disable xdebug only for certain PHP version or sapi. On this case PHP 7.2 fpm
sudo phpdismod -v 7.2 -s fpm xdebug
sudo service php7.2-fpm nginx restart

- 562
- 3
- 13
If you are using MAMP Pro on Mac OS X it's done via the MAMP client by unchecking Activate Xdebug under the PHP tab:

- 573
- 2
- 8
- 20
So, yeah, all what you need, just comment line in INI file like zend_extension=xdebug.so
or similar.
Comments can be made by adding semicolon.
But, such kind of answer already added, and I'd like to share ready solution to switch Xdebug status.
I've made quick switcher for Xdebug. Maybe it would be useful for someone.

- 2,847
- 2
- 32
- 42
For WAMP, click left click on the Wamp icon in the taskbar tray. Hover over PHP and then click on php.ini and open it in your texteditor.
Now, search for the phrase 'zend_extension' and add ; (semicolon) in front it.
Restart the WAMP and you are good to go.

- 576
- 11
- 23
Apache/2.4.33 (Win64) PHP/7.2.4 myHomeBrew stack
At end of php.ini I use the following to manage Xdebug for use with PhpStorm
; jch ~ Sweet analizer at https://xdebug.org/wizard.php for matching xdebug to php version.
; jch ~ When upgrading php versions check if newer xdebug.dll is needed in ext directory.
; jch Renamed... zend_extension = E:\x64Stack\PHP\php7.2.4\ext\php_xdebug-2.6.0-7.2-vc15-x86_64.dll
zend_extension = E:\x64Stack\PHP\php7.2.4\ext\php_xdebug.dll
; jch !!!! Added the following for Xdebug with PhpStorm
[Xdebug]
; zend_extension=<full_path_to_xdebug_extension>
; xdebug.remote_host=<the host where PhpStorm is running (e.g. localhost)>
; xdebug.remote_port=<the port to which Xdebug tries to connect on the host where PhpStorm is running (default 9000)>
xdebug.remote_enable=1
xdebug.remote_host=localhost
xdebug.remote_port=9000
xdebug.profiler_enable=1
xdebug.profiler_output_dir="E:\x64Stack\Xdebug_profiler_output"
xdebug.idekey=PHPSTORM
xdebug.remote_autostart=1
; jch ~~~~~~~~~To turn Xdebug off(disable) uncomment the following 3 lines restart Apache~~~~~~~~~
;xdebug.remote_autostart=0
;xdebug.remote_enable=0
;xdebug.profiler_enable=0
; !!! Might get a little more speed by also commenting out this line above...
;;; zend_extension = E:\x64Stack\PHP\php7.2.4\ext\php_xdebug.dll
; so that Xdebug is both disabled AND not loaded

- 41
- 4
For those interested in disabling it in codeship, run this script before running tests:
rm -f /home/rof/.phpenv/versions/$(phpenv version-name)/etc/conf.d/xdebug.ini
I was receiving this error:
Use of undefined constant XDEBUG_CC_UNUSED - assumed 'XDEBUG_CC_UNUSED' (this will throw an Error in a future version of PHP)
which is now gone!

- 5,476
- 7
- 51
- 88
In CLI:
sudo phpdismod xdebug
disable xdebug
sudo phpenmod xdebug
enable xdebug
And restart the server

- 19
- 3