Newrelic PHP Application 安裝記錄


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
# 建立安裝用的目錄
cd ~/downloads && mkdir 0001-newrelic && cd 0001-newrelic

# 由上面選擇要下載的
# http://download.newrelic.com/php_agent/release/
wget http://download.newrelic.com/php_agent/release/newrelic-php5-X.X.X.X-OS.tar.gz
tar zxvf newrelic-php5-X.X.X.X-OS.tar.gz
cd newrelic-php5-X.X.X.X-OS

# 直接修改安裝 Script
# 因為 PHP 不是安裝在預設的路徑裡
vim newrelic-install

add_to_path /opt/php-5.4/bin
if [ -n "${NR_INSTALL_PATH}" ]; then

在這兩行中加入

add_to_path /path/to/php/bin

# 進行安裝
./newrelic-install

# 如無意外應該會有類似的提示
# 選擇 1 為安裝
New Relic PHP Agent Installation (interactive mode)
===================================================

Please select from one of the following options:

1) Install New Relic Agent and Daemon
2) Uninstall New Relic Agent and Daemon

0) Exit

Enter choice (1-2, 0 to exit): 1

# 應該會找到 PHP 並提示輸入 license key
Enter New Relic license key (or leave blank): SOME/KEY

# 回車後會有進一步的訊息.並提示安裝完成.切回 NewRelic 網上控制台應該為已激活
Found a valid PHP in : /path/to/php/bin
PHP Version : 5.4.0
Module API version : 20090626
Module directory : /path/to/php/lib/php/extensions/no-debug-non-zts-20130630
Zend Thread Safety : no
CLI ini file : /path/to/php/lib/php.ini
Install Status : OK

# 此外還會安裝 設定 和 Daemon
~/downloads/0001-newrelic/newrelic-php5-X.X.X.X-OS/scripts/newrelic.ini.template

Install daemon ([y]es, [n]o or x to e[x]it): y

# 最後提示 Log 位置
/var/log/newrelic/newrelic-daemon.log
/var/log/newrelic/php_agent.log

# 查看 phpinfo 應該會看見多了 New Relic 的資料
# 如果沒看見.就要重啟 php-fpm 或者 webserver (!!!!!!)
<?php phpinfo() ?>