These instructions are for profiling a PHP application running on a CentOS-6 remote host using the php56u
php 5.6 packages from an OSX local host.
Install Xdebug for php56u
.
# yum -y install \
php56u-pecl-xdebug
Configure Xdebug.
# sed -i \
-e "s~^;\(xdebug.collect_params = \)0$~\12~" \
-e "s~^;\(xdebug.collect_return = \)0$~\11~" \
-e "s~^;\(xdebug.profiler_enable_trigger = \)0$~\11~" \
-e "s~^;\(xdebug.remote_enable = \)0$~\11~" \
-e "s~^;\(xdebug.show_exception_trace = \)0$~\11~" \
-e "s~^;\(xdebug.show_mem_delta = \)0$~\11~" \
-e "s~^;\(xdebug.trace_enable_trigger = \)0$~\11~" \
-e "s~^;\(xdebug.trace_format = \)0$~\10~" \
/etc/php.d/15-xdebug.ini
Restart Apache
# apachectl graceful
Install qcachegrind
via brew.
$ brew install qcachegrind
Install the Vagrant plugin vagrant-scp
.
$ vagrant plugin install vagrant-scp
Install the Chrome browser plugin.
Install Xdebug helper.
If remote debugging is also required, forward the Xdebug host:port from the remote VM to our local by running the following in a terminal.
$ vagrant ssh -- -R 9000:localhost:9000
Optionally, set the appropriate xdebug.idekey
configuration value. The example is for the PHPStorm IDE, for Atom the value should be xdebug-atom
.
$ export DBGP_IDEKEY=PHPSTORM
Using the "Xdebug helper" Chrome browser plugin, switch to profile mode and visit the URL of interest hosted on the remote VM. This should generate files like: /tmp/cachegrind.out.6772.08ffda
.
Using the vagrant-scp
plugin copy the output file to the local ~/Downloads
directory for analysis.
$ vagrant scp :/tmp/cachegrind.out.6772.08ffda ~/Downloads
Open the file for analysis with qcachegrind
.
$ qcachegrind ~/Downloads/cachegrind.out.6772.08ffda