# How to configure apm agent for multiple php sites on one machine

**URL:** <https://discuss.elastic.co/t/how-to-configure-apm-agent-for-multiple-php-sites-on-one-machine/313508>\
**Category:** APM\
**Tags:** php\
**Created:** [September 2, 2022, 6:54am UTC](https://discuss.elastic.co/t/how-to-configure-apm-agent-for-multiple-php-sites-on-one-machine/313508 "2022-09-02T06:54:50Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![lhb6540](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/lhb6540/32/104727_2.png) [@lhb6540](https://discuss.elastic.co/u/lhb6540)\
**Post date:** [September 2, 2022, 6:54am UTC](https://discuss.elastic.co/t/how-to-configure-apm-agent-for-multiple-php-sites-on-one-machine/313508/1 "2022-09-02T06:54:50Z")

</div>

Follow this page [Configuration | APM PHP Agent Reference [1.x] | Elastic](https://www.elastic.co/guide/en/apm/agent/php/current/configuration.html)  
It is easy to configure apm agent for one php site on the machine by configuring php.ini, but if I have multiple php apps on one machine, how should I differentiate the service\_name of different apps

---

<div class="post-metadata">

**Author:** ![alanstorm](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/alanstorm/32/77134_2.png) [@alanstorm](https://discuss.elastic.co/u/alanstorm)\
**Post date:** [September 8, 2022, 12:03am UTC](https://discuss.elastic.co/t/how-to-configure-apm-agent-for-multiple-php-sites-on-one-machine/313508/2 "2022-09-08T00:03:18Z")

</div>

That's a great question @lhb6540 -- at a high level you'll want to have each application set a different value for the service\_name via different php.ini files or another of PHP's mechanisms for setting ini variables. _How_ you'll do this will depend on how you're running PHP.

If you're not sure how to set ini values, we can help with that if you can answer a few questions. Do you know if you're running PHP via an Apache module (mod\_php)? Or are you using PHP-FPM? Or maybe something newer like swoole? Let us know and we'll get you the information you need to get up and running with as many apps as you want 🙂

---

<div class="post-metadata">

**Author:** ![lhb6540](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/lhb6540/32/104727_2.png) [@lhb6540](https://discuss.elastic.co/u/lhb6540)\
**Post date:** [September 8, 2022, 8:26am UTC](https://discuss.elastic.co/t/how-to-configure-apm-agent-for-multiple-php-sites-on-one-machine/313508/3 "2022-09-08T08:26:03Z")

</div>

I use php-fpm 7.4 on centos7  
I configured nginx in front of multiple sites and forwarded to localhost:9000 via fastcgi  
My php configuration file directory is /etc/opt/remi/php74/php.ini (I configure elastic agent related information here), and the php-fpm configuration file directory is /etc/opt/remi/php74/php -fpm.d/www.conf

---

<div class="post-metadata">

**Author:** ![alanstorm](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/alanstorm/32/77134_2.png) [@alanstorm](https://discuss.elastic.co/u/alanstorm)\
**Post date:** [September 8, 2022, 7:54pm UTC](https://discuss.elastic.co/t/how-to-configure-apm-agent-for-multiple-php-sites-on-one-machine/313508/4 "2022-09-08T19:54:40Z")

</div>

Thanks for that information @lhb6540!

Since you're using PHP-FPM your best bet will be to take advantage of PHP's [.user.ini](https://www.php.net/manual/en/configuration.file.per-user.php) files. These files allow you to set `php.ini` configuration values on a per directory basis, and should allow you to set a different `elastic_apm.service_name` value for each of your applications (as outlined [in the PHP Agent docs](https://www.elastic.co/guide/en/apm/agent/php/current/configuration.html))

If you need more information please let us know. Otherwise good luck with your sites/apps and thanks for giving Elastic APM a spin.

---

<div class="post-metadata">

**Author:** ![lhb6540](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/lhb6540/32/104727_2.png) [@lhb6540](https://discuss.elastic.co/u/lhb6540)\
**Post date:** [September 9, 2022, 4:34am UTC](https://discuss.elastic.co/t/how-to-configure-apm-agent-for-multiple-php-sites-on-one-machine/313508/5 "2022-09-09T04:34:12Z")

</div>

Thanks,this method solved the problem

---

<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:** [September 30, 2022, 12:34am UTC](https://discuss.elastic.co/t/how-to-configure-apm-agent-for-multiple-php-sites-on-one-machine/313508/6 "2022-09-30T00:34:57Z")

</div>

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