PHP tracer manual Installation

PHP tracer manual Installation

Before you start

Datadog strongly encourages you to install the PHP extension through the pre-built packages. If you still prefer to manually install the PHP tracer, follow the steps below.

Install from the .tar.gz archive

Download the latest .tar.gz from the release page.

From the location you downloaded the package:

$ tar -xf datadog-php-tracer.tar.gz -C /

Automatic INI file setup

In case of a standard PHP installation, the command below will automatically install and configure the extension.

$ /opt/datadog-php/bin/post-install.sh

Verify that the extension has been correctly installed

$ php --ri=ddtrace

ddtrace

Datadog PHP tracer extension
...

If the PHP installation is not standard the above steps might fail. In this case proceed with the manual steps below.

Manual INI file setup

Steps in this paragraph are only required if the Automatic INI file setup did not work.

Modify the php.ini configuration file to make the ddtrace extension available in the PHP runtime. To find out where the INI file is, run the following command:

$ php --ini

Configuration File (php.ini) Path: /usr/local/etc/php/7.2
Loaded Configuration File:         /usr/local/etc/php/7.2/php.ini
...

Add the following lines to the php.ini file.

extension=/opt/datadog-php/extensions/ddtrace-<PHP_EXTENSION_VERSION>.so
ddtrace.request_init_hook=/opt/datadog-php/dd-trace-sources/bridge/dd_wrap_autoloader.php

The correct value for PHP_EXTENSION_VERSION depends on the PHP version.

PHP VersionPHP_EXTENSION_VERSION
5.420100412
5.520121113
5.620131106
7.020151012
7.120160303
7.220170718
7.320180731
7.420190902
8.020200930

Install from source

Download the source code tar.gz or .zip file from the releases page and unzip the file. Then compile and install the extension with the commands below.

$ cd /path/to/dd-trace-php
$ phpize
$ ./configure --enable-ddtrace
$ make
$ sudo make install

Modify the INI file

Modify the php.ini configuration file to make the ddtrace extension available in the PHP runtime. To find out where the INI file is, run the following command:

$ php --ini

Configuration File (php.ini) Path: /usr/local/etc/php/7.2
Loaded Configuration File:         /usr/local/etc/php/7.2/php.ini
...

Add the following line to the php.ini file.

extension=ddtrace.so

Depending on how you manually installed the PHP tracer, you also need to add this line to the php.ini file.

# If you installed from .tar.gz
ddtrace.request_init_hook=<PATH_TO_EXTRACTED_TAR_GZ>/dd-trace-sources/bridge/dd_wrap_autoloader.php

# If you installed from source
ddtrace.request_init_hook=<PATH_TO_SOURCES>/bridge/dd_wrap_autoloader.php

After restarting the web server/PHP SAPI (e.g., $ sudo apachectl restart, $ sudo service php-fpm restart, etc.) the extension is enabled. To confirm that the extension is loaded, run:

$ php --ri=ddtrace

ddtrace

Datadog PHP tracer extension
...

Visit a tracing-enabled endpoint of your application and view the APM UI to see the traces.

Note: It might take a few minutes before traces appear in the UI.