# ElasticAPM SaaS: PHP agent fails to run

**URL:** <https://discuss.elastic.co/t/elasticapm-saas-php-agent-fails-to-run/304758>\
**Category:** APM\
**Tags:** php, elastic-agent\
**Created:** [May 15, 2022, 5:37pm UTC](https://discuss.elastic.co/t/elasticapm-saas-php-agent-fails-to-run/304758 "2022-05-15T17:37:23Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![dthapostle](https://avatars.discourse-cdn.com/v4/letter/d/d78d45/32.png) [@dthapostle](https://discuss.elastic.co/u/dthapostle)\
**Post date:** [May 15, 2022, 5:37pm UTC](https://discuss.elastic.co/t/elasticapm-saas-php-agent-fails-to-run/304758/1 "2022-05-15T17:37:23Z")

</div>

I configured Elastic APM agent using Elastic manual: [Set up the Agent | APM PHP Agent Reference [1.x] | Elastic](https://www.elastic.co/guide/en/apm/agent/php/current/setup.html)

I configured PHP 7.4 to use elastic\_apm.so and restarted PHP-FPM. It fails on every start/connectoin:

```auto
-- A start job for unit php-7.4-fpm.service has finished successfully.
-- 
-- The job identifier is 420341.
May 15 16:24:02 dev-wordpress-epuff-it-vm [20482]: [Elastic APM PHP Tracer] 2022-05-15 16:24:02.646271+00:00 [PID: 20482] [TID: 20482] [ERROR] [Util] [util_for_PHP.c:50] [loadPhpFile] php_stream_open_for_zend_ex failed. Return value: -1. filename: /root/eapmsrc/apm-agent-php-1.4.2/src/bootstrap_php_part.php
May 15 16:24:02 dev-wordpress-epuff-it-vm [20482]: [Elastic APM PHP Tracer] 2022-05-15 16:24:02.646396+00:00 [PID: 20482] [TID: 20482] [ERROR] [Util] [util_for_PHP.c:95] [loadPhpFile] Exiting...; resultCode: resultFailure (4);
May 15 16:24:02 dev-wordpress-epuff-it-vm [20482]: [Elastic APM PHP Tracer] 2022-05-15 16:24:02.646417+00:00 [PID: 20482] [TID: 20482] [ERROR] [C-to-PHP] [tracer_PHP_part.c:81] [bootstrapTracerPhpPart] Exiting...; resultCode: resultFailure (4);
May 15 16:24:02 dev-wordpress-epuff-it-vm [20482]: [Elastic APM PHP Tracer] 2022-05-15 16:24:02.646434+00:00 [PID: 20482] [TID: 20482] [ERROR] [Lifecycle] [lifecycle.c:472] [elasticApmRequestInit] Exiting...; resultCode: resultFailure (4);
May 15 16:24:02 dev-wordpress-epuff-it-vm [20482]: [Elastic APM PHP Tracer] 2022-05-15 16:24:02.677241+00:00 [PID: 20482] [TID: 20482] [ERROR] [Util] [util_for_PHP.c:142] [callPhpFunction] call_user_function failed. Return value: -1. PHP function name: `\Elastic\Apm\Impl\AutoInstrument\PhpPartFacade::shutdown'. argsCount: 0.
May 15 16:24:02 dev-wordpress-epuff-it-vm [20482]: [Elastic APM PHP Tracer] 2022-05-15 16:24:02.677319+00:00 [PID: 20482] [TID: 20482] [ERROR] [Util] [util_for_PHP.c:154] [callPhpFunction] Exiting...; resultCode: resultFailure (4);
May 15 16:24:02 dev-wordpress-epuff-it-vm [20482]: [Elastic APM PHP Tracer] 2022-05-15 16:24:02.677354+00:00 [PID: 20482] [TID: 20482] [ERROR] [C-to-PHP] [tracer_PHP_part.c:112] [shutdownTracerPhpPart] Exiting...; resultCode: resultFailure (4);
^C

```

---

<div class="post-metadata">

**Author:** ![Sergey\_Kleyman](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/sergey_kleyman/32/39333_2.png) [@Sergey\_Kleyman](https://discuss.elastic.co/u/Sergey_Kleyman)\
**Post date:** [May 18, 2022, 8:41am UTC](https://discuss.elastic.co/t/elasticapm-saas-php-agent-fails-to-run/304758/2 "2022-05-18T08:41:57Z")

</div>

Hi Aleksey,

Is it possible that the user under which application is running doesn't have permissions to access ` /root/eapmsrc/`? If you would like to make sure that is the root cause I've added diagnostics for the agent to log when `php_stream_open_for_zend_ex` fails. Then changes are already merged to the main branch but it's not released yet but you can use [the temporary binaries generated by CI](https://apm-ci.elastic.co/blue/organizations/jenkins/apm-agent-php%2Fapm-agent-php-mbp/detail/main/43/artifacts).

If the root causes is indeed the permissions I would advise to copy `/root/eapmsrc/` somewhere where any user has read access (don't forget to change `elastic_apm.bootstrap_php_part_file` configuration setting to point to the new location).

---

<div class="post-metadata">

**Author:** ![dthapostle](https://avatars.discourse-cdn.com/v4/letter/d/d78d45/32.png) [@dthapostle](https://discuss.elastic.co/u/dthapostle)\
**Post date:** [May 18, 2022, 1:45pm UTC](https://discuss.elastic.co/t/elasticapm-saas-php-agent-fails-to-run/304758/3 "2022-05-18T13:45:50Z")

</div>

@Sergey_Kleyman thank you. It seems to be real cause. I moved files to web root and APM started work.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [June 8, 2022, 9:46am UTC](https://discuss.elastic.co/t/elasticapm-saas-php-agent-fails-to-run/304758/4 "2022-06-08T09:46:42Z")

</div>

This topic was automatically closed 20 days after the last reply. New replies are no longer allowed.
