CentOS7 安装 SkyAPM-php-sdk v4.1.2

环境:

  • CentOS Linux release 7.7.1908 (Core)
  • PHP 7.2.10
  • 升级之后:gcc (GCC) 10.2.1 20200804 (Red Hat 10.2.1-2)
  • 升级之后:cmake version 3.19.1

upgrade gcc

root用户

yum install centos-release-scl
yum search gcc # 查看gcc可用版本有哪些
yum install devtoolset-10-gcc*
scl enable devtoolset-10 bash  # 仅当前终端有效
gcc --version
cc --version
c++ --version

upgrade cmake

root用户

curl -L -o cmake-3.19.1.tar.gz https://github.com/Kitware/CMake/releases/download/v3.19.1/cmake-3.19.1.tar.gz
tar -zxf cmake-3.19.1.tar.gz
./bootstrap
make -j$(nproc)
make install
ldconfig # refresh shared library cache.
make clean
cmake --version

install protobuf and grpc

普通用户

git clone --depth 1 -b v1.34.x https://github.com/grpc/grpc.git
cd grpc
git submodule update --init  --recursive

#### protobuf
sudo yum install automake libtool
cd third_party/protobuf
./autogen.sh
./configure
make -j$(nproc)
sudo make install
sudo ldconfig
make clean

#### grpc
cd ../../
mkdir -p cmake/build
cd cmake/build
cmake ../.. -DBUILD_SHARED_LIBS=ON -DgRPC_INSTALL=ON
make -j$(nproc)
sudo make install
sudo ldconfig
make clean

[option] re-install php

直接使用自己 LEMPEnv 构建的 php 7.2.10

install SkyAPM-php-sdk v4.1.2

普通用户

sudo yum install boost boost-devel boost-doc
curl -Lo v4.1.2.tar.gz https://github.com/SkyAPM/SkyAPM-php-sdk/archive/v4.1.2.tar.gz
tar -zxf v4.1.2.tar.gz
cd SkyAPM-php-sdk-4.1.2
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/lib:/usr/local/lib64
phpize
./configure
make
make install

图

Add SkyWalking config to php.ini and restart php-fpm

编辑 php.ini:

; Loading extensions in PHP
extension=skywalking

[skywalking]
; enable skywalking
skywalking.enable = 1
; Set skyWalking collector version (5 or 6 or 7 or 8)
; skywalking服务一般是skywalking8+elasticsearch7
skywalking.version = 8
; Set app code e.g. php-skywalking-demo
skywalking.app_code = php-skywalking-demo
; Set grpc address
skywalking.grpc=127.0.0.1:11800

验证:

php -m | grep sky
php -i | grep sky

图

修改php-fpm配置项:daemonize = no

参考文档

  • https://learnku.com/articles/51718
  • https://www.cnblogs.com/jixiaohua/p/11732225.html
  • https://github.com/SkyAPM/SkyAPM-php-sdk/blob/v4.1.2/docs/install.md
  • https://github.com/SkyAPM/SkyAPM-php-sdk/blob/master/docker/Dockerfile.7.4
  • https://blog.csdn.net/lfsfxytgb9_lyg/article/details/115720849