Linux 2(WSL2)のWindowsサブシステムを介したXdebug

カットの下には、PHP、xdebugをWindows Subsystem For Linux 2(WSL 2)で操作するための便利な環境をセットアップする方法についての小さなメモがあります。





まず、ちょっとした歴史



私はUbuntuの世界に非常に長い間住んでいました。すべてが実行されるのと同じシステムで、PHP、NodeJS、GoLangですぐに書くのは非常に快適です。しかし、残念ながら、管理職に就くと、Windowsでのみ機能する多くのソフトウェアを使用する必要があるという事実につながります。



" SSH". PhpStorm, ssh Ubuntu — .



— :) 100500 Phpstorm dell e7390:) , sftp.



WSL2 (http://habr.com/ru/news/t/516054) .







WSL Windows . Microsoft



PowerShell wsl Linux, Windows





Ubuntu:



sudo apt update
sudo apt upgrade
sudo apt install apache2
sudo apt install php libapache2-mod-php php-mysql php-xml php-curl
sudo a2enmod rewrite


/mnt/d/work/projects/__. , , Linux, . , , .



( ), , php Linux, NTFS . .



  1. WSL . /home/user/projects
  2. ( GIT). /home/user/projects/test
  3. \\wsl$\Ubuntu "Ubuntu" — . \\wsl$

  4. PhpStorm

  5. ( , xdebug)

  6. Automatic upload

  7. WSL


— . = . . , rsync , . , — :)



Apache, . , , php-fpm nginx — .



xdebug



xdebug . .



  1. xdebug sudo apt-get php-xdebug



  2. sudo nano /etc/php/7.2/mods-available/xdebug.ini



    zend_extension=xdebug.so
    xdebug.remote_enable=true
    xdebug.remote_host=wsl.host
    xdebug.remote_port=9002
    xdebug.profiler_enable=1
    xdebug.profiler_output_dir=/tmp
    xdebug.remote_autostart=on
    xdebug.idekey=PHPSTORM
    xdebug.remote_log=/tmp/xdebug.log


  3. apache sudo service apache2 restart







xdebug . /etc/hosts wsl.host. IP , windows.



, , xdebug.remote_host=127.0.0.1, WSL , 127.0.0.1 linux linux, windows. , PhpStorm :)



, gif- .





-



github C# , Windows . , - Windows .



"" bash , IP /etc/hosts linux WSL — github.



. " ", systemd rc.local wsl . , .



  1. /startup.sh , chmod +x /startup.sh
  2. sudo ( /etc/hosts )
  3. sudo /startup.sh /etc/profile


wsl , /etc/hosts wsl.host linux windows. - , .



wsl , — cat /etc/hosts - :

172.26.64.1 wsl.host



xdebug PhpStorm Windows



WSL PhpStorm



  1. File->Settings->Languages & Framework->PHP









    "From Docker, Vagrant, VM, WSL, Remote"







    WSL







    , xdebug





  2. File->Settings->Languages & Framework->PHP->Debug

    , WSL ( 9002, 9000)















    advanced "Pass required configuration options.."







, — wsl.host 127.0.0.1 .



, .. HTTP ini .



— .





  1. breakpoint index.php
  2. ,















  3. Php Script













,







したがって、いくつかの異なるソース、記事、要点をふるいにかけて、PHPを使用するときに「ほぼ理想的な」作業環境にたどり着きました。改善/改善できることがあれば、コメントまたは他の方法で私に連絡してください




All Articles