[Osaka/Yokohama/Tokushima] Looking for infrastructure/server side engineers!

[Osaka/Yokohama/Tokushima] Looking for infrastructure/server side engineers!

[Deployed by over 500 companies] AWS construction, operation, maintenance, and monitoring services

[Deployed by over 500 companies] AWS construction, operation, maintenance, and monitoring services

[Successor to CentOS] AlmaLinux OS server construction/migration service

[Successor to CentOS] AlmaLinux OS server construction/migration service

[For WordPress only] Cloud server “Web Speed”

[For WordPress only] Cloud server “Web Speed”

[Cheap] Website security automatic diagnosis “Quick Scanner”

[Cheap] Website security automatic diagnosis “Quick Scanner”

[Reservation system development] EDISONE customization development service

[Reservation system development] EDISONE customization development service

[Registration of 100 URLs is 0 yen] Website monitoring service “Appmill”

[Registration of 100 URLs is 0 yen] Website monitoring service “Appmill”

[Compatible with over 200 countries] Global eSIM “Beyond SIM”

[Compatible with over 200 countries] Global eSIM “Beyond SIM”

[If you are traveling, business trip, or stationed in China] Chinese SIM service “Choco SIM”

[If you are traveling, business trip, or stationed in China] Chinese SIM service “Choco SIM”

[Global exclusive service] Beyond's MSP in North America and China

[Global exclusive service] Beyond's MSP in North America and China

[YouTube] Beyond official channel “Biyomaru Channel”

[YouTube] Beyond official channel “Biyomaru Channel”

How to install xdebug with vagrant + vscode

Good evening!
This is Nagato from the System Development Department.

This time, I will explain in an easy-to-understand manner how to introduce xdebug, which is a favorite of PHP programmers, into a vagrant + vscode environment.
The installation environment is as follows.
vagrant : 2.2.9
php : 8.0.3
vscode : 1.55.1
xdebug : 3.0.4

Advance preparation

The supported version of xdebug varies depending on the php version, so check in advance.
To confirm, please copy and paste all the information output by "php -i" to the site below.
https://xdebug.org/wizard

Copy the download link of the resulting xdebug file that is output.

install xdebug

Use wget to obtain the file from the download link you copied in advance.

cd /usr/local/src wget http://xdebug.org/files/xdebug-3.0.4.tgz

Introducing php-devel to use phpize command

sudo yum install php-devel

After extracting the downloaded file, execute the commands in order.

tar -xzvf xdebug-3.0.4.tgz phpize ./configure make sudo make install

After executing the make command, an xdebug.so file will be created in the modules directory of the current directory, so copy it.

sudo cp modules/xdebug.so /usr/lib64/php/modules

The installation is now complete.

Add settings to php.ini

Next, add xdebug settings to the php.ini file.
Instead of directly writing the configuration information in the php.ini file, create a new ini file for xdebug and load it.

sudo vi /etc/php.d/15-xdebug.ini

Add the following settings to the newly created ini file.
Please note that the settings to be added and how to specify them differ depending on the version of xdebug.
Also, for version 2 series, the xdebug port number is set to "9000" by default, but it
may already be in use, so we recommend setting it to something other than "9000".
In version 3 series, the default has been changed to "9003", so I think it is okay without specifying it.

For version 2 series

[xdebug] zend_extension=/usr/lib64/php/modules/xdebug.so xdebug.defaul_enable=1 xdebug.remote_enable=1 xdebug.remote_port=9001 xdebug.remote_handler=dbgp xdebug.remote_autostart=1 xdebug.remote_connect_back=1

For version 3 series

[xdebug] zend_extension=/usr/lib64/php/modules/xdebug.so xdebug.client_port=9003 xdebug.mode=debug xdebug.start_with_request=yes

Settings in vscode

Open the extension installation screen with "ctrl+shift+x" on vscode,
search for "php debug", and install it.

Once the extension installation is complete,
click "Run" ⇒ "Add configuration" on the toolbar at the top of vscode, select "php"
".vscode/launch.json" will be created in the current directory, so open it. Masu.


I think the default settings are as follows.

{ // Learn the available attributes using IntelliSense. // Hover to display the description of an existing attribute. // For more information check: https://go.microsoft.com/fwlink/?linkid=830387 "version": "0.2.0", "configurations": [ { "name": "Listen for Xdebug", "type": "php", "request": "launch", "port": 9001 }, { "name": "Launch currently open script", "type": "php", "request" : "launch", "program": "${file}", "cwd": "${fileDirname}", "port": 9000 } ] }

Here, specify the port number set in the php.ini file in the "port" field of "Listen for Xdebug".
If not set, specify the default port number.
xdebug2 series: 9000
xdebug3 series: 9003

lastly

I have opened the system development service site "SEKARAKU Lab" to which I belong.
Beyond is a one-stop service for everything from server design and construction to operation, so if you have any trouble with server-side development, please feel free to contact us.
SEKARAKU Lab: [https://sekarakulab.beyondjapan.com/](https://sekarakulab.beyondjapan.com/)

All settings are now complete and xdebug is ready to use.
That's all, thank you for your hard work.

If you found this article helpful , please give it a like!
3
Loading...
3 votes, average: 1.00 / 13
6,156
X facebook Hatena Bookmark pocket
[2025.6.30 Amazon Linux 2 support ended] Amazon Linux server migration solution

[2025.6.30 Amazon Linux 2 support ended] Amazon Linux server migration solution

The person who wrote this article

About the author

Masaki Nagato

Joined as a new graduate in April 2020.
My name is Nagato and I belong to the System Development Department. He mainly develops web systems and game APIs using PHP.
Qualification: PHP7 engineer certification beginner level