been working in ubuntu 16.04 and i have apache2 with php installed.
all is good and i can switch version from php 7.0 - 7.4 without any issues.
now i have to setup a project developed using php5.6.
installed it normally
sudo-apt install php5.6
switch php for cli using
sudo update-alternatives --config php
was able to switch successfully. but when i change the php for apache.
sudo a2dismod php7.1 ; sudo a2enmod php5.6 ; sudo service apache2 restart
I can no longer access my localhost. it only returns an error.
This site can’t be reached
localhost refused to connect.
switching back to other php version (7.x) will fix it. but i need to use php5.6.
also no errors in /var/log/apache2/error.log
did i do some mistakes on php5.6 installation or there are some apache configs missing?
Thank you in advance
found the cause of the error. you should make sure no other php7.x are enabled on your apache. ive been switching versions and didnt realize i left 7.4 enabled.
sudo a2dismod php7.0, sudo a2dismod php7.1, sudo a2dismod php7.2........
until i made sure that everything was disabled aside from php5.6
I installed Xdebug on PHP 7.3 using pecl install xdebug
When I add these settings to /etc/php/7.3/apache2/php.ini and reload Apache the page fails and says no data sent to server.
xdebug.var_display_max_children=-1
xdebug.var_display_max_data=-1
zend_extension="/usr/lib/php/20180731/xdebug.so"
xdebug.remote_enable=1
xdebug.remote_handler=dbgp
xdebug.remote_mode=req
xdebug.remote_host=127.0.0.1
xdebug.remote_port=9000
xdebug.halt_level=E_WARNING|E_NOTICE|E_USER_WARNING|E_USER_NOTICE
xdebug.scream=1
Not sure why it's not working.
(In the original version of your question, your configuration was commented out, now you've edited that bit out, leaving the next couple of paragraphs kinda out of the loop)
Despite the documentation stating that the has character (#) is no longer recognized as a valid comment character since PHP 7.0:
it seems that php will happily treat those lines as commented nonetheless in configuration files. Everything afer the hash is ignored by the interpreter.
So those configuration lines are completely ineffective.
To verify that your configuration is being loaded, create a simple file like this:
<php
phpinfo();
Loading this file will tell you everything about PHPs configuration. If Xdebug has been successfully loaded, you'll see something like this:
And down below the configuration settings loaded:
These are the most important settings, that actually load and enable the Xdebug extension:
zend_extension="/usr/lib/php/20180731/xdebug.so"
xdebug.remote_enable=1
Important: You need to check that /usr/lib/php/20180731/xdebug.so actually exists, and if not find the actual location of your xdebug module.
The next line assumes that the webserver and the browser are installed on the same machine on the same IP, which might be true for a simple setup:
xdebug.remote_host=127.0.0.1
As an alternative, you can tell Xdebug to connect back to whichever IP has made the orginal request
xdebug.remote_connect_back=On
With the following line you are telling on which port your IDE is listening to. It's 9000 by default, so you'll normally would not need to set it unless you need to listen to a non-standard port (e.g. debugging several projects at the same time, against different interpreters). But normally, you can omit this line safely:
xdebug.remote_port=9000
Once the module is loaded and enabled, you can also configure some Xdebug settings using an environment variable. Specifically xdebug.remote_host, xdebug.remote_port, xdebug.remote_mode and xdebug.remote_handler
E.g:
export XDEBUG_CONFIG="remote_host=192.168.0.3 remote_port=9005"
xdebug is not compatible with php7.3 for releases < 2.7
you may install xdebug beta version which is make-compatible with php7.3:
pecl install xdebug-beta
https://bugs.xdebug.org/view.php?id=1584
Update:
XDEBUG has released a new version, and it has different configurations. The new version is compatible with PHP>=7.4. Check it out:
https://xdebug.org/docs/install
To install xdebug on php7.3 run the following commands:
sudo update-alternatives --set phpize /usr/bin/phpize7.3
sudo update-alternatives --set php /usr/bin/php7.3
sudo update-alternatives --set php-config /usr/bin/php-config7.3
Now download source code and install by running the following commands:
cd /tmp
wget http://xdebug.org/files/xdebug-2.8.0.tgz
tar -xzvf xdebug-2.8.0.tgz
cd xdebug-2.8.0
phpize
./configure
sudo make
sudo make install
today I upgraded ubuntu 14.10 to 15.04 and xdebug is not working anymore. I use eclipse Luna Service Release 2.
I've tried reinstalling xdebug through pecl, apt-get, even manual install following http://xdebug.org/wizard.php instructions (pasting my phpinfo() output).
I have xampp, in /opt/lampp directory.
I've tried several locations for "zend_extension" in /opt/lampp/etc/php.ini such as zend_extension=/usr/lib/php5/20131226/xdebug.so and zend_extension =/opt/lampp/lib/php/extensions/no-debug-non-zts-20121212/xdebug.so
When I hit debug on eclipse, the browser receives the order, and the parameters ?XDEBUG_SESSION_START=ECLIPSE_DBGP&KEY= are included in the url, but the execution will not stop on any breakpoint.
When I run phpinfo() xdebug is not showing as an installed module.
any hints?
I removed the phpinfo() output for clarification after posting the answer.
Finally I found no solution, so I had to remove all the lamp package, and I reinstalled everything as independent modules following this tutorial: http://www.unixmen.com/how-to-install-lamp-stack-on-ubuntu-15-10/, then I did this to install xdebug:
1.- Install xdebug extension for PHP
$ sudo apt-get install php5-xdebug
2.- Check the location of "xdebug.so" module, which is kept under "/usr/lib/php5/20131226", where the number depends on the PHP version.
3.- The installation creates a configuration file "/etc/php5/mods-available/xdebug.ini" with the following line (otherwise, create one):
zend_extension=xdebug.so
NOTE: in the previous version, you need to specify the full-path filename, e.g., "zend_extension=/usr/lib/php5/20121212/xdebug.so".
Include the following lines into "xdebug.ini" to enable remote debugging from Eclipse PDT:
xdebug.remote_enable = On
xdebug.remote_port = 9000
xdebug.remote_host = 127.0.0.1
Recall that Apache loads PHP configuration files "/etc/php5/apache2/php.ini" and "/etc/php5/apache2/conf.d/*.ini". To enable the above xdebug configuration file, create the following symlink in "/etc/php5/apache2/conf.d":
$ cd /etc/php5/apache2/conf.d
$ sudo ln -s ../../mods-available/xdebug.ini 20-xdebug.ini
$ ls -l
lrwxrwxrwx 1 root root 31 Sep 11 19:42 20-xdebug.ini -> ../../mods-available/xdebug.ini
4.- Check PHP configuration file "/etc/php5/apache2/php.ini" for the following settings:
; Turn on the error display for development system,
; but not for production system.
display_errors = On
; Format error in HTML
html_errors = On
5.- Restart the Apache2:
$ sudo service apache2 restart
And it works like a charm
For now Xdebug (Please only use uptil Xdebug 2.6, because later versions had some issues with debugging); only work up to php 7.2 (i.e. less than 7.3). So if you had any other version installed like php 7.3 or 7.4 then you had to also install php 7.2 along side your current php version (mostly because now by default latest version is installed through apt). and then update in between alternatives.
To set PHP 7.0 as the default, run
update-alternatives --set php /usr/bin/php7.0
To set PHP 7.2 as the default, run
update-alternatives --set php /usr/bin/php7.2
To set PHP 7.3 as the default, run
update-alternatives --set php /usr/bin/php7.3
To set PHP 7.4 as the default, run
update-alternatives --set php /usr/bin/php7.4
Before we can configure Apache to use PHP 7.2, we need to disable the new (or old) version of PHP by typing
a2dismod php7.4
Now enable the newly installed PHP 7.2 version with the following command:
a2enmod php7.2
Restart the Apache web server for the changes to take effect:
sudo systemctl restart apache2
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.
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?
An easy solution working on Linux distributions similar to Ubuntu
sudo php5dismod xdebug
sudo service apache2 restart
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
Also, you can add xdebug_disable() to your code. Try:
if(function_exists('xdebug_disable')) { xdebug_disable(); }
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.
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');
in xubuntu I totally disabled xdebug for the CLI with this...
sudo rm /etc/php5/cli/conf.d/*xdebug*
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.
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
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
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
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.
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
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.
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
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.
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.
(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.
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.
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
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.
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:
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.
Xdebug Switcher
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.
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
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!
In CLI:
sudo phpdismod xdebug
disable xdebug
sudo phpenmod xdebug
enable xdebug
And restart the server