Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

Karl's avatar
Level 2

Disable xdebug

I have a server provisioned by using Forge.

However, I have one old site on the server which wasn't built using Laravel or any other framework. The problem with this is that xdebug is showing errors for undefined variables, etc.

Is there any way in which I can disable xdebug for this one site?

0 likes
9 replies
dabernathy89's avatar

I'm by no means an expert, but I believe the only way to disable xdebug is to remove it from php.ini.

1 like
thepsion5's avatar

If you have a single setup/bootstrap file, you can always just call xdebug_disable() at the top of the script.

fideloper's avatar

To disable xdebug for PHP-FPM and CLI (all use cases, in fact):

sudo php5dismod xdebug
sudo service php5-fpm restart

To disable xdebug specifically for PHP-FPM:

sudo php5dismod  -s fpm xdebug
sudo service php5-fpm restart

The "SAPI" fpm (defined with -s fpm) relates directly to modules found in /etc/php5/fpm/conf.d. CLI-specific modules are found in /etc/php5/cli/conf.d/

All modules inside of cli/conf.d and fpm/conf.d are symlinks (aliases) to modules in /etc/php5/mods-available.

This is Ubuntu/Debians convention as a means for enabling modules for each use case (each SAPI) indivisually. There is a separate php.ini configuration and separate set of modules loaded in CLI, FPM and (altho not applicable with Forge) Apache's mod_php.

This will be the best way to accomplish your goal, as @dabernathy89's reply doesn't take into account Ubuntu/Debian's way of handling the loading and configuration of modules and @thepsion5's method will mean you have more code in your code base which is server-specific. (Not to trash your replies, but I think they're likely to be more confusing! :D <3 )

16 likes
cbj4074's avatar

For those running PHP 7 on Debian or Ubuntu, the commands vary slightly:

$ sudo phpdismod xdebug
$ sudo service php7.0-fpm restart
5 likes
huglester's avatar

Strange that forge enables XDEBUG by default. Is it really needed in production?

driesvints's avatar

It says /bin/bash: phpdismod: command not found for me and I cannot seem to figure out why. I also can't seem to find any source on how to install it or find a way to disable Xdebug another way. Running PHP 7.1.1 on Ubuntu 16.04.

Can anyone help me with this?

Grummfy's avatar

for debian based most of the time is just removing the link inside /etc/php/VERSION/SAPI/config.d

so you should remove /etc/php/7.1//config.d/-xdebug* to remove every xdebug module

or simply remove the package ;)

in pure cli you can also do php -d xdebug.profiler_enable=0 -d xdebug.default_enable=0 myphpscript.php

Please or to participate in this conversation.