program tip

XDebug를 비활성화하는 방법

radiobox 2020. 7. 24. 20:23
반응형

XDebug를 비활성화하는 방법


XDebug를 설치 한 후 서버 속도가 느려 졌다고 생각합니다. 따라서 가설을 테스트하기 위해 XDebug를 완전히 비활성화하고 싶습니다. 이 작업을 수행하는 방법에 대한 자습서를 검색했지만 해당 정보를 찾을 수 없습니다.


당신 php.ini을 찾아 XDebug를 찾으십시오 .

xdebug 자동 시작을 false로 설정

xdebug.remote_autostart=0  
xdebug.remote_enable=0

프로파일 러 비활성화

xdebug.profiler_enable=0

xdebug가 비활성화되었지만로드 된 경우에도 성능이 손실 될 수 있습니다 . 확장 프로그램 자체의 로딩을 비활성화하려면 php.ini에 주석을 추가해야합니다. 다음과 같은 항목을 찾으십시오.

zend_extension = "/path/to/php_xdebug.dll"

그리고 넣어 ;, 예를 들어 그것을 언급 ;zend_extension = ….

이 게시물 XDebug를 확인하십시오. 단일 .php 파일에 대한 원격 디버깅을 비활성화하는 방법은 무엇입니까?


우분투와 유사한 Linux 배포판에서 작동하는 쉬운 솔루션

sudo php5dismod xdebug
sudo service apache2 restart

에서 리눅스 우분투 ( - 어쩌면 또 다른이 테스트 아니에요 과) 유통 PHP 5 보드에, 당신은 사용할 수 있습니다 :

sudo php5dismod xdebug

그리고 PHP 7

sudo phpdismod xdebug

그런 다음 서버를 다시 시작하십시오.

sudo service apache2 restart

또한 xdebug_disable()코드에 추가 할 수 있습니다 . 시험:

if(function_exists('xdebug_disable')) { xdebug_disable(); }


구성 파일의 이름을 바꾸고 서버를 다시 시작했습니다.

$ mv /etc/php/7.0/fpm/conf.d/20-xdebug.ini /etc/php/7.0/fpm/conf.d/20-xdebug.i

$ sudo service php7.0-fpm restart && sudo service nginx restart

그것은 나를 위해 일했다.


php.ini에 주석 확장을 추가하고 Apache를 다시 시작하십시오. 다음은 간단한 스크립트입니다 (바로 가기를 할당 할 수 있음)

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');

xubuntu에서 CLI로 xdebug를 완전히 비활성화했습니다 ...

sudo rm /etc/php5/cli/conf.d/*xdebug*

CLI ini 파일의 Windows (WAMP) :

X:\wamp\bin\php\php5.x.xx\php.ini

코멘트 라인

; XDEBUG Extension

;zend_extension = "X:/wamp/bin/php/php5.x.xx/zend_ext/php_xdebug-xxxxxx.dll"

아파치는 처리 xdebug하고 작곡가는 처리하지 않습니다.


두 가지 옵션 :

1 : 초기화 스크립트에 다음 코드를 추가하십시오.

 if (function_exists('xdebug_disable')) {
           xdebug_disable();
         }

2 : php.ini에 다음 플래그 추가

 xdebug.remote_autostart=0
 xdebug.remote_enable=0

첫 번째 옵션이 권장됩니다.


PHP.ini를 찾아 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 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.


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


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

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:

Disabling Xdebug in MAMP Pro


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

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

참고URL : https://stackoverflow.com/questions/8754826/how-to-disable-xdebug

반응형