Skip to content

Commit d9b975b

Browse files
authored
Merge pull request #987 from jingjingxyk/build_native_php
Build native php
2 parents 1ce516b + fa6ba49 commit d9b975b

11 files changed

Lines changed: 73 additions & 17 deletions

.github/workflows/auto-cache-pool-tarball.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ jobs:
7373
mkdir -p pool/ext
7474
mkdir -p pool/php-tar/
7575
mkdir -p runtime/
76+
test -f runtime/php && rm -f runtime/php
7677
if [ ! -f runtime/php/php ] ; then
7778
bash setup-php-runtime.sh
7879
fi

.github/workflows/linux-aarch64.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,7 @@ jobs:
105105
mkdir -p pool/ext
106106
mkdir -p bin/
107107
mkdir -p runtime/
108+
test -f runtime/php && rm -f runtime/php
108109
if [ ! -f runtime/php/php ] ; then
109110
bash setup-php-runtime.sh
110111
fi

.github/workflows/linux-x86_64.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,7 @@ jobs:
152152
mkdir -p pool/ext
153153
mkdir -p bin/
154154
mkdir -p runtime/
155+
test -f runtime/php && rm -f runtime/php
155156
if [ ! -f runtime/php/php ] ; then
156157
bash setup-php-runtime.sh
157158
fi

.github/workflows/macos-aarch64.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,7 @@ jobs:
103103
mkdir -p pool/ext
104104
mkdir -p bin/
105105
mkdir -p runtime/
106+
test -f runtime/php && rm -f runtime/php
106107
if [ ! -f runtime/php/php ] ; then
107108
bash setup-php-runtime.sh
108109
fi

.github/workflows/macos-x86_64.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,7 @@ jobs:
114114
mkdir -p pool/ext
115115
mkdir -p bin/
116116
mkdir -p runtime/
117+
test -f runtime/php && rm -f runtime/php
117118
if [ ! -f runtime/php/php ] ; then
118119
bash setup-php-runtime.sh
119120
fi

docs/upgrade.md

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,9 @@
11
# 升级 PHP 版本 步骤
22

3-
> 1、修改 sapi/PHP-VERSION.conf 文件里版本号即可
4-
5-
> 2、修改 sync-source-code.php 文件里 PHP 源码包的 sha256sum 配置
6-
7-
> 3、执行同步源码脚本, 拉取 PHP 官方源码 到本项目
8-
9-
> 4、sapi/cli/ 代码的升级,需要手动确认
3+
1. 修改 `sapi/PHP-VERSION.conf` 文件里版本号即可
4+
2. 修改 `sync-source-code.php` 文件里 PHP 源码包的 sha256sum 配置
5+
3. 执行同步源码脚本, 拉取 PHP 官方源码 到本项目
6+
4. sapi/cli 代码的升级,需要手动确认
107

118
```shell
129

@@ -17,8 +14,8 @@ php sync-source-code.php
1714
php sync-source-code.php --action run
1815

1916

20-
./bin/runtime/php -c ./bin/runtime/php.ini sync-source-code.php
21-
./bin/runtime/php -c ./bin/runtime/php.ini sync-source-code.php --action run
17+
./runtime/php/php -c ./runtime/php/php.ini sync-source-code.php
18+
./runtime/php/php -c ./runtime/php/php.ini sync-source-code.php --action run
2219

2320
```
2421

sapi/download-box/Dockerfile-dowload-box

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM nginx:1.23-alpine
1+
FROM nginx:1.27-alpine
22

33
RUN rm -rf /usr/share/nginx/html/*
44
ADD ./default.conf /etc/nginx/conf.d/default.conf
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
#!/usr/bin/env bash
2+
3+
set -exu
4+
__DIR__=$(
5+
cd "$(dirname "$0")"
6+
pwd
7+
)
8+
__PROJECT__=$(
9+
cd ${__DIR__}/../../../
10+
pwd
11+
)
12+
cd ${__DIR__}
13+
14+
{
15+
docker stop swoole-cli-alpine-dev
16+
sleep 5
17+
} || {
18+
echo $?
19+
}
20+
cd ${__DIR__}
21+
22+
IMAGE=alpine:3.18
23+
24+
cd ${__DIR__}
25+
26+
mkdir -p /dev/shm/swoole-cli/thirdparty/
27+
mkdir -p /dev/shm/swoole-cli/ext/
28+
mkdir -p /dev/shm/swoole-cli/var/
29+
30+
docker run --rm --name swoole-cli-alpine-dev -d \
31+
-v ${__PROJECT__}:/work \
32+
-v /dev/shm/swoole-cli/thirdparty/:/work/thirdparty/ \
33+
-v /dev/shm/swoole-cli/ext/:/work/ext/ \
34+
-v /dev/shm/swoole-cli/var/:/work/var/ \
35+
-w /work --init $IMAGE tail -f /dev/null

sapi/quickstart/linux/run-swoole-cli-builder-container.sh

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,15 +33,15 @@ while [ $# -gt 0 ]; do
3333
shift $(($# > 0 ? 1 : 0))
3434
done
3535

36-
if [ ! -f ${__PROJECT__}/runtime/php ]; then
36+
if [ ! -f ${__PROJECT__}/runtime/php/php ]; then
3737
{
3838
bash setup-php-runtime.sh $OPTIONS
3939
} || {
4040
echo $?
4141
}
4242
fi
43-
export PATH=${__PROJECT__}/runtime:$PATH
44-
alias php="php -d curl.cainfo=${__PROJECT__}/runtime/cacert.pem -d openssl.cafile=${__PROJECT__}/runtime/cacert.pem "
43+
export PATH=${__PROJECT__}/runtime/php/:$PATH
44+
alias php="php -d curl.cainfo=${__PROJECT__}/runtime/php/cacert.pem -d openssl.cafile=${__PROJECT__}/runtime/php/cacert.pem "
4545

4646
export COMPOSER_ALLOW_SUPERUSER=1
4747

setup-php-runtime.sh

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ mkdir -p bin/
5757
mkdir -p runtime/
5858
mkdir -p var/runtime
5959
APP_RUNTIME_DIR=${__PROJECT__}/runtime/php
60+
test -f ${__PROJECT__}/runtime/php && rm -f ${__PROJECT__}/runtime/php
6061
mkdir -p ${APP_RUNTIME_DIR}
6162

6263
cd ${__PROJECT__}/var/runtime
@@ -70,10 +71,12 @@ if [ $OS = 'windows' ]; then
7071
fi
7172

7273
MIRROR=''
74+
CURL_OPTIONS=""
7375
while [ $# -gt 0 ]; do
7476
case "$1" in
7577
--mirror)
7678
MIRROR="$2"
79+
CURL_OPTIONS+="-H 'Referer: https://www.swoole.com/download' -H 'User-Agent: download swoole-cli runtime with setup-php-runtime.sh' -H 'X-Auth-Token: 6F0A7F038A69'"
7780
;;
7881
--proxy)
7982
export HTTP_PROXY="$2"
@@ -103,6 +106,13 @@ china)
103106

104107
esac
105108

109+
downloader() {
110+
local file=$1
111+
local url=$2
112+
local cmd=$(echo "curl $CURL_OPTIONS -fSLo $file $url ")
113+
eval $cmd
114+
}
115+
106116
test -f composer.phar || curl -fSLo composer.phar ${COMPOSER_DOWNLOAD_URL}
107117
chmod a+x composer.phar
108118

@@ -113,13 +123,13 @@ APP_RUNTIME="${APP_NAME}-${APP_VERSION}-${OS}-${ARCH}"
113123
if [ $OS = 'windows' ]; then
114124
{
115125
APP_RUNTIME="${APP_NAME}-${APP_VERSION}-cygwin-${ARCH}"
116-
test -f ${APP_RUNTIME}.zip || curl -fSLo ${APP_RUNTIME}.zip ${APP_DOWNLOAD_URL}
126+
test -f ${APP_RUNTIME}.zip || downloader ${APP_RUNTIME}.zip ${APP_DOWNLOAD_URL}
117127
test -d ${APP_RUNTIME} && rm -rf ${APP_RUNTIME}
118128
unzip "${APP_RUNTIME}.zip"
119129
exit 0
120130
}
121131
else
122-
test -f ${APP_RUNTIME}.tar.xz || curl -fSLo ${APP_RUNTIME}.tar.xz ${APP_DOWNLOAD_URL}
132+
test -f ${APP_RUNTIME}.tar.xz || downloader ${APP_RUNTIME}.tar.xz ${APP_DOWNLOAD_URL}
123133
test -f ${APP_RUNTIME}.tar || xz -d -k ${APP_RUNTIME}.tar.xz
124134
test -f swoole-cli && rm -f swoole-cli
125135
tar -xvf ${APP_RUNTIME}.tar

0 commit comments

Comments
 (0)