未验证 提交 ccb58445 编写于 作者: H huohuanhuan 提交者: GitHub

Add files via upload (#223)

* Add files via upload

添加centos7 Systemd启动脚本

* Create agent_install_doc

* Update agent_install_doc

* Update and rename sw-php-agent.service to sw-php-agent.service.example

* Update agent_install_doc

* Update install-agent.md

* Update install-agent.md

* Update install-agent.md

* Update install-agent.md

* Update install-agent.md

* Update install-agent.md

* Delete agent_install_doc

* Update sw-php-agent.service.example

* Update install-agent.md

* Update install-agent.md

* Add files via upload

添加sw+php-agentDcoker-compose文件,SwUi端口:9001 phpWeb端口:8080

* Update docker-compose.yml

* Update install-agent.md

* Update sw-php-agent.service.example
Co-authored-by: N何延龙 <yanlong.hee@gmail.com>
上级 03dc42bb
version: '3'
services:
oap:
image: apache/skywalking-oap-server
ui:
image: apache/skywalking-ui
environment:
- SW_OAP_ADDRESS=oap:12800
ports:
- 9001:8080
phpagent:
image: skyapm/skywalking-php
environment:
- SW_AGENT_COLLECTOR_BACKEND_SERVICES=oap:11800
ports:
- 8080:8080
Tips: It is recommended that you use SkyWalking and use nginx as load balancing
# Install SkyWalking PHP Agent
## Requirements
When building directly from Git sources or after custom modifications you might also need:
* php 7+
* golang 1.13
* SkyWalking Collector
* SkyWalking oap server
* SkyWalking UI
## PHP extension + Agent
The collect data from your instance you need both the PHP extension, and the agent.
......@@ -13,10 +16,11 @@ build them from source.
You can run the following commands to install the SkyWalking PHP Agent.
## Install PHP Extension
## Install PHP Extension
```shell script
git clone https://github.com/SkyAPM/SkyAPM-php-sdk.git
cd SkyAPM-php-sdk
curl -Lo v3.2.8.tar.gz https://github.com/SkyAPM/SkyAPM-php-sdk/archive/v3.2.8.tar.gz
tar zxvf v3.2.8.tar.gz
cd SkyAPM-php-sdk-3.2.8
phpize && ./configure && make && make install
```
......@@ -25,10 +29,10 @@ phpize && ./configure && make && make install
For installing the sky-php-agent, you first need to build it:
```shell script
cd SkyAPM-php-sdk
go build -o sky-php-agent agent/cmd/main.go
cd SkyAPM-php-sdk-3.2.8
go build -o sky-php-agent cmd/main.go
chmod +x sky-php-agent
cp sky-php-agent /usr/bin
cp sky-php-agent /usr/local/bin
```
## How to use
......@@ -42,38 +46,120 @@ extension=skywalking.so
; enable skywalking
skywalking.enable = 1
; Set skyWalking collector version (5 or 6)
; Set skyWalking collector version (5 or 6 or 7 or 8)
skywalking.version = 6
; Set app code e.g. MyProjectName
skywalking.app_code = MyProjectName
; sock file path(default /tmp/sky-agent.sock)
skywalking.sock_path=/tmp/sky-agent.sock
```
### Run `sky-php-agent` to send PHP generated log information to `SkyWalking collector`
## Select startup script and log output method
## If you use CentOS 7 Use the startup script below to You need to change the corresponding address, version
```shell script
// sky-php-agent [collector grpc address]
// e.g.
sky-php-agent --grpc 127.0.0.1:11800
[Unit]
Description=The Sw-Php-Agent Process Manager
After=syslog.target network.target
[Service]
Type=simple
#Modify the corresponding directory and address here
ExecStart=/usr/local/bin/sky-php-agent-linux-X64 --grpc=127.0.0.1:11800 --sky-version=7 --socket=/tmp/sky-agent.sock
ExecStop=/bin/kill -SIGINT $MAINPID
Restart=on-failure
[Install]
WantedBy=multi-user.target
```
## If you use CentOS6 Log management with lograted
## This is Start script You need to change the address, version and Copy and run it with root
```shell script
echo "
#/bin/bash
### ⚠️⚠️⚠️ Warning *Make sure PHP has read and write permissions on the socks file*
start(){
[ -f /tmp/php-agent.pid ]&&echo "Alredy running"&&exit 1
/usr/local/bin/sky-php-agent-linux-X64 --grpc=127.0.0.1:11800 --sky-version=7 --socket=/tmp/sky-agent.sock 1>>/var/log/phpagent/php-agent.log 2>>/var/log/phpagent/php-agent-error.log &
if [ $? -eq 0 ];then
echo $! >/tmp/php-agent.pid
echo "sky-php-agent startup!!!"
fi
}
stop(){
kill -9 `cat /tmp/php-agent.pid`
rm -f /tmp/php-agent.pid
[[ $? == 0 ]]&&echo "sky-php-agent stop!!!"
}
# add the restart method
case $1 in
start)
start
;;
stop)
stop
;;
## Dockerfile
### Multi stage build example (starting point)
```bash
FROM golang:1.13 AS builder
ARG SKY_AGENT_VERSION=3.2.6
WORKDIR /go/src/app
RUN wget https://github.com/SkyAPM/SkyAPM-php-sdk/archive/${SKY_AGENT_VERSION}.tar.gz; \
tar xvf ${SKY_AGENT_VERSION}.tar.gz
RUN mv SkyAPM-php-sdk-${SKY_AGENT_VERSION} build
RUN cd build; \
GOOS=linux GOARCH=amd64 go build -o sky-php-agent-linux-x64 ./agent/cmd/main.go
FROM php:7.2.28-fpm-alpine3.11
# Copy from builder
COPY --from=builder /go/src/app/build/sky-php-agent-linux-x64 /usr/local/bin/sky-php-agent
RUN apk update && apk upgrade && apk add --no-cache autoconf libc6-compat libcurl curl-dev icu-dev & \
apk add --no-cache --virtual .build-deps $PHPIZE_DEPS
restart)
stop
start
;;
*)
echo "USAGE: $0 {start |stop |restart }"
;;
esac
exit 0 " > /etc/init.d/php-agent
```
## This is Log management script,Copy and run it with root
```shell script
mkdir /var/log/phpagent/
echo "
/var/log/phpagent/*.log {
rotate 10
daily
dateext
nocompress
missingok
notifempty
create 0644 root root
postrotate
/etc/init.d/php-agent restart
endscript
}" >/etc/logrotate.d/phpagent
```
### Agent parameter description
```shell script
# View help information
./sky-php-agent -h
# Specify grpc address
/usr/local/bin/sky-php-agent --grpc 127.0.0.1:11800
# Specify the socket file. The path is the path in the php.ini configuration
/usr/local/bin/sky-php-agent --socket=/tmp/sky-agent.sock
# Specify the version of skywalking
/usr/local/bin/sky-php-agent --sky-version=7
```
### ⚠️⚠️⚠️ Warning *Make sure PHP has read and write permissions on the socks file*
[Unit]
Description=The SkyWalking PHP-Agent Process Manager
After=syslog.target network.target
[Service]
Type=simple
#Modify the corresponding directory and address here
ExecStart=/usr/local/bin/sky-php-agent --grpc=127.0.0.1:11800 --sky-version=7 --socket=/tmp/sky-agent.sock
ExecStop=/bin/kill -SIGINT $MAINPID
Restart=on-failure
[Install]
WantedBy=multi-user.target
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册