Last active
November 21, 2017 09:27
-
-
Save PavloZv/a0d97b7f48be1ad96c1573dc09d15cce to your computer and use it in GitHub Desktop.
Debug PHP коду на віддаленому сервері з Xdebug і PhpStorm
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| На сервері: | |
| інсталюємо xdebug; | |
| редагуємо документ xdebug.ini (/etc/php5/conf.d/; /etc/php/7.0/fpm/conf.d/); | |
| zend_extension=/usr/lib/php5/20100525/xdebug.so - якщо відсутній рядок у файліЮ то прописуємо | |
| xdebug.profiler_enable = 0 | |
| xdebug.remote_enable = 1 | |
| xdebug.remote_host = 127.0.0.1 | |
| xdebug.remote_port=9001 | |
| xdebug.remote_handler=dbgp | |
| xdebug.idekey=PHPSTORM | |
| На машині розробника: | |
| для браузера Chrome ставимо розширення Xdebug helper. В налаштуваннях розширення для параметра IDE key | |
| вказуємо(вибираємо) PHPSTORM; | |
| В PhpStorm: | |
| В File>Settings...>Languages & Frameworks>PHP>Debug вказуємо порт 9001; | |
| В Run>Edit Configurations... додаємо PHP Web Aplication заповнюємо поле Name, Поле Server нажимаємо ... | |
| і налаштовуємо Name, Host(віддаленої машини), відмічаємо Use path mappings і навпроти локальної папки проекту вказуємо | |
| повний шлях до папки проекту на віддаленому сервері. | |
| Для підняття ssh тунелю вводимо команду ssh -R 9001:127.0.0.1:9001 user@server (user@server - user і домен або ip-адрес); | |
| Для перевірки ssh тунелю на стороні сервера виконати команду telnet 127.0.0.1 9001, маємо побачити: | |
| Trying 127.0.0.1... | |
| Connected to 127.0.0.1. | |
| Escape character is '^]'. | |
| Гарячі клавіші виходу з telnet — Ctrl + ] > exit; | |
| Можливі помилки: | |
| telnet: Unable to connect to remote host: Connection refused - Перенаправлення не працює | |
| Connection closed by foreign host - IDE не слухає порт | |
| Послідовність... | |
| 1 Піднімаємо shh тунель; | |
| 2 Включаємо прослушку в PhpStorm; | |
| 3 Відкриваємо в браузері сторінку сайту і включаємо debug. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment