Upgrade & Secure Your Future with DevOps, SRE, DevSecOps, MLOps!

We spend hours scrolling social media and waste money on things we forget, but won’t spend 30 minutes a day earning certifications that can change our lives.
Master in DevOps, SRE, DevSecOps & MLOps by DevOpsSchool!

Learn from Guru Rajesh Kumar and double your salary in just one year.


Get Started Now!

How to install & Configure Datadog APM with PHP based application (WordPress) in linux?

Prerequisite

Step 1- Install DD Agent and Start it

Step 2- Choose your language- Offcourse PHP

Step 3- Install the PHP client for APM datadog tracing

Reference:
- https://github.com/DataDog/dd-trace-php/releases

$ cd /opt
$ wget https://github.com/DataDog/dd-trace-php/releases/download/0.53.0/datadog-php-tracer-0.53.0-1.x86_64.rpm
$ rpm -ivh datadog-php-tracer-0.53.0-1.x86_64.rpmCode language: JavaScript (javascript)

Step 4 – Make sure following Spec to avoid an ERROR

$ vi /opt/lampp/etc/php.ini
extension=/opt/datadog-php/extensions/ddtrace-.so - WRONG

$ more /opt/lampp/logs/php_error_log

# Take latest version of ddtrace using "ls /opt/datadog-php/extensions/"
$ vi /opt/lampp/etc/php.ini
extension=/opt/datadog-php/extensions/ddtrace-20200930.so - RIGHT

$ /opt/lampp/lampp restartCode language: PHP (php)

Step 5 – Validate ddtrace is enabled or not

$ export PATH=$PATH:/opt/lampp/bin/
$ php --version
$ php -m | grep ddtrace
Code language: JavaScript (javascript)

Step 4 – Modify Apache Configuration to set Datadog APM Meta data for a application

vi /opt/lampp/etc/httpd.conf

SetEnv DD_SERVICE 'wordpress'
SetEnv DD_ENV 'dev'
SetEnv DD_VERSION 'latest'
SetEnv DD_TRACE_SAMPLE_RATE '1'
SetEnv DD_TRACE_DEBUG true

$ /opt/lampp/lampp restartCode language: JavaScript (javascript)

Step 5 – Create a load on http://13.233.196.197/wordpress/ using Jmeter

$ netstat -tulpn | grep LISTEN
$ curl http://127.0.0.1:8126
$ datadog-agent config | head -n 35

By default the Datadog Agent is enabled in your datadog.yaml file under apm_enabled: true and listens for trace traffic at localhost:8126Code language: JavaScript (javascript)

Error & Solution – 1

[root@ip-172-31-25-121 opt]# rpm -ivh datadog-php-tracer-0.53.0-1.x86_64.rpm
Preparing...                          ################################# [100%]
Updating / installing...
   1:datadog-php-tracer-0.53.0-1      ################################# [100%]
### PHP version
/var/tmp/rpm-tmp.hSDzSh: line 34: -d: command not found
### Installing Datadog PHP tracing extension (ddtrace)
###
### Logging  -i to a file
###
/var/tmp/rpm-tmp.hSDzSh: line 34: -d: command not found
/var/tmp/rpm-tmp.hSDzSh: line 34: -d: command not found
/var/tmp/rpm-tmp.hSDzSh: line 34: -d: command not found
/var/tmp/rpm-tmp.hSDzSh: line 34: -d: command not found
/var/tmp/rpm-tmp.hSDzSh: line 34: -d: command not found
/var/tmp/rpm-tmp.hSDzSh: line 34: -d: command not found
/var/tmp/rpm-tmp.hSDzSh: line 34: -d: command not found
###
### conf.d folder not found falling back to appending extension config to main "php.ini"
/var/tmp/rpm-tmp.hSDzSh: line 34: -d: command not found
### Failed enabling ddtrace extension
###
### The extension has been installed but couldn't be enabled
### Try adding the extension manually to your PHP - php.ini - configuration file
### e.g. by adding following line:
###
###     extension=/opt/datadog-php/extensions/ddtrace-.so
###
### Note that your PHP API version must match the extension's API version
### PHP API version can be found using following command
###
###      -i | grep 'PHP API'
###
[root@ip-172-31-25-121 opt]# php
bash: php: command not found

SOLUTION
--------------
rpm -e datadog-php-tracer-0.53.0-1.x86_64
rm -rf datadog-php
export PATH=$PATH:/opt/lampp/bin/
php --version

extension=/opt/datadog-php/extensions/ddtrace-.so

===========================================
DD_TRACE_CLI_ENABLED=true DD_SERVICE='test' DD_ENV='dev' DD_VERSION='1' DD_TRACE_SAMPLE_RATE='1' php -r 'echo "Hello PHP";'Code language: PHP (php)

Certification Courses

DevOpsSchool has introduced a series of professional certification courses designed to enhance your skills and expertise in cutting-edge technologies and methodologies. Whether you are aiming to excel in development, security, or operations, these certifications provide a comprehensive learning experience. Explore the following programs:

DevOps Certification, SRE Certification, and DevSecOps Certification by DevOpsSchool

Explore our DevOps Certification, SRE Certification, and DevSecOps Certification programs at DevOpsSchool. Gain the expertise needed to excel in your career with hands-on training and globally recognized certifications.