「Pinpoint」- Agent,PHP,安装,CentOS 6.5 (Final)

解决方案

安装比较复杂,尤其是在旧系统上,比如 CentOS 6.5,主要问题是它所依赖的Thrift库的安装。

#1 安装Boost库

#!/bin/sh

# Install Boost 1.6.3+

################################################################################
# download
################################################################################
wget https://jaist.dl.sourceforge.net/project/boost/boost/1.63.0/boost_1_63_0.tar.gz
tar -zxvf boost_1_63_0.tar.gz
cd boost_1_63_0

################################################################################
# install
################################################################################
./bootstrap.sh
./b2 install --prefix=/usr/local

#2 安装Thrift库

#!/bin/sh

# Install Thrift 0.11.0+

################################################################################
# download
################################################################################
wget http://apache.fayea.com/thrift/0.11.0/thrift-0.11.0.tar.gz
tar zxvf thrift-0.11.0.tar.gz
cd thrift-0.11.0

################################################################################
# configure
################################################################################
./configure \
    --with-lua=no \
    --with-qt4=no \
    --with-qt5=no \
    -with-boost=/usr/local  \
    --with-boost-libdir=/usr/local/lib \
    --enable-tests=no \
    --with-c_glib=no

################################################################################
# make
################################################################################
make && make install

################################################################################
# export environment variable
################################################################################
export WITH_BOOST_PATH=/usr/local/
export WITH_THRIFT_PATH=/usr/local/
export LD_LIBRARY_PATH=//usr/local/lib/:$LD_LIBRARY_PATH

# !!! 如果你不知道Thrift安装到哪里了,可以使用find命令进行查找
# !!! find ./ -type f -name '*thrift*'
# !!! find ./ -type f -name '*boost*'

#3 安装PHP代理

#!/bin/sh

################################################################################
# 检查PHP环境
################################################################################
# Checking 「phpize」 and 「php-config」 is in your PATH.
# If not, install phpize and export in your system PATH.
# (eg:export PATH=/path to phpize/:/path to php-config/:$PATH)

################################################################################
# 构建安装
################################################################################
cd pinpoint_php

./Build.sh

make install

# If 2 running successfully, agent had installed into php module.
# Installing shared extensions:     /usr/local/php/lib/php/extensions/no-debug-non-zts-20131226/

################################################################################
# 修改php.ini配置,启用该扩展「extension=pinpoint.so」
################################################################################
# 略……,

常见错误汇总

# “none” is not exported by the List::Util module
automake 1.13

# Couldn’t find libtoolize!
How to fix “failed to run libtoolize: No such file or directory” error
yum install -y libtool

# ptrdiff_t not found or g++ not installed – cannot continue

# Dependencies
yum install automake libtool flex bison pkgconfig gcc-c++ openssl-devel

# automake version 1.11.1 is too old (need 1.13 or later)
automake 1.13

# configure: error: Bison version 2.5 or higher must be installed on the system!
bison 2.5

# ./configure: line 17395: syntax error near unexpected token `QT,
# ./configure: line 17395: ` PKG_CHECK_MODULES(QT, QtCore >= 4.3, QtNetwork >= 4.3, have_qt=yes, have_qt=no)’
Update thrift to 0.11.0 #9

yum install automake libtool flex bison pkgconfig gcc-c++

################################################################################
# check the aclocal configure
################################################################################
find /usr -name "pkg.m4"   # /usr/share/aclocal/pkg.m4
aclocal --print-ac-dir      # /usr/local/share/aclocal
# thrift/
aclocal -I ./aclocal -I /usr/share/aclocal/

################################################################################
# modify the bootstrap.sh
################################################################################
-aclocal -I ./aclocal
+aclocal -I ./aclocal -I /usr/share/aclocal/

参考文献

Pinpoint/Getting Started
Pinpoint C Agent
Building Apache Thrift on CentOS 6.5