Phpstorm+xdebug Remote Debugging code on a Linux machine __linux

Source: Internet
Author: User
Tags php source code

First, Background introduction :

Recently in the understanding of Web site navigation items, in order to be able to more in-depth understanding of the subject, so I chose to view the site navigation code, but only a blunt view of the PHP source code is relatively jerky, I hope to be able to use the IDE tool to step through the code to understand the entire site navigation function to achieve.

To achieve these goals, I chose Phpstorm+xdebug to remotely debug code on Linux. And before the White Pine sharing Phpstorm+xdebug debugging method is different, the former debugging webserver is built in the local environment Php+apache debugging, and I have to face the problems are:

1. URL navigation code is deployed in the Linux virtual machine environment.

2. The code running environment is: linux+nginx+php-fpm+redis+superphp Environment support

In order to solve the above method, the following methods are adopted.

Second, the configuration method :

1. Compile configuration on Linux virtual machine xdebug

1) Download Xdebug. Access http://xdebug.org/download.php, download the corresponding Xdebug source code.

2) # TAR-XVF xdebug-2.3.2.tgz

3) #cd Xdebug

4 Run PHP directory/bin/phpize

5) Configure the bin path for the./configure--enable-xdebug--with-php-config=/php/php-config

6) Make

7) make install

2. Configure Xdebug on a Linux virtual machine

Add the following configuration in the php.ini file:

zend_extension= "/search/php5/lib/php/extensions/no-debug-non-zts-20121212/xdebug.so"// xdebug.so Path, please configure it according to the installed PHP directory

[Xdebug]

Xdebug.idekey=phpstorm

Xdebug.remote_connect_back = 1//If this is turned on, the following xdebug.remote_host parameters are ignored

xdebug.remote_host=10.129.157.29//Note Here is the IP of the client's ip< that is the IDE's machine, not your web server>

Xdebug.remote_enable=on

Xdebug.remote_port = 9001//Note here is the client's port < The IDE's machine IP, not your web server>

Xdebug.remote_handler = DBGP

Xdebug.auto_trace = 1

Xdebug.collect_includes = 1

Xdebug.collect_params = 1

Xdebug.collect_return = 1

xdebug.default_enable = 1

Xdebug.collect_assignments = 1

Xdebug.collect_vars = 1

Xdebug.remote_autostart = 1

Xdebug.show_local_vars = 1

Xdebug.show_exception_trace = 0

3. Download Phpstorm

4. Configuring in Phpstorm

1 Configure Debug Item: Open file->setings->php| Debug. In the Xdebug configuration entry on the right, configure the port number that is the same as the server Xdebug, as in the previous example, 9001.

2) Configure the server item .

A. Open file->setings->php| Servers on the right click +, add server,host:web server domain name or IP, the port is generally 80.

B. Check the use pathmapping below to fill in the path of the code on the server on the absolute path to. Here must be set OH. Otherwise, a file cannot be found and an error occurs, leading to debugging termination.

Note: Because superphp is also referenced in the URL navigation, you need to add superphp in project and set the superphp path on the server.

3 Configure the Web application Pilot : Open run->editconfigurations-> Add a PHP webapplication tuning pilot.

At this point, the configuration is complete.

5. After setting the breakpoint in the code, click Run->debug, the browser is tuned up, and the breakpoint in Phpstorm is interrupted, then you can F5 single step debugging.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.