需要安裝的項(xiàng)目鏈接:https://github.com/apache/skywalking-php
項(xiàng)目文檔:https://skywalking.apache.org/docs/skywalking-php/next/en/setup/service-agent/php-agent/readme/
由于SkyWalking PHP Agent需要libclang 9.0+硫椰,CentOS7上并沒(méi)有蜡歹,scl上也沒(méi)有先改,于是需要自行編譯始花。
但是編譯libclang需要的gcc版本,CentOS7又不滿足媳荒,因此需要編譯個(gè)新的gcc循未。
首先安裝gcc 9.3(這一步可以省略涂圆,直接用scl源里面的devtoolset就行,我這里編譯是因?yàn)槟承┨厥庠颍?/p>
yum install gcc make gmp-devel mpfr-devel libmpc-devel texinfo flex
# 安裝在/opt/gcc-9
mkdir /opt/gcc-9
wget https://github.com/gcc-mirror/gcc/archive/refs/tags/releases/gcc-9.3.0.zip
unzip gcc-9.3.0.zip
cd gcc-releases-gcc-9.3.0/
./contrib/download_prerequisites
cd ..
mkdir objdir
cd objdir
$PWD/../gcc-releases-gcc-9.3.0/configure --prefix=/opt/gcc-9 --enable-languages=c,c++ --disable-multilib
make -j
make install
然后安裝clang13:
yum install cmake3
# 安裝在/opt/clang
mkdir /opt/clang
wget https://github.com/llvm/llvm-project/releases/download/llvmorg-13.0.1/llvm-project-13.0.1.src.tar.xz
tar -xvf llvm-project-13.0.1.src.tar.xz
cd llvm-project-13.0.1.src
mkdir build
cd build/
export CC=/opt/gcc-9/bin/gcc
export CXX=/opt/gcc-9/bin/g++
export LD_LIBRARY_PATH=/opt/gcc-9/lib64/lib
# 只編譯clang
cmake3 -G "Unix Makefiles" -DCMAKE_INSTALL_PREFIX=/opt/clang -DLLVM_TARGETS_TO_BUILD=X86 -DCMAKE_BUILD_TYPE=Release -DLLVM_ENABLE_PROJECTS=clang ../llvm
make -j
make install
unset CC
unset CXX
unset LD_LIBRARY_PATH
# 這一步比較關(guān)鍵硝逢,不軟鏈會(huì)找不到符號(hào)
cd /opt/clang/lib/
ln -s /opt/gcc-9/lib64/libstdc++.so.6
# 檢查下符號(hào)有沒(méi)有缺失
ldd /opt/clang/lib/libclang.so.13.0.1
連protoc的版本都不足姨拥,也得編:
wget https://github.com/protocolbuffers/protobuf/archive/refs/tags/v3.6.1.zip -O protobuf-3.6.1.zipo
unzip protobuf-3.6.1.zip
cd protobuf-3.6.1
# 安裝在mkdir /opt/protobuf
mkdir /opt/protobuf
./autogen.sh
./configure --prefix=/opt/protobuf
make -j
make install
Rust的安裝就省略了,照著官方文檔編就是了渠鸽。
然后到了終于到了編譯SkyWalking PHP Agent:
wget https://github.com/apache/skywalking-php/archive/refs/tags/v0.6.0.zip -O skywalking-php-0.6.0.zip
unzip skywalking-php-0.6.0.zip
cd skywalking-php-0.6.0
export PROTOC=/opt/protobuf/bin/protoc
export LIBCLANG_PATH=/opt/clang/lib
# 不加這一行叫乌,會(huì)導(dǎo)致缺少<stdbool.h>之類的文件,具體目錄位置可以在/usr搜下`stdbool.h`
export C_INCLUDE_PATH=/usr/lib/gcc/x86_64-redhat-linux/4.8.2/include
phpize
./configure
make -j
make install
終于安裝完了徽缚。