LoginSignup
9
7

More than 5 years have passed since last update.

PHP New Relic でVirtual Hostごとに設定を変える方法

Posted at

New Relic って何よ?

  • サーバのパフォーマンス等を計測するサービス
  • rpm でちらっとインストールすると、計測しはじめ、New Relic の Webサイトで計測結果を見られる
  • 有料だけど、便利。個人用無料コースか、オープンソースのものがでないかな…

Apache の設定 (apache.conf/httpd.conf)

<VirtualHost 192.168.42.43>
  ServerName www.myvhost1.com
  DocumentRoot "/path/to/vhost1/"
  ...
  <IfModule php5_module>
       php_value newrelic.appname "Virtual Host 1"
  </IfModule>
</VirtualHost>

<VirtualHost 192.168.123.45>
  ServerName www.myvhost2.com
  DocumentRoot "/path/to/vhost2/"
  ...
  <IfModule php5_module>
    php_value newrelic.appname "Virtual Host 2"
  </IfModule>
</VirtualHost>

php-fpm の場合

[app1]
listen=/tmp/pool-app1.sock
php_value[newrelic.appname] = "My App 1"

[app2]
listen=/tmp/pool-app2.sock
php_value[newrelic.appname] = "My App 2"

[app3]
listen=/tmp/pool-app3.sock
php_flag[newrelic.enabled] = off

Nginx の場合

location /blog {
  fastcgi_param PHP_VALUE "newrelic.appname=My Blog";
  ...
}

location /shop {
  fastcgi_param PHP_VALUE "newrelic.appname=Shopping Cart";
  ...
}
  if (extension_loaded ('newrelic')) {
    newrelic_set_appname ("My App 1");
  }

参考

PHP per-directory INI settings - New Relic Documentation
https://newrelic.com/docs/php/per-directory-settings

9
7
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
9
7