Compare commits

..

222 Commits

Author SHA1 Message Date
Jerry Ma
cecf204f7b Update README.md 2023-04-30 17:21:27 +08:00
Jerry
8391d3a60c Update README-en.md 2023-03-28 10:29:49 +08:00
Jerry
1a516a13dd Update README.md 2023-03-28 10:28:18 +08:00
Jerry
62bee67274 Update README.md 2023-03-18 17:48:46 +08:00
Jerry
36ce06c3ca Update README.md 2023-03-04 23:49:49 +08:00
Jerry
3071297bd5 Merge pull request #28 from jingjingxyk/feature_libmcrypt
添加aria2快速下载依赖库和扩展;添加依赖库GMP;添加依赖库libmcrypt;
2023-03-04 21:56:43 +08:00
Jerry
0707bcab68 Update README-en.md 2023-03-04 21:54:07 +08:00
Jerry
fe7196f2aa Update README.md 2023-03-04 21:47:05 +08:00
jingjingxyk
220252da74 修改描述 2023-03-03 19:43:05 +08:00
jingjingxyk
65ebe4dfa6 Merge branch 'master' into feature_libmcrypt 2023-03-03 19:22:24 +08:00
jingjingxyk
580565de23 添加爱快速aria2快速下载依赖库和扩展;添加依赖库GMP;添加依赖库libmcrypt; 2023-03-03 19:19:54 +08:00
Jerry
9e8af298d4 Update README.md 2023-02-28 21:51:02 +08:00
Jerry
1ca64d6626 Update README.md 2023-01-16 13:28:35 +08:00
Jerry
1b38f23268 Update README.md 2023-01-16 13:20:38 +08:00
Jerry
1b2ed00cbb Update build-php.yml 2023-01-10 11:29:53 +08:00
Jerry
14a3c28044 revert docker alpine version to 3.16, fix #20 2023-01-10 11:28:16 +08:00
Jerry
5767d9a275 Update build-php.yml 2022-12-28 17:06:43 +08:00
Jerry
da802d5e70 Update build-php.yml 2022-12-28 17:05:52 +08:00
Jerry
50b6f5244d Update extensions.txt 2022-11-09 14:12:53 +08:00
Jerry Ma
7f860e46f3 Merge pull request #13 from ikilobyte/master
add --with-config-file-path=/etc
2022-10-24 11:10:26 +08:00
Jerry Ma
5a354d58fa Update README.md 2022-10-20 16:03:37 +08:00
Sunny
f186c4572b add --with-config-file-path=/etc 2022-10-12 11:14:11 +08:00
Jerry Ma
fb592bf103 Update README.md 2022-10-05 08:47:05 +08:00
Jerry Ma
195c922f4e Update build-php.yml 2022-09-20 15:01:24 +08:00
Jerry Ma
464eca3588 change multiarch version tag 2022-08-16 12:42:22 +08:00
Jerry Ma
0fbef677ca Update compile-php.sh 2022-08-16 10:17:34 +08:00
Jerry Ma
99bdb1fec1 Update build-php.yml 2022-08-15 20:37:54 +08:00
Jerry Ma
f6d777a668 Update build-php.yml 2022-08-08 17:15:05 +08:00
Jerry Ma
1515e9d9d5 Update build-php.yml 2022-08-06 09:23:55 +08:00
Jerry Ma
d164b567bf Update README-en.md 2022-07-15 14:37:36 +08:00
Jerry Ma
38baa371ca Update README.md 2022-07-15 14:36:25 +08:00
Jerry Ma
6c62d032fe Update build-php.yml 2022-07-15 09:57:17 +08:00
Jerry Ma
10541ddcc7 Update build-php.yml 2022-07-14 23:59:54 +08:00
Jerry Ma
f73a02b9a9 Update config.json 2022-07-11 10:05:35 +08:00
Jerry Ma
d755803e90 Update dependencies version 2022-07-09 18:06:56 +08:00
Jerry Ma
23d8a014ce Update PHP build versions 2022-07-08 23:55:12 +08:00
crazywhalecc
09c5cdae11 add libiconv compiler 2022-07-07 05:33:58 +00:00
crazywhalecc
1b88682fcb add libiconv compiler 2022-07-07 05:24:37 +00:00
Jerry Ma
9cc703d424 Update compile-php.sh 2022-06-27 14:06:01 +08:00
Jerry Ma
8fd3cab450 Update README-en.md 2022-06-27 11:14:43 +08:00
Jerry Ma
b2a4fb115c Update README-en.md 2022-06-27 11:13:56 +08:00
Jerry Ma
ace647d6c4 Update README-en.md 2022-06-27 11:11:40 +08:00
Jerry Ma
5048fb5b48 Update README-en.md 2022-06-27 11:09:32 +08:00
crazywhalecc
4c55f4a22b Update to 1.5.2 (Add protobuf support) 2022-06-21 13:49:38 +08:00
crazywhalecc
96bc62b2a9 Update to 1.5.1 version (add readline extension) 2022-06-20 21:17:51 +08:00
crazywhalecc
c5fc6fa9dc Change curl to wget 2022-06-20 20:56:59 +08:00
crazywhalecc
ed2b320271 Add readline support 2022-06-20 20:52:35 +08:00
Jerry Ma
1dd4ad9cc1 Update compile-deps.sh, support caching [skip ci] 2022-06-20 18:55:37 +08:00
Jerry Ma
265fac3ca1 Update download-git.sh, support caching [skip ci] 2022-06-20 18:54:11 +08:00
Jerry Ma
09437d3e91 Update check-extensions.sh [skip ci] 2022-06-20 18:53:19 +08:00
crazywhalecc
1f2be3b484 Update github action CI 2022-06-11 02:27:07 +08:00
crazywhalecc
87ce77cf25 Fix check-extensions.sh syntax 2022-06-11 02:10:27 +08:00
crazywhalecc
dc5bac99b0 Update README 2022-06-11 02:09:18 +08:00
crazywhalecc
6fab3e789d Update github action CI 2022-06-11 01:39:03 +08:00
crazywhalecc
b02fa68683 Update github action CI 2022-06-11 01:37:04 +08:00
crazywhalecc
a07ba59b0f update github action CI 2022-06-11 01:22:34 +08:00
crazywhalecc
8f978dd187 update github action CI 2022-06-11 01:21:36 +08:00
crazywhalecc
a72ed9ca16 Update to 1.6.0 version (dialog selection and multiarch micro) 2022-06-11 01:09:45 +08:00
root
4b750825e9 update to 1.5.1 (add event support) 2022-06-10 18:23:07 +08:00
Jerry Ma
7f04a27f41 Update PHP version
7.4.30, 8.0.20, 8.1.7
2022-06-10 16:34:39 +08:00
Jerry Ma
6b3f973a61 Update compile-micro.sh 2022-06-10 15:42:44 +08:00
Jerry Ma
e3ccf916bf Update README.md 2022-06-04 14:43:39 +08:00
Jerry Ma
de1302c6af Update README.md 2022-05-20 06:39:55 +08:00
Jerry Ma
8055816683 Update README-en.md 2022-05-16 17:05:04 +08:00
Jerry Ma
7e2b390963 Update README.md 2022-05-16 17:04:39 +08:00
crazywhalecc
fbf4016965 update README.md 2022-05-16 17:02:57 +08:00
crazywhalecc
2b802c710f fix micro error bug 2022-05-16 16:19:01 +08:00
crazywhalecc
f7162cbc79 fix micro error bug 2022-05-16 15:51:11 +08:00
crazywhalecc
347419ee53 fix yml syntax 2022-05-16 14:56:59 +08:00
crazywhalecc
e4c8815ba7 debug compile-micro mode 2022-05-16 14:56:02 +08:00
crazywhalecc
09095f48a7 debug compile-micro mode 2022-05-16 14:55:24 +08:00
crazywhalecc
e573f446a5 fix typo 2022-05-16 14:16:20 +08:00
crazywhalecc
b936730e51 fix micro bug for docker 2022-05-16 14:11:00 +08:00
crazywhalecc
6e1c7a09cc Fix mirror site not working 2022-05-16 14:05:47 +08:00
crazywhalecc
74060cbf27 add micro php build 2022-05-16 14:01:00 +08:00
Jerry Ma
4cba2cb8c1 Update README-en.md 2022-05-15 01:41:58 +08:00
Jerry Ma
67ae206b0e Update build-php action trigger events 2022-05-15 01:36:22 +08:00
Jerry Ma
dfc6694dce Fix backup address not working 2022-05-15 01:15:16 +08:00
Jerry Ma
82170b8d50 Update example images [skip ci] 2022-05-15 01:10:07 +08:00
Jerry Ma
523aa0a6d3 Update example image [skip ci] 2022-05-15 01:09:11 +08:00
Jerry Ma
de2a38b5a2 Update README.md 2022-05-15 00:57:14 +08:00
Jerry Ma
212f1de3ae Update versions of dependencies 2022-05-13 19:50:58 +08:00
Jerry Ma
6f7f2f75b0 Update build php versions [skip ci] 2022-05-13 19:47:10 +08:00
Jerry Ma
7a5612ec2b Update README-en.md [skip ci] 2022-05-09 19:30:40 +08:00
Jerry Ma
f8a16ce6c0 Update README.md [skip ci] 2022-05-09 19:28:59 +08:00
Jerry Ma
a14d494bba Update config.json 2022-05-09 19:13:37 +08:00
crazywhalecc
e240183fa0 Add zip extension support 2022-05-09 19:10:59 +08:00
Jerry Ma
d4b6dbfba3 Update README.md [skip ci] 2022-05-09 11:03:31 +08:00
Jerry Ma
0986665d53 Update build PHP version
7.4.29, 8.0.18, 8.1.5
2022-04-18 04:33:04 +08:00
Jerry Ma
e6f4c5e41f Update README-en.md 2022-04-17 22:19:22 +08:00
Jerry Ma
0e9c8ebf61 Update README.md [skip ci] 2022-04-17 22:07:56 +08:00
Jerry Ma
cab1f16734 Create install-runtime.sh [skip ci] 2022-04-17 22:01:23 +08:00
crazywhalecc
4c56797d14 Add exif, pdo_sqlite, shmop, soap extensions 2022-04-12 00:50:58 +08:00
crazywhalecc
247da4010a update README.md [skip ci] 2022-04-11 23:46:00 +08:00
crazywhalecc
6f078b6865 Add fileinfo extension to default 2022-04-11 23:41:27 +08:00
Jerry Ma
bfe986e62a Update PHP extensions version 2022-04-03 21:04:14 +08:00
Jerry Ma
e3bc589d4b Update README-en.md [skip ci] 2022-04-02 16:50:43 +08:00
Jerry Ma
b6d1ecf0e5 Update README.md [skip ci] 2022-04-02 16:48:48 +08:00
Jerry Ma
6151fcfda0 Update download.sh mute progress 2022-04-02 16:13:16 +08:00
Jerry Ma
0c210d088f Update Dockerfile 2022-04-02 16:07:11 +08:00
Jerry Ma
36132012db Update php versions 2022-04-02 15:52:56 +08:00
Jerry Ma
3c96621af4 Simplify build actions 2022-04-02 15:49:08 +08:00
Jerry Ma
da0b052cc2 Update build-php.yml 2022-04-02 15:23:20 +08:00
Jerry Ma
7fae0f3fe9 Update build-php.yml 2022-04-02 01:46:34 +08:00
Jerry Ma
6970500f85 Update build-php.yml 2022-04-02 01:45:23 +08:00
Jerry Ma
1286a9e237 Delete build-php-arm.yml [skip ci] 2022-04-02 01:45:04 +08:00
Jerry Ma
bf085706b0 Update build-php.yml 2022-04-02 01:38:14 +08:00
Jerry Ma
cb1d1cdc5e Update build-php-arm.yml 2022-04-02 00:31:00 +08:00
Jerry Ma
90c6aebac6 Update build-php-arm.yml 2022-04-02 00:30:30 +08:00
Jerry Ma
84ed82d896 Add dynamic CPU compile acceleration [skip ci] 2022-04-01 22:19:11 +08:00
Jerry Ma
da6c2a88b1 Update extension download link & version [skip ci] 2022-04-01 22:16:07 +08:00
Jerry Ma
f87f3c2736 Update Dockerfile 2022-03-21 02:16:22 +08:00
Jerry Ma
c41ca40337 Update build-php-arm.yml 2022-02-25 14:27:43 +08:00
Jerry Ma
f9f27045ee Update english readme [skip ci] 2022-02-20 17:33:19 +08:00
Jerry Ma
3496c3a2e8 Update README.md 2022-02-18 13:48:08 +08:00
Jerry Ma
23d7af5a30 Update build-php-arm.yml 2022-02-11 16:43:18 +08:00
Jerry Ma
01a51c58d8 Update workflows [skip ci]
Change runner on remote ubuntu-latest
2022-02-11 16:41:20 +08:00
Jerry Ma
be777dc848 Update build-php-arm.yml 2022-02-11 16:36:27 +08:00
Jerry Ma
55f866e5c5 Update build-php.yml 2022-02-11 16:35:45 +08:00
Jerry Ma
94f915d36a Update extension library version 2022-02-11 16:32:33 +08:00
Jerry Ma
23aebace18 Update README.md 2022-01-10 10:14:06 +08:00
Jerry Ma
fb2ce8708f Change LICENSE to MIT 2022-01-10 10:12:05 +08:00
Jerry Ma
ac5fb5e763 Update build-php.yml 2021-12-18 17:14:53 +08:00
Jerry Ma
c93fb71709 Create build-php-arm.yml 2021-12-18 17:04:58 +08:00
Jerry Ma
2df9cf2f5f Update build-php.yml 2021-12-18 17:04:33 +08:00
Jerry Ma
7153bd8a57 Update build-php.yml 2021-12-18 15:59:09 +08:00
Jerry Ma
337a8ca820 Update config.json 2021-12-18 14:32:06 +08:00
Jerry Ma
f47c97eb17 Update build-php.yml 2021-12-18 11:58:47 +08:00
Jerry Ma
8dd87eda01 Update download.sh 2021-12-18 02:28:07 +08:00
Jerry Ma
cae4e23872 Update compile-php.sh 2021-12-18 02:17:05 +08:00
Jerry Ma
8b9251bb3a Update build-php.yml 2021-12-18 02:10:54 +08:00
Jerry Ma
96e25d2ff7 Update build-php.yml 2021-12-18 01:28:47 +08:00
Jerry Ma
7d4e95a742 Update build-php.yml 2021-12-18 01:25:27 +08:00
Jerry Ma
ac35981e0e Update build-php.yml 2021-12-17 23:47:16 +08:00
Jerry Ma
d04cecc733 Update check-extensions.sh 2021-11-27 15:24:21 +08:00
Jerry Ma
c2876f28a8 Update build-php.yml 2021-10-24 13:59:45 +08:00
Jerry Ma
05f33ded14 Update build-php.yml 2021-10-13 15:14:24 +08:00
Jerry Ma
02c85139b4 update README.md [skip ci] 2021-10-13 13:56:25 +08:00
Jerry Ma
8ed1945667 test 2021-10-13 09:15:43 +08:00
Jerry Ma
85c54d46b0 Add mongodb extension default 2021-10-13 09:10:48 +08:00
Jerry Ma
31e3788ead Update library version 2021-09-11 15:24:23 +08:00
Jerry Ma
cd460dd352 update README.md [skip ci] 2021-09-03 09:29:40 +08:00
Jerry Ma
8667351378 Update README-en.md 2021-09-01 16:28:14 +08:00
Jerry Ma
e2f5593d91 Update README.md 2021-09-01 16:26:46 +08:00
Jerry Ma
27d255bc40 update README.md [skip ci] 2021-09-01 16:26:01 +08:00
Jerry Ma
753ae2de39 update README.md [skip ci] 2021-08-31 13:36:11 +08:00
9c10e4401f return to 1 file multi build 2021-08-31 13:34:34 +08:00
b57bdaacc6 Merge remote-tracking branch 'origin/master' 2021-08-31 13:04:13 +08:00
851b35ea4f fix mkdir bugs 2021-08-31 13:03:54 +08:00
Jerry Ma
5c981172de Update README.md 2021-08-31 11:17:26 +08:00
0635341f43 separate action scripts 2021-08-31 10:47:03 +08:00
Jerry Ma
65a5cad9cf Update docker-image.yml 2021-08-31 10:16:05 +08:00
Jerry Ma
5aa4c0ea67 Update docker-image.yml 2021-08-31 00:58:17 +08:00
Jerry Ma
839adb9751 Update docker-image.yml 2021-08-31 00:50:41 +08:00
Jerry Ma
f8ab590356 Update docker-image.yml 2021-08-31 00:49:03 +08:00
Jerry Ma
282470ad96 Update docker-image.yml 2021-08-30 20:14:17 +08:00
Jerry Ma
4488ef397b Update Dockerfile 2021-08-30 17:08:37 +08:00
Jerry Ma
69dd9f124d Update docker-image.yml 2021-08-30 17:03:38 +08:00
Jerry Ma
2d3eec300f Update Dockerfile 2021-08-30 17:02:18 +08:00
Jerry Ma
3de37e8e4e Update docker-image.yml 2021-08-30 17:01:01 +08:00
Jerry Ma
8e6cd15101 Update action-deploy.sh 2021-08-30 16:32:22 +08:00
Jerry Ma
2f186e5db9 Update docker-image.yml 2021-08-30 15:42:10 +08:00
Jerry Ma
b52c3a5597 Update docker-image.yml 2021-08-30 15:27:39 +08:00
Jerry Ma
e29de024d2 Delete main.yml 2021-08-30 15:16:07 +08:00
Jerry Ma
5f9c65156d Create action-deploy.sh 2021-08-30 15:15:34 +08:00
Jerry Ma
19b29b4aad Update docker-image.yml 2021-08-30 15:08:35 +08:00
Jerry Ma
02b2f14e6d Create docker-image.yml 2021-08-30 14:41:19 +08:00
Jerry Ma
8a3df3a2a6 Create main.yml 2021-08-30 14:34:31 +08:00
Jerry Ma
5e33b0d84a Update README.md 2021-07-28 14:54:48 +08:00
Jerry Ma
5a47243022 Update README.md 2021-07-28 14:31:41 +08:00
Jerry Ma
d67f765d31 Update README-en.md 2021-07-28 14:28:43 +08:00
Jerry Ma
294e25bf12 Update README-en.md 2021-07-28 14:27:18 +08:00
Jerry Ma
0f99625334 Update README.md 2021-07-28 14:26:28 +08:00
Jerry Ma
918546a090 Update README.md 2021-07-27 14:57:59 +08:00
Jerry Ma
1c8e652797 Fix Issue #2
https://github.com/crazywhalecc/static-php-cli/issues/2#issuecomment-885332238
2021-07-23 14:31:51 +08:00
root
66942f866e update README.md 2021-07-22 12:05:09 +00:00
root
7440fe3936 update to 1.3.3 version, support multi-version build 2021-07-22 12:03:28 +00:00
root
35395538b4 update to 1.3.2 version (support sqlite3) 2021-07-22 05:24:14 +00:00
Jerry Ma
36f4833b71 Update Dockerfile 2021-07-15 22:00:29 +08:00
Whale
33de213a66 Update Dockerfile 2021-06-13 19:08:46 +08:00
Whale
9fa229fa36 Update README-en.md 2021-06-06 11:53:16 +08:00
Whale
6efa11d8af Update README.md 2021-06-06 11:49:07 +08:00
Whale
cc3fa7d1fd Update README-en.md 2021-06-06 11:42:21 +08:00
Whale
de5d92be70 Update README-en.md 2021-06-06 11:41:55 +08:00
Whale
cb679247fc Update README.md 2021-06-06 11:29:37 +08:00
Whale
f7e961c223 Update README.md 2021-06-06 11:16:59 +08:00
jerry
89fc7c6482 update README.md 2021-06-06 01:03:10 +08:00
jerry
12b32ce1a0 update to Dockerfile version(1.3.0) 2021-06-06 01:01:58 +08:00
Whale
cdf4d4999e Delete static-compile-php.sh 2021-06-06 00:59:44 +08:00
Whale
6926a5c989 Delete multi-version-build.sh 2021-06-06 00:59:37 +08:00
Whale
2944eb4a75 Update README.md 2021-06-06 00:59:20 +08:00
Whale
135259e0db Update README.md 2021-06-06 00:49:00 +08:00
Whale
38e2b587e1 Update README.md 2021-06-05 23:48:37 +08:00
Whale
92a0078d54 Update README.md 2021-06-05 23:34:41 +08:00
e0c7963713 Merge branch 'master' of https://github.com/crazywhalecc/static-php-cli 2021-06-02 19:58:23 +08:00
Whale
1069ae3539 Update README.md 2021-06-03 22:06:48 +08:00
908f7c8b98 update Dockerfile 2021-06-02 19:57:55 +08:00
Whale
89a1526501 Create php-arg.sh 2021-06-02 00:35:07 +08:00
Whale
6e9a975e94 Create merge-curl-config.sh 2021-06-02 00:34:44 +08:00
Whale
b3cbf9cc37 Create ac_override_2 2021-06-02 00:34:25 +08:00
Whale
22ac543fe7 Create ac_override_1 2021-06-02 00:34:10 +08:00
Whale
cc3aa2ec44 Create Dockerfile 2021-06-02 00:33:47 +08:00
jerry
609790ea7b 升级到1.2.1版本,修复几个小问题,增加php7.2,更新swoole依赖版本到4.6.7 2021-05-31 20:30:14 +08:00
jerry
cb98414cef 升级到1.2.1版本,修复几个小问题,增加php7.2 2021-05-31 20:26:40 +08:00
Whale
85efd3275b Update README.md 2021-05-07 16:58:40 +08:00
Whale
2b3f736c68 Update static-compile-php.sh 2021-05-07 16:58:16 +08:00
Whale
18c74cdadb Update multi-version-build.sh 2021-05-07 16:57:17 +08:00
Whale
7cb7facec3 Update static-compile-php.sh 2021-05-07 10:20:44 +08:00
Whale
cf42a4ee71 Update README-en.md 2021-05-07 10:20:25 +08:00
Whale
bce1d13d91 Update README.md 2021-05-07 10:20:12 +08:00
root
7ad936f8c2 Merge branch 'master' of https://fgit.zhamao.me/crazywhalecc/static-php-swoole
Nothing
2021-05-06 22:50:50 +08:00
Whale
b46b58ad49 Update README.md 2021-05-07 10:06:00 +08:00
Whale
189dc21f1a Update README.md 2021-05-07 10:01:18 +08:00
Whale
7bf38281d5 Update README.md 2021-05-07 09:33:13 +08:00
Whale
980d25c40a Create README-en.md 2021-05-07 09:33:06 +08:00
root
e1b0013201 test 2021-05-06 22:50:26 +08:00
root
50e5cea9fb fix multi version bug 2021-04-28 16:25:04 +08:00
root
6b258bee6b set to 1.2.0 2021-05-06 09:08:01 +00:00
Whale
ad76951419 Update README.md 2021-05-06 14:44:36 +08:00
Whale
862f5e9924 Update README.md 2021-05-06 14:44:16 +08:00
Whale
0a4d604069 Update README.md 2021-05-06 14:43:12 +08:00
Whale
720341316b Update README.md 2021-05-04 00:44:42 +08:00
27 changed files with 1543 additions and 990 deletions

67
.github/workflows/build-php.yml vendored Normal file
View File

@@ -0,0 +1,67 @@
name: Build PHP
on:
push:
branches: [ master ]
paths:
- ".github/workflows/**.yml"
- "docker/**"
jobs:
integration:
name: Build PHP ${{ matrix.php-versions }} for ${{ matrix.arch }}
runs-on: ubuntu-latest
strategy:
matrix:
php-versions: [ "7.4.30", "8.0.23", "8.1.10", "8.2.0" ]
arch: [ "x86_64", "aarch64", "armv7l" ]
steps:
- uses: actions/checkout@v2
- name: Check Dockerfile to ${{ matrix.arch }}
run: |
cd docker/
if [[ "${{ matrix.arch }}" != "x86_64" ]]; then
if [[ "${{ matrix.arch }}" = "armv7l" ]]; then
sed -ie 's/alpine:latest/multiarch\/alpine:armv7-latest-stable/g' Dockerfile
else
sed -ie 's/alpine:latest/multiarch\/alpine:${{ matrix.arch }}-v3.16/g' Dockerfile
fi
docker run --rm --privileged multiarch/qemu-user-static:register --reset
fi
- name: Build micro and PHP distribution ${{ matrix.php-versions }} for ${{ matrix.arch }}
id: buildphp
run: |
cd docker/ && docker build . --tag static-php --build-arg USE_BACKUP_ADDRESS=yes && \
mkdir ../dist && \
docker run --rm -v $(pwd)/../dist:/dist/ static-php build-php original ${{ matrix.php-versions }} all /dist/
- name: Fail if anything failed
if: steps.buildphp == 'failure'
run: |
false
- name: Upload Artifacts
uses: actions/upload-artifact@v3
with:
name: static-php-cli_${{ matrix.php-versions }}_${{ matrix.arch }}
path: |
dist
- name: Pack PHP ${{ matrix.php-versions }} to archive
run: |
cd dist
tar -zcvf "php-${{ matrix.php-versions }}-static-bin-${{ matrix.arch }}.tar.gz" ./php && rm ./php
if [ -f "./micro.sfx" ]; then
tar -zcvf "micro-${{ matrix.php-versions }}-${{ matrix.arch }}.tar.gz" ./micro.sfx && rm ./micro.sfx
fi
- name: Deploy to Zhamao Server
uses: easingthemes/ssh-deploy@main
env:
SSH_PRIVATE_KEY: ${{ secrets.DEPLOY_SERVER_SECRET_KEY }}
ARGS: "-rltgoDzvO"
SOURCE: "dist/"
REMOTE_HOST: ${{ secrets.DEPLOY_SERVER_HOST }}
REMOTE_PORT: ${{ secrets.DEPLOY_SERVER_PORT }}
REMOTE_USER: ${{ secrets.DEPLOY_SERVER_USER }}
TARGET: ${{ secrets.DEPLOY_SERVER_TARGET }}
- name: Remove dist directory
run: |
rm -rf dist/
docker images | grep -v REPOSITORY | awk '{print $3}' | xargs docker rmi --force

5
.gitignore vendored Normal file
View File

@@ -0,0 +1,5 @@
.idea
runtime/
docker/libraries/
docker/extensions/
docker/source/

695
LICENSE
View File

@@ -1,674 +1,21 @@
GNU GENERAL PUBLIC LICENSE
Version 3, 29 June 2007
Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
Preamble
The GNU General Public License is a free, copyleft license for
software and other kinds of works.
The licenses for most software and other practical works are designed
to take away your freedom to share and change the works. By contrast,
the GNU General Public License is intended to guarantee your freedom to
share and change all versions of a program--to make sure it remains free
software for all its users. We, the Free Software Foundation, use the
GNU General Public License for most of our software; it applies also to
any other work released this way by its authors. You can apply it to
your programs, too.
When we speak of free software, we are referring to freedom, not
price. Our General Public Licenses are designed to make sure that you
have the freedom to distribute copies of free software (and charge for
them if you wish), that you receive source code or can get it if you
want it, that you can change the software or use pieces of it in new
free programs, and that you know you can do these things.
To protect your rights, we need to prevent others from denying you
these rights or asking you to surrender the rights. Therefore, you have
certain responsibilities if you distribute copies of the software, or if
you modify it: responsibilities to respect the freedom of others.
For example, if you distribute copies of such a program, whether
gratis or for a fee, you must pass on to the recipients the same
freedoms that you received. You must make sure that they, too, receive
or can get the source code. And you must show them these terms so they
know their rights.
Developers that use the GNU GPL protect your rights with two steps:
(1) assert copyright on the software, and (2) offer you this License
giving you legal permission to copy, distribute and/or modify it.
For the developers' and authors' protection, the GPL clearly explains
that there is no warranty for this free software. For both users' and
authors' sake, the GPL requires that modified versions be marked as
changed, so that their problems will not be attributed erroneously to
authors of previous versions.
Some devices are designed to deny users access to install or run
modified versions of the software inside them, although the manufacturer
can do so. This is fundamentally incompatible with the aim of
protecting users' freedom to change the software. The systematic
pattern of such abuse occurs in the area of products for individuals to
use, which is precisely where it is most unacceptable. Therefore, we
have designed this version of the GPL to prohibit the practice for those
products. If such problems arise substantially in other domains, we
stand ready to extend this provision to those domains in future versions
of the GPL, as needed to protect the freedom of users.
Finally, every program is threatened constantly by software patents.
States should not allow patents to restrict development and use of
software on general-purpose computers, but in those that do, we wish to
avoid the special danger that patents applied to a free program could
make it effectively proprietary. To prevent this, the GPL assures that
patents cannot be used to render the program non-free.
The precise terms and conditions for copying, distribution and
modification follow.
TERMS AND CONDITIONS
0. Definitions.
"This License" refers to version 3 of the GNU General Public License.
"Copyright" also means copyright-like laws that apply to other kinds of
works, such as semiconductor masks.
"The Program" refers to any copyrightable work licensed under this
License. Each licensee is addressed as "you". "Licensees" and
"recipients" may be individuals or organizations.
To "modify" a work means to copy from or adapt all or part of the work
in a fashion requiring copyright permission, other than the making of an
exact copy. The resulting work is called a "modified version" of the
earlier work or a work "based on" the earlier work.
A "covered work" means either the unmodified Program or a work based
on the Program.
To "propagate" a work means to do anything with it that, without
permission, would make you directly or secondarily liable for
infringement under applicable copyright law, except executing it on a
computer or modifying a private copy. Propagation includes copying,
distribution (with or without modification), making available to the
public, and in some countries other activities as well.
To "convey" a work means any kind of propagation that enables other
parties to make or receive copies. Mere interaction with a user through
a computer network, with no transfer of a copy, is not conveying.
An interactive user interface displays "Appropriate Legal Notices"
to the extent that it includes a convenient and prominently visible
feature that (1) displays an appropriate copyright notice, and (2)
tells the user that there is no warranty for the work (except to the
extent that warranties are provided), that licensees may convey the
work under this License, and how to view a copy of this License. If
the interface presents a list of user commands or options, such as a
menu, a prominent item in the list meets this criterion.
1. Source Code.
The "source code" for a work means the preferred form of the work
for making modifications to it. "Object code" means any non-source
form of a work.
A "Standard Interface" means an interface that either is an official
standard defined by a recognized standards body, or, in the case of
interfaces specified for a particular programming language, one that
is widely used among developers working in that language.
The "System Libraries" of an executable work include anything, other
than the work as a whole, that (a) is included in the normal form of
packaging a Major Component, but which is not part of that Major
Component, and (b) serves only to enable use of the work with that
Major Component, or to implement a Standard Interface for which an
implementation is available to the public in source code form. A
"Major Component", in this context, means a major essential component
(kernel, window system, and so on) of the specific operating system
(if any) on which the executable work runs, or a compiler used to
produce the work, or an object code interpreter used to run it.
The "Corresponding Source" for a work in object code form means all
the source code needed to generate, install, and (for an executable
work) run the object code and to modify the work, including scripts to
control those activities. However, it does not include the work's
System Libraries, or general-purpose tools or generally available free
programs which are used unmodified in performing those activities but
which are not part of the work. For example, Corresponding Source
includes interface definition files associated with source files for
the work, and the source code for shared libraries and dynamically
linked subprograms that the work is specifically designed to require,
such as by intimate data communication or control flow between those
subprograms and other parts of the work.
The Corresponding Source need not include anything that users
can regenerate automatically from other parts of the Corresponding
Source.
The Corresponding Source for a work in source code form is that
same work.
2. Basic Permissions.
All rights granted under this License are granted for the term of
copyright on the Program, and are irrevocable provided the stated
conditions are met. This License explicitly affirms your unlimited
permission to run the unmodified Program. The output from running a
covered work is covered by this License only if the output, given its
content, constitutes a covered work. This License acknowledges your
rights of fair use or other equivalent, as provided by copyright law.
You may make, run and propagate covered works that you do not
convey, without conditions so long as your license otherwise remains
in force. You may convey covered works to others for the sole purpose
of having them make modifications exclusively for you, or provide you
with facilities for running those works, provided that you comply with
the terms of this License in conveying all material for which you do
not control copyright. Those thus making or running the covered works
for you must do so exclusively on your behalf, under your direction
and control, on terms that prohibit them from making any copies of
your copyrighted material outside their relationship with you.
Conveying under any other circumstances is permitted solely under
the conditions stated below. Sublicensing is not allowed; section 10
makes it unnecessary.
3. Protecting Users' Legal Rights From Anti-Circumvention Law.
No covered work shall be deemed part of an effective technological
measure under any applicable law fulfilling obligations under article
11 of the WIPO copyright treaty adopted on 20 December 1996, or
similar laws prohibiting or restricting circumvention of such
measures.
When you convey a covered work, you waive any legal power to forbid
circumvention of technological measures to the extent such circumvention
is effected by exercising rights under this License with respect to
the covered work, and you disclaim any intention to limit operation or
modification of the work as a means of enforcing, against the work's
users, your or third parties' legal rights to forbid circumvention of
technological measures.
4. Conveying Verbatim Copies.
You may convey verbatim copies of the Program's source code as you
receive it, in any medium, provided that you conspicuously and
appropriately publish on each copy an appropriate copyright notice;
keep intact all notices stating that this License and any
non-permissive terms added in accord with section 7 apply to the code;
keep intact all notices of the absence of any warranty; and give all
recipients a copy of this License along with the Program.
You may charge any price or no price for each copy that you convey,
and you may offer support or warranty protection for a fee.
5. Conveying Modified Source Versions.
You may convey a work based on the Program, or the modifications to
produce it from the Program, in the form of source code under the
terms of section 4, provided that you also meet all of these conditions:
a) The work must carry prominent notices stating that you modified
it, and giving a relevant date.
b) The work must carry prominent notices stating that it is
released under this License and any conditions added under section
7. This requirement modifies the requirement in section 4 to
"keep intact all notices".
c) You must license the entire work, as a whole, under this
License to anyone who comes into possession of a copy. This
License will therefore apply, along with any applicable section 7
additional terms, to the whole of the work, and all its parts,
regardless of how they are packaged. This License gives no
permission to license the work in any other way, but it does not
invalidate such permission if you have separately received it.
d) If the work has interactive user interfaces, each must display
Appropriate Legal Notices; however, if the Program has interactive
interfaces that do not display Appropriate Legal Notices, your
work need not make them do so.
A compilation of a covered work with other separate and independent
works, which are not by their nature extensions of the covered work,
and which are not combined with it such as to form a larger program,
in or on a volume of a storage or distribution medium, is called an
"aggregate" if the compilation and its resulting copyright are not
used to limit the access or legal rights of the compilation's users
beyond what the individual works permit. Inclusion of a covered work
in an aggregate does not cause this License to apply to the other
parts of the aggregate.
6. Conveying Non-Source Forms.
You may convey a covered work in object code form under the terms
of sections 4 and 5, provided that you also convey the
machine-readable Corresponding Source under the terms of this License,
in one of these ways:
a) Convey the object code in, or embodied in, a physical product
(including a physical distribution medium), accompanied by the
Corresponding Source fixed on a durable physical medium
customarily used for software interchange.
b) Convey the object code in, or embodied in, a physical product
(including a physical distribution medium), accompanied by a
written offer, valid for at least three years and valid for as
long as you offer spare parts or customer support for that product
model, to give anyone who possesses the object code either (1) a
copy of the Corresponding Source for all the software in the
product that is covered by this License, on a durable physical
medium customarily used for software interchange, for a price no
more than your reasonable cost of physically performing this
conveying of source, or (2) access to copy the
Corresponding Source from a network server at no charge.
c) Convey individual copies of the object code with a copy of the
written offer to provide the Corresponding Source. This
alternative is allowed only occasionally and noncommercially, and
only if you received the object code with such an offer, in accord
with subsection 6b.
d) Convey the object code by offering access from a designated
place (gratis or for a charge), and offer equivalent access to the
Corresponding Source in the same way through the same place at no
further charge. You need not require recipients to copy the
Corresponding Source along with the object code. If the place to
copy the object code is a network server, the Corresponding Source
may be on a different server (operated by you or a third party)
that supports equivalent copying facilities, provided you maintain
clear directions next to the object code saying where to find the
Corresponding Source. Regardless of what server hosts the
Corresponding Source, you remain obligated to ensure that it is
available for as long as needed to satisfy these requirements.
e) Convey the object code using peer-to-peer transmission, provided
you inform other peers where the object code and Corresponding
Source of the work are being offered to the general public at no
charge under subsection 6d.
A separable portion of the object code, whose source code is excluded
from the Corresponding Source as a System Library, need not be
included in conveying the object code work.
A "User Product" is either (1) a "consumer product", which means any
tangible personal property which is normally used for personal, family,
or household purposes, or (2) anything designed or sold for incorporation
into a dwelling. In determining whether a product is a consumer product,
doubtful cases shall be resolved in favor of coverage. For a particular
product received by a particular user, "normally used" refers to a
typical or common use of that class of product, regardless of the status
of the particular user or of the way in which the particular user
actually uses, or expects or is expected to use, the product. A product
is a consumer product regardless of whether the product has substantial
commercial, industrial or non-consumer uses, unless such uses represent
the only significant mode of use of the product.
"Installation Information" for a User Product means any methods,
procedures, authorization keys, or other information required to install
and execute modified versions of a covered work in that User Product from
a modified version of its Corresponding Source. The information must
suffice to ensure that the continued functioning of the modified object
code is in no case prevented or interfered with solely because
modification has been made.
If you convey an object code work under this section in, or with, or
specifically for use in, a User Product, and the conveying occurs as
part of a transaction in which the right of possession and use of the
User Product is transferred to the recipient in perpetuity or for a
fixed term (regardless of how the transaction is characterized), the
Corresponding Source conveyed under this section must be accompanied
by the Installation Information. But this requirement does not apply
if neither you nor any third party retains the ability to install
modified object code on the User Product (for example, the work has
been installed in ROM).
The requirement to provide Installation Information does not include a
requirement to continue to provide support service, warranty, or updates
for a work that has been modified or installed by the recipient, or for
the User Product in which it has been modified or installed. Access to a
network may be denied when the modification itself materially and
adversely affects the operation of the network or violates the rules and
protocols for communication across the network.
Corresponding Source conveyed, and Installation Information provided,
in accord with this section must be in a format that is publicly
documented (and with an implementation available to the public in
source code form), and must require no special password or key for
unpacking, reading or copying.
7. Additional Terms.
"Additional permissions" are terms that supplement the terms of this
License by making exceptions from one or more of its conditions.
Additional permissions that are applicable to the entire Program shall
be treated as though they were included in this License, to the extent
that they are valid under applicable law. If additional permissions
apply only to part of the Program, that part may be used separately
under those permissions, but the entire Program remains governed by
this License without regard to the additional permissions.
When you convey a copy of a covered work, you may at your option
remove any additional permissions from that copy, or from any part of
it. (Additional permissions may be written to require their own
removal in certain cases when you modify the work.) You may place
additional permissions on material, added by you to a covered work,
for which you have or can give appropriate copyright permission.
Notwithstanding any other provision of this License, for material you
add to a covered work, you may (if authorized by the copyright holders of
that material) supplement the terms of this License with terms:
a) Disclaiming warranty or limiting liability differently from the
terms of sections 15 and 16 of this License; or
b) Requiring preservation of specified reasonable legal notices or
author attributions in that material or in the Appropriate Legal
Notices displayed by works containing it; or
c) Prohibiting misrepresentation of the origin of that material, or
requiring that modified versions of such material be marked in
reasonable ways as different from the original version; or
d) Limiting the use for publicity purposes of names of licensors or
authors of the material; or
e) Declining to grant rights under trademark law for use of some
trade names, trademarks, or service marks; or
f) Requiring indemnification of licensors and authors of that
material by anyone who conveys the material (or modified versions of
it) with contractual assumptions of liability to the recipient, for
any liability that these contractual assumptions directly impose on
those licensors and authors.
All other non-permissive additional terms are considered "further
restrictions" within the meaning of section 10. If the Program as you
received it, or any part of it, contains a notice stating that it is
governed by this License along with a term that is a further
restriction, you may remove that term. If a license document contains
a further restriction but permits relicensing or conveying under this
License, you may add to a covered work material governed by the terms
of that license document, provided that the further restriction does
not survive such relicensing or conveying.
If you add terms to a covered work in accord with this section, you
must place, in the relevant source files, a statement of the
additional terms that apply to those files, or a notice indicating
where to find the applicable terms.
Additional terms, permissive or non-permissive, may be stated in the
form of a separately written license, or stated as exceptions;
the above requirements apply either way.
8. Termination.
You may not propagate or modify a covered work except as expressly
provided under this License. Any attempt otherwise to propagate or
modify it is void, and will automatically terminate your rights under
this License (including any patent licenses granted under the third
paragraph of section 11).
However, if you cease all violation of this License, then your
license from a particular copyright holder is reinstated (a)
provisionally, unless and until the copyright holder explicitly and
finally terminates your license, and (b) permanently, if the copyright
holder fails to notify you of the violation by some reasonable means
prior to 60 days after the cessation.
Moreover, your license from a particular copyright holder is
reinstated permanently if the copyright holder notifies you of the
violation by some reasonable means, this is the first time you have
received notice of violation of this License (for any work) from that
copyright holder, and you cure the violation prior to 30 days after
your receipt of the notice.
Termination of your rights under this section does not terminate the
licenses of parties who have received copies or rights from you under
this License. If your rights have been terminated and not permanently
reinstated, you do not qualify to receive new licenses for the same
material under section 10.
9. Acceptance Not Required for Having Copies.
You are not required to accept this License in order to receive or
run a copy of the Program. Ancillary propagation of a covered work
occurring solely as a consequence of using peer-to-peer transmission
to receive a copy likewise does not require acceptance. However,
nothing other than this License grants you permission to propagate or
modify any covered work. These actions infringe copyright if you do
not accept this License. Therefore, by modifying or propagating a
covered work, you indicate your acceptance of this License to do so.
10. Automatic Licensing of Downstream Recipients.
Each time you convey a covered work, the recipient automatically
receives a license from the original licensors, to run, modify and
propagate that work, subject to this License. You are not responsible
for enforcing compliance by third parties with this License.
An "entity transaction" is a transaction transferring control of an
organization, or substantially all assets of one, or subdividing an
organization, or merging organizations. If propagation of a covered
work results from an entity transaction, each party to that
transaction who receives a copy of the work also receives whatever
licenses to the work the party's predecessor in interest had or could
give under the previous paragraph, plus a right to possession of the
Corresponding Source of the work from the predecessor in interest, if
the predecessor has it or can get it with reasonable efforts.
You may not impose any further restrictions on the exercise of the
rights granted or affirmed under this License. For example, you may
not impose a license fee, royalty, or other charge for exercise of
rights granted under this License, and you may not initiate litigation
(including a cross-claim or counterclaim in a lawsuit) alleging that
any patent claim is infringed by making, using, selling, offering for
sale, or importing the Program or any portion of it.
11. Patents.
A "contributor" is a copyright holder who authorizes use under this
License of the Program or a work on which the Program is based. The
work thus licensed is called the contributor's "contributor version".
A contributor's "essential patent claims" are all patent claims
owned or controlled by the contributor, whether already acquired or
hereafter acquired, that would be infringed by some manner, permitted
by this License, of making, using, or selling its contributor version,
but do not include claims that would be infringed only as a
consequence of further modification of the contributor version. For
purposes of this definition, "control" includes the right to grant
patent sublicenses in a manner consistent with the requirements of
this License.
Each contributor grants you a non-exclusive, worldwide, royalty-free
patent license under the contributor's essential patent claims, to
make, use, sell, offer for sale, import and otherwise run, modify and
propagate the contents of its contributor version.
In the following three paragraphs, a "patent license" is any express
agreement or commitment, however denominated, not to enforce a patent
(such as an express permission to practice a patent or covenant not to
sue for patent infringement). To "grant" such a patent license to a
party means to make such an agreement or commitment not to enforce a
patent against the party.
If you convey a covered work, knowingly relying on a patent license,
and the Corresponding Source of the work is not available for anyone
to copy, free of charge and under the terms of this License, through a
publicly available network server or other readily accessible means,
then you must either (1) cause the Corresponding Source to be so
available, or (2) arrange to deprive yourself of the benefit of the
patent license for this particular work, or (3) arrange, in a manner
consistent with the requirements of this License, to extend the patent
license to downstream recipients. "Knowingly relying" means you have
actual knowledge that, but for the patent license, your conveying the
covered work in a country, or your recipient's use of the covered work
in a country, would infringe one or more identifiable patents in that
country that you have reason to believe are valid.
If, pursuant to or in connection with a single transaction or
arrangement, you convey, or propagate by procuring conveyance of, a
covered work, and grant a patent license to some of the parties
receiving the covered work authorizing them to use, propagate, modify
or convey a specific copy of the covered work, then the patent license
you grant is automatically extended to all recipients of the covered
work and works based on it.
A patent license is "discriminatory" if it does not include within
the scope of its coverage, prohibits the exercise of, or is
conditioned on the non-exercise of one or more of the rights that are
specifically granted under this License. You may not convey a covered
work if you are a party to an arrangement with a third party that is
in the business of distributing software, under which you make payment
to the third party based on the extent of your activity of conveying
the work, and under which the third party grants, to any of the
parties who would receive the covered work from you, a discriminatory
patent license (a) in connection with copies of the covered work
conveyed by you (or copies made from those copies), or (b) primarily
for and in connection with specific products or compilations that
contain the covered work, unless you entered into that arrangement,
or that patent license was granted, prior to 28 March 2007.
Nothing in this License shall be construed as excluding or limiting
any implied license or other defenses to infringement that may
otherwise be available to you under applicable patent law.
12. No Surrender of Others' Freedom.
If conditions are imposed on you (whether by court order, agreement or
otherwise) that contradict the conditions of this License, they do not
excuse you from the conditions of this License. If you cannot convey a
covered work so as to satisfy simultaneously your obligations under this
License and any other pertinent obligations, then as a consequence you may
not convey it at all. For example, if you agree to terms that obligate you
to collect a royalty for further conveying from those to whom you convey
the Program, the only way you could satisfy both those terms and this
License would be to refrain entirely from conveying the Program.
13. Use with the GNU Affero General Public License.
Notwithstanding any other provision of this License, you have
permission to link or combine any covered work with a work licensed
under version 3 of the GNU Affero General Public License into a single
combined work, and to convey the resulting work. The terms of this
License will continue to apply to the part which is the covered work,
but the special requirements of the GNU Affero General Public License,
section 13, concerning interaction through a network will apply to the
combination as such.
14. Revised Versions of this License.
The Free Software Foundation may publish revised and/or new versions of
the GNU General Public License from time to time. Such new versions will
be similar in spirit to the present version, but may differ in detail to
address new problems or concerns.
Each version is given a distinguishing version number. If the
Program specifies that a certain numbered version of the GNU General
Public License "or any later version" applies to it, you have the
option of following the terms and conditions either of that numbered
version or of any later version published by the Free Software
Foundation. If the Program does not specify a version number of the
GNU General Public License, you may choose any version ever published
by the Free Software Foundation.
If the Program specifies that a proxy can decide which future
versions of the GNU General Public License can be used, that proxy's
public statement of acceptance of a version permanently authorizes you
to choose that version for the Program.
Later license versions may give you additional or different
permissions. However, no additional obligations are imposed on any
author or copyright holder as a result of your choosing to follow a
later version.
15. Disclaimer of Warranty.
THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
16. Limitation of Liability.
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
SUCH DAMAGES.
17. Interpretation of Sections 15 and 16.
If the disclaimer of warranty and limitation of liability provided
above cannot be given local legal effect according to their terms,
reviewing courts shall apply local law that most closely approximates
an absolute waiver of all civil liability in connection with the
Program, unless a warranty or assumption of liability accompanies a
copy of the Program in return for a fee.
END OF TERMS AND CONDITIONS
How to Apply These Terms to Your New Programs
If you develop a new program, and you want it to be of the greatest
possible use to the public, the best way to achieve this is to make it
free software which everyone can redistribute and change under these terms.
To do so, attach the following notices to the program. It is safest
to attach them to the start of each source file to most effectively
state the exclusion of warranty; and each file should have at least
the "copyright" line and a pointer to where the full notice is found.
<one line to give the program's name and a brief idea of what it does.>
Copyright (C) <year> <name of author>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
Also add information on how to contact you by electronic and paper mail.
If the program does terminal interaction, make it output a short
notice like this when it starts in an interactive mode:
<program> Copyright (C) <year> <name of author>
This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
This is free software, and you are welcome to redistribute it
under certain conditions; type `show c' for details.
The hypothetical commands `show w' and `show c' should show the appropriate
parts of the General Public License. Of course, your program's commands
might be different; for a GUI interface, you would use an "about box".
You should also get your employer (if you work as a programmer) or school,
if any, to sign a "copyright disclaimer" for the program, if necessary.
For more information on this, and how to apply and follow the GNU GPL, see
<https://www.gnu.org/licenses/>.
The GNU General Public License does not permit incorporating your program
into proprietary programs. If your program is a subroutine library, you
may consider it more useful to permit linking proprietary applications with
the library. If this is what you want to do, use the GNU Lesser General
Public License instead of this License. But first, please read
<https://www.gnu.org/licenses/why-not-lgpl.html>.
MIT License
Copyright (c) 2022 Jerry Ma
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

187
README-en.md Executable file
View File

@@ -0,0 +1,187 @@
# static-php-cli
Compile A Statically Linked PHP With Swoole and other Popular Extensions.
Compile A Single Binary With PHP Code.
[![version](https://img.shields.io/badge/version-1.5.2-green.svg)]()
![Build Actions](https://github.com/crazywhalecc/static-php-cli/actions/workflows/build-php.yml/badge.svg)
## Refactoring
The current project is under reconstruction, and this branch is an older version.
The refactored version supports many new features. The following is the current progress of refactoring:
- **Discussionhttps://github.com/crazywhalecc/static-php-cli/discussions/29**
- **Branch[refactor](https://github.com/crazywhalecc/static-php-cli/tree/refactor)**
- **Bugs and TODOshttps://github.com/crazywhalecc/static-php-cli/issues/32**
## Compilation Requirements
- Supporting architecture: `x86_64`, `arm64(aarch64)`, `armv7(armv7l)`
- Docker required (or alpine linux 3.13+)
- PHP version from 7.2 to 8.1
- Micro Package requires PHP >= 8.0
## Runtime Requirements
Linux
## Usage
1. Directly download static binary from this link or [Actions uploaded artifacts](https://github.com/crazywhalecc/static-php-cli/actions).
<https://dl.zhamao.xin/php-bin/file/>
2. Use fast install script `install-runtime.sh` to download static php and composer distribution into `runtime/` directory
But this script has some Chinese comments and prompts, if you cannot understand or have to use it in English, I will make an pure international version! :)
```bash
bash -c "`curl -fsSL https://raw.githubusercontent.com/crazywhalecc/static-php-cli/master/install-runtime.sh`"
```
## Packing PHP Code into a Static Binary
From v1.5.0, we support packing PHP code into a static binary. You can pack your PHP code into a static binary by micro.
You can directly download `micro-` prefix file, untar it and you will get file `micro.sfx`.
Here's a simple example to use it:
```bash
echo "<?php echo 'Hello world' . PHP_EOL;" > code.php
cat micro.sfx code.php > single-app && chmod +x single-app
./single-app
# If packing phar into a static binary, just change code.php to your phar path.
```
> Note: It means that your PHP code won't be compiled and you can't protect your source code by using micro!
>
> If you are looking for compiling PHP code or encrypting code, here's not your solution.
>
> Special thanks: <https://github.com/dixyes/phpmicro>
## Compiling
Here's help command to compile it yourself:
```bash
git clone https://github.com/crazywhalecc/static-php-cli.git
cd static-php-cli/docker
docker build -t static-php . --build-arg USE_BACKUP_ADDRESS=yes
# Making a directory to put binary files
mkdir dist
# It will ask you for PHP version, extensions, and compile static binaries
docker run --rm -v $(pwd)/dist:/dist/ -it static-php build-php
```
After compilation you can use command to get static php binary file.
```bash
cd dist
file ./php
```
If you don't want to use docker, a single script for compiling in **Alpine Linux**:
```bash
cd docker
# Change PHP Version
export VER_PHP="8.1.7"
# Use Original download link (Default is China mainland mirror link, for others please use 'yes' for original link)
export USE_BACKUP="yes"
./fast-compiler.sh
```
To customize PHP extensions, edit `docker/extensions.txt` file, and rules below:
- Use `^` as deselect, to mark not install. Use `#` as comments.
- extensions name uses lower case, and default file contains all supported extensions, if u need other extensions, consider write an Issue
## Supported PHP extensions
| Support | PHP Ext Name | Version | Comments |
| ------- | ------------ | ------- | ---------------------------------------- |
| yes | bcmath | * | |
| yes | calendar | * | |
| yes | ctype | * | |
| yes | curl | * | |
| yes | dom | * | |
| yes | event | >=3.0.8 | author's bitbucket version, not pecl |
| yes | exif | * | |
| yes | filter | * | |
| yes | fileinfo | * | |
| yes | gd | * | |
| yes | hash | * | |
| yes | iconv | * | |
| yes | inotify | 3.0.0 | |
| yes | json | * | |
| yes | libxml | * | |
| yes | mbstring | * | |
| yes | mongodb | >=1.9.1 | not tested |
| | mysqli | | |
| yes | mysqlnd | * | |
| yes | openssl | * | |
| yes | pcntl | * | |
| yes | pdo | * | |
| yes | pdo_mysql | * | |
| yes | pdo_sqlite | * | |
| | pdo_pgsql | * | |
| yes | phar | * | |
| yes | posix | * | |
| yes, not compiled | protobuf | * | Not compiled and enabled as default |
| yes | readline | * | Not support `./php -a` |
| yes | redis | * | |
| yes | shmop | * | |
| yes | simplexml | * | |
| yes | soap | * | |
| yes | sockets | * | |
| yes | sqlite3 | * | |
| yes | swoole | >=4.6.6 | support mysqlnd, sockets, openssl, redis |
| yes | tokenizer | * | |
| yes | xml | * | |
| yes | xmlreader | * | |
| yes | xmlwriter | * | |
| yes | zip | * | not support `bzip2`, `lzma` compression |
| yes | zlib | * | |
## Customization
- If you are going to run without prompt, Just add it to the end of `docker run xxx` cmd according to the parameters given below.
> 1st parameter `original` represents that you are using global original download address to fetch dependencies, if you are in mainland China, use `mirror`.
>
> 2nd parameter `8.1.7` is your PHP version you are compiling.
>
> 3rd parameter `all` represents that you will compile all supported extensions.
>
> 4th parameter `/dist/` is your binary output directory.
>
> For example, `docker run --rm -v $(pwd)/dist:/dist/ -it static-php build-php original 8.1.7 all /dist/`
- `docker/extensions.txt` edit extensions.
- `docker/compile-php.sh` file `php_compile_args` function to adjust PHP configure arguments.
- `docker/check-extensions.sh` file `check_in_configure` function to adjust extensions' configure arguments.
- `docker/config.json` edit extensions and dependencies version and download links.
## Current Issue
- [X] Not support event(libevent), because of its `config.m4` and code.
- [ ] Swoole not support `--enable-swoole-curl`.
- [X] Not support readline, maybe caused by ncurses library.
- [X] Not support curl (solved)
- [X] Customize extensions to compile
- [X] php.ini integration
- [X] i18n (including README and scripts)
## Running preview
### Using static binary
<img width="881" alt="未命名" src="https://user-images.githubusercontent.com/20330940/168441751-e62cb8d4-a3c8-42d9-b34e-d804b39756a1.png">
### Using swoole application packed with micro
<img width="937" alt="all" src="https://user-images.githubusercontent.com/20330940/168557743-b8f92263-712f-490e-9fe0-831597741595.png">
## References
- <https://blog.terrywh.net/post/2019/php-static-openssl/>
- <https://stackoverflow.com/a/37245653>
- <http://blog.gaoyuan.xyz/2014/04/09/statically-compile-php/>

258
README.md Normal file → Executable file
View File

@@ -1,61 +1,223 @@
# static-php-swoole
Compile A Statically Linked PHP With Swoole and other Extensions
编译纯静态的 PHP Binary 二进制文件带有各种扩展CLI 模式,暂不支持 CGI 和 FPM 模式)
# static-php-cli
Compile A Statically Linked PHP With Swoole and other Extensions. [English README](README-en.md)
[![版本](https://img.shields.io/badge/version-1.1.1-green.svg)]()
编译纯静态的 PHP Binary 二进制文件,带有各种扩展,让 PHP-cli 应用变得更便携!
## 环境需求
- 目前在 x86_64 和 aarch64(arm64) 架构上编译成功,其他架构需自行测试
- 需要 Alpine Linux测试环境为 3.13 版本,其他版本未测试)系统(也就是说需要 musl
- WSL2 也是支持的
同时可以使用 micro 二进制文件,将 PHP 源码和 PHP 二进制构建为一个文件分发!
注:只能编译 CLI 模式,暂不支持 CGI 和 FPM 模式
[![版本](https://img.shields.io/badge/script--version-1.5.2-green.svg)]()
[![License](https://img.shields.io/badge/License-MIT-blue.svg)]()
![Build Actions](https://github.com/crazywhalecc/static-php-cli/actions/workflows/build-php.yml/badge.svg)
## 重构
本分支为旧版。重构版支持很多新特性。下面是目前重构的进度:
- **关于重构版的讨论https://github.com/crazywhalecc/static-php-cli/discussions/29**
- **重构的分支:[refactor](https://github.com/crazywhalecc/static-php-cli/tree/refactor)**
- **重构的问题和待办https://github.com/crazywhalecc/static-php-cli/issues/32**
**目前重构版已经完成本分支的所有扩展,并且还支持更多扩展**
## 编译环境需求
- 目前支持 arm64、x86_64、armv7l 架构
- 需要 Docker也可以直接在 Alpine Linux 上使用)
- 脚本支持编译的 PHP 版本7.2 ~ 8.1
## 运行环境需求
Linux
## 直接使用
1. 可以直接下面的托管服务器或到 `Actions` 找到最新的构建项目下载 Actions 构建的文件。
<https://dl.zhamao.xin/php-bin/file/>
2. 可以直接使用快速脚本 `install-runtime.sh`,将静态 PHP 二进制及 Composer 下载到当前目录的 `runtime/` 子目录下:
## 开始
可以直接在旁边的 Release 中下载编译好的二进制,也可以自己编译。
```bash
# 自己编译
./static-compile-php.sh
# 完事后在 `php-dist/bin/php` 这个二进制文件可以随意拿着去任何一个 Linux 系统运行了!
# 可以使用 export ZM_DOWN_PHP_VERION=8.0 来切换 PHP 版本
bash <(curl -fsSL https://dl.zhamao.xin/php-bin/install-runtime.sh)
```
## 包含扩展
- bcmath
- calendar
- ctype
- filter
- openssl
- pcntl
- iconv
- json
- mbstring
- phar
- curl
- pdo
- gd
- pdo_mysql
- mysqlnd
- sockets
- swoole
- redis
- simplexml
- dom
- xml
- xmlwriter
- xmlreader
- posix
- tokenizer
## PHP 代码打包使用
v1.5.0 脚本开始,脚本新增了对 PHP 代码打包的支持,可以将 PHP 代码打包为一个文件分发,方便在 Linux 系统使用。(仅支持 PHP >= 8.0
1. 可以直接在上面的下载链接中下载 `micro-` 开头的文件并解压,获得 `micro.sfx` 文件后,使用以下命令和 PHP 源码或 PHAR 结合:
```bash
echo "<?php echo 'Hello world' . PHP_EOL;" > code.php
cat micro.sfx code.php > single-app && chmod +x single-app
./single-app
# 如果打包 PHAR 文件,仅需把 code.php 更换为 phar 文件路径即可
```
2. 如果打包项目,可以先将项目打包为 phar + entry然后结合打包 micro 与 phar 文件即可。
> 关于如何将项目打包为 phar见项目 [php-cli-helper](https://github.com/crazywhalecc/php-cli-helper)。
> 感谢 <https://github.com/dixyes/phpmicro> 项目提供的支持
## 自行编译
可以自己使用 Dockerfile 进行编译构建:
```bash
git clone https://github.com/crazywhalecc/static-php-cli.git
cd static-php-cli/docker
export DOCKER_BUILDKIT=1
docker build -t static-php . --build-arg USE_BACKUP_ADDRESS=no
# 新建一个用于放置构建好的二进制的文件夹
mkdir dist
# 终端会引导你进行编译安装,可选择 PHP 版本、要编译的扩展
docker run --rm -v $(pwd)/dist:/dist/ -it static-php build-php
```
编译之后可以使用下方命令将二进制 PHP 提取出来,用以下方式:
```bash
cd dist
file ./php
# 如果是 PHP 8.0 以上,同时会输出 micro 构建版本
file ./micro.sfx
```
如果你不想使用 Docker想从Alpine环境直接编译可以使用预置相同编译配置的脚本 `fast-compiler.sh`
```bash
cd docker
# 用于切换编译的PHP版本
export VER_PHP="8.1.7"
./fast-compiler.sh
```
如果要选择安装的扩展,可以修改 `docker/extensions.txt` 文件,具体规则如下:
- 文件内使用 `^` 可以表示默认不安装该扩展,`#` 开头可以编写注释
- 扩展名一律使用小写,目前默认状态下文件内所列的扩展为支持的扩展,其他扩展暂不支持,如有需求请提 Issue 添加
## 支持的扩展表
| 是否支持 | PHP 扩展名称 | 支持版本 | 备注 |
| -------- | ------------ | -------- | ------------------------------------------------------- |
| yes, enabled | bcmath | * | |
| yes, enabled | calendar | * | |
| yes, enabled | ctype | * | |
| yes, enabled | curl | * | 自带下载编译 curl 库 |
| yes, enabled | dom | * | |
| yes, enabled | event | >=3.0.8 | 从 BitBucket 作者仓库下载,非 pecl 版本 |
| yes, enabled | exif | * | |
| yes, enabled | filter | * | |
| yes, enabled | fileinfo | * | |
| yes, enabled | gd | * | |
| yes, enabled | hash | * | |
| yes, enabled | iconv | * | |
| yes, enabled | inotify | 3.0.0 | 从 pecl 或镜像站下载的源码 |
| yes, enabled | json | * | |
| yes, enabled | libxml | * | 自带下载编译 libxml2 库 |
| yes, enabled | mbstring | * | |
| yes, enabled | mongodb | >=1.9.1 | 未测试,从 pecl 或镜像站下载的源码 |
| | mysqli | | |
| yes, enabled | mysqlnd | * | |
| yes, enabled | openssl | * | |
| yes, enabled | pcntl | * | |
| yes, enabled | pdo | * | |
| yes, enabled | pdo_mysql | * | |
| yes, enabled | pdo_sqlite | * | |
| | pdo_pgsql | * | |
| yes, enabled | phar | * | |
| yes, enabled | posix | * | |
| yes, not enabled | protobuf | * | 默认不编译 |
| yes, enabled | readline | * | 不支持 `./php -a` |
| yes, enabled | redis | * | 从 pecl 或镜像站下载的源码 |
| yes, enabled | shmop | * | |
| yes, enabled | simplexml | * | |
| yes, enabled | soap | * | |
| yes, enabled | sockets | * | |
| yes, enabled | sqlite3 | * | |
| yes, enabled | swoole | >=4.6.6 | 使用参数 `--enable-openssl --with-openssl --with-openssl-dir=/usr`,从 pecl 或镜像站下载的源码 |
| yes, enabled | tokenizer | * | |
| yes, enabled | xml | * | |
| yes, enabled | xmlreader | * | |
| yes, enabled | xmlwriter | * | |
| yes, enabled | zip | * | 因链接库原因已关闭 `libzip` 库的 `bzip2``lzma` 支持 |
| yes, enabled | zlib | * | |
## 自定义
- 从 Docker 运行编译会依次询问下载地址、PHP 版本、要编译的扩展、编译输出文件夹。
- 如果不想弹出终端交互框,只需按照下方给出的参数加到字符串的后面。
> `参数1`: `original` 代表使用原始地址,如果你位于中国大陆,可使用 `mirror` 加快下载。
>
> `参数2`: `8.1.7` 是你要编译的 PHP 版本。
>
> `参数3`: `all` 代表你要编译所有非反选的扩展,不询问。
>
> `参数4`: `/dist/` 是你编译后输出二进制 PHP 和 micro 的文件夹
>
> 基本例子: `docker run --rm -v $(pwd)/dist:/dist/ -it static-php build-php original 8.1.7 all /dist/`
- `docker/extensions.txt` 指定要编译安装的扩展。
- `docker/extensions.txt` 中,`^` 开头的扩展名为反选,反选的扩展将出现在编译的扩展列表中,但默认不选中。
- `docker/compile-php.sh` 中的 `php_compile_args` 函数来调整 PHP 编译参数。
- `docker/check-extensions.sh` 中的 `check_in_configure` 函数可调整 PHP 扩展编译的参数。
- `docker/config.json` 可调整要下载的扩展和依赖库版本和链接。
- `docker/fast-compiler.sh` 可以在 Alpine Linux 系统下直接运行。
## 目前的问题(对勾为已解决)
- [X] 不支持 event(libevent) 扩展event 扩展的 sockets 支持不能在静态编译中使用,因为静态内嵌编译暂时没办法调整扩展编译顺序,同时其本身也不支持静态编译。
- [ ] Swoole 扩展不支持 `--enable-swoole-curl`,也是因为编译顺序和加载顺序的问题。
- [X] 不支持 readline 扩展readline 扩展安装后无法正常使用 `php -a`,原因还没有弄清楚,可能是静态编译造成的 ncurses 库出现了问题。
- [X] curl/libcurl 扩展静态编译
- [X] 可自行选择不需要编译进入的扩展
- [X] php.ini 内嵌或分发
- [X] i18n国际化脚本本身和 README
如果你对以上问题有解决方案,请提出 Issue 或 PR
如果你对此脚本比较感兴趣,未来会在此编写脚本中涉及内容的解析和说明。
## 运行示例
编译后的状态
![image](https://user-images.githubusercontent.com/20330940/116291663-6df47580-a7c7-11eb-8df3-6340c6f87055.png)
在不同系统直接运行 Swoft
![image](https://user-images.githubusercontent.com/20330940/116053161-f16d7400-a6ac-11eb-87b8-e510c6454861.png)
### 静态 PHP 运行脚本
## Todo List
- [X] curl/libcurl 扩展静态编译
- [ ] 可自行选择不需要编译进入的扩展
- [ ] php.ini 内嵌或分发
- [ ] 尝试带进去个 composer其实自己下完全可以
<img width="881" alt="未命名" src="https://user-images.githubusercontent.com/20330940/168441751-e62cb8d4-a3c8-42d9-b34e-d804b39756a1.png">
### micro 打包运行 Swoole
<img width="937" alt="all" src="https://user-images.githubusercontent.com/20330940/168557743-b8f92263-712f-490e-9fe0-831597741595.png">
## 原理
静态编译是一项比较多见于 Golang 的编译方式,在传统的 Linux 系统下正常的程序和库基本是动态编译链接Dynamically linked也就是说不同程序引用同样的库可以共用减少资源重复。
但是由于不少系统软件环境配置复杂,或者依赖的库版本冲突,一般使用 Docker 等容器技术可以解决这一问题。但 Docker 等容器也需要拉取镜像,体积较大,对于程序有便携需求的人(比如网络安全员做渗透测试等)需要很多程序可以像 Windows 上的绿色程序一样随处打包运行。
PHP 是最好的编程语言,它编写容易,易于部署和开发,倘若将 PHP 编译为静态的文件,并且将 Swoole 或 libevent 等库同样内嵌,那 PHP 不仅将可以编写便携的 Web 服务器,还能做很多想不到的事!
编译静态 PHP 大致分为以下几个步骤:
1. 下载 PHP 源码
2. 下载需要静态编译的额外扩展源码(如 inotify、mongodb、redis 等)
3. 将额外扩展源码放入 PHP 源码中
4. 生成 `configure` 并使用 `-static` 的 FLAG 进行生成 makefile
5. 修改 Makefile 中的编译参数,增加 `-all-static` 和去掉 dynamic 相关的参数
6. 使用 `make` 构建静态 PHP
7. 使用 `make install` 安装到指定目录,再使用 `strip` 去除符号表缩小体积
对于第二步,如果额外扩展中有依赖 Linux 的其他库(比如 curl 依赖 libcurl则需要在第二步之前编译安装对应库的静态版本比如 libxml2.a
而此处出问题最多的部分就是安装额外扩展的依赖上,很多库不支持静态编译,而互联网很难找到对对应库进行静态编译的资料。
脚本和 Dockerfile 统一采用 Alpine 的目的就是apk 包管理下有很多库提供了 `*-static` 静态版本,直接使用包管理安装就可以使用,而即使没有,也可以使用 musl-libc 进行静态编译,避免 glibc 下的 `libnss` 等无法静态编译的问题。
第二种要面对比较棘手的问题就是 PHP 扩展可能本身不支持静态编译(如 curl 扩展),有些通过绕过手段可以静态编译,但有些只能通过对扩展源码进行修改才能使其支持。
所以这个项目中涉及的脚本,最大的问题就在于对其他依赖的处理,而不是 PHP 编译本身。PHP 如果不启用任何扩展(即使用 `--disable-all`),则可以很方便地静态编译。
## 参考资料
- <https://blog.terrywh.net/post/2019/php-static-openssl/>

89
docker/Dockerfile Executable file
View File

@@ -0,0 +1,89 @@
FROM alpine:3.16
# define script basic information
# Version of this Dockerfile
ENV SCRIPT_VERSION=1.5.1
# Download address uses backup address
ARG USE_BACKUP_ADDRESS
# (if downloading slowly, consider set it to yes)
ENV USE_BACKUP="${USE_BACKUP_ADDRESS}"
# APK repositories mirror address, if u r not in China, consider set USE_BACKUP=yes to boost
ENV LINK_APK_REPO='mirrors.ustc.edu.cn'
ENV LINK_APK_REPO_BAK='dl-cdn.alpinelinux.org'
RUN if [ "${USE_BACKUP}" = "" ]; then \
export USE_BACKUP="no" ; \
fi
RUN sed -i.backup 's/dl-cdn.alpinelinux.org/'${LINK_APK_REPO}'/g' /etc/apk/repositories ;
RUN if [ "${USE_BACKUP}" = "no" ]; then cp -f /etc/apk/repositories.backup /etc/apk/repositories; fi
RUN cat /etc/apk/repositories
# build requirements
RUN apk add bash file wget cmake gcc g++ jq autoconf git libstdc++ linux-headers make m4 libgcc binutils ncurses dialog > /dev/null
# php zlib dependencies
RUN apk add zlib-dev zlib-static > /dev/null
# php mbstring dependencies
RUN apk add oniguruma-dev > /dev/null
# php openssl dependencies
RUN apk add openssl-libs-static openssl-dev openssl > /dev/null
# php gd dependencies
RUN apk add libpng-dev libpng-static > /dev/null
# curl c-ares dependencies
RUN apk add c-ares-static c-ares-dev > /dev/null
# php event dependencies
RUN apk add libevent libevent-dev libevent-static > /dev/null
# php sqlite3 dependencies
RUN apk add sqlite sqlite-dev sqlite-libs sqlite-static > /dev/null
# php libzip dependencies
RUN apk add bzip2-dev bzip2-static bzip2 > /dev/null
# php micro ffi dependencies
RUN apk add libffi libffi-dev > /dev/null
# php gd event parent dependencies
RUN apk add zstd-static > /dev/null
# php readline dependencies
RUN apk add readline-static ncurses-static readline-dev > /dev/null
RUN apk add aria2
RUN mkdir /app
WORKDIR /app
ADD ./ /app/
# RUN chmod +x /app/*.sh
# use proxy
# ENV http_proxy=http://192.168.3.26:8015
# ENV https_proxy=http://192.168.3.26:8015
# 提前下载好,就可以跳过两步
# (容器外提前执行 下面两个命令)
RUN sh ./download-library-batch-aria2.sh
RUN sh ./download-extension-batch-aria2.sh
#ENV http_proxy=''
#ENV https_proxy=''
RUN ls -lh source/libraries
RUN ls -lh source/extensions
# quick test complie
# RUN bash ./compile-deps.sh
RUN sh ./download.sh swoole ${USE_BACKUP} && \
sh ./download.sh inotify ${USE_BACKUP} && \
sh ./download.sh mongodb ${USE_BACKUP} && \
sh ./download.sh event ${USE_BACKUP} && \
sh ./download.sh redis ${USE_BACKUP} && \
sh ./download.sh libxml2 ${USE_BACKUP} && \
sh ./download.sh xz ${USE_BACKUP} && \
sh ./download.sh curl ${USE_BACKUP} && \
sh ./download.sh libzip ${USE_BACKUP} && \
sh ./download.sh libiconv ${USE_BACKUP} && \
sh ./download-git.sh dixyes/phpmicro phpmicro ${USE_BACKUP}
RUN bash ./compile-deps.sh
RUN echo -e "#!/usr/bin/env bash\n/app/compile-php.sh \$@" > /bin/build-php && chmod +x /bin/build-php

3
docker/ac_override_1 Executable file
View File

@@ -0,0 +1,3 @@
AC_DEFUN([PHP_CHECK_LIBRARY], [
$3
])

18
docker/ac_override_2 Executable file
View File

@@ -0,0 +1,18 @@
AC_DEFUN([PHP_CHECK_LIBRARY], [
save_old_LDFLAGS=$LDFLAGS
ac_stuff="$5"
save_ext_shared=$ext_shared
ext_shared=yes
PHP_EVAL_LIBLINE([$]ac_stuff, LDFLAGS)
AC_CHECK_LIB([$1],[$2],[
LDFLAGS=$save_old_LDFLAGS
ext_shared=$save_ext_shared
$3
],[
LDFLAGS=$save_old_LDFLAGS
ext_shared=$save_ext_shared
unset ac_cv_lib_$1[]_$2
$4
])dnl
])

200
docker/check-extensions.sh Executable file
View File

@@ -0,0 +1,200 @@
#!/bin/sh
# Here are 3 steps in configuration of extensions
# before_configure
# in_configure
# after_configure
self_dir=$(cd "$(dirname "$0")";pwd)
php_dir=$(find $self_dir/source -name "php-*" -type d | tail -n1)
test -f "$self_dir/extensions_install.txt" && EXT_LIST_FILE="$self_dir/extensions_install.txt" || EXT_LIST_FILE="$self_dir/extensions.txt"
function do_copy_extension() {
ext_dir=$(find $self_dir/source -name "*$1-*" -type d | tail -n1)
mv $ext_dir $php_dir/ext/$1
if [ $? != 0 ]; then
echo "Compile error! ext: $1, ext_dir=$ext_dir"
exit 1
fi
}
function check_before_configure() {
list=$(cat "$EXT_LIST_FILE" | grep -v "^#" | grep -v "^$" | grep -v "^\^")
xml_sign="no"
for loop in $list
do
case $loop in
bcmath) ;;
calendar) ;;
ctype) ;;
exif) ;;
filter) ;;
fileinfo) ;;
gd) ;;
hash) ;;
iconv) ;;
json) ;;
mbstring) ;;
mysqlnd) ;;
openssl) ;;
pcntl) ;;
pdo) ;;
pdo_mysql) ;;
pdo_sqlite) ;;
phar) ;;
posix) ;;
protobuf)
do_copy_extension protobuf
echo '#ifndef PHP_PROTOBUF_H' >> $php_dir/ext/protobuf/php_protobuf.h && \
echo '# define PHP_PROTOBUF_H' >> $php_dir/ext/protobuf/php_protobuf.h && \
echo '#ifdef HAVE_CONFIG_H' >> $php_dir/ext/protobuf/php_protobuf.h && \
echo '# include "config.h"' >> $php_dir/ext/protobuf/php_protobuf.h && \
echo '#endif' >> $php_dir/ext/protobuf/php_protobuf.h && \
echo 'extern zend_module_entry protobuf_module_entry;' >> $php_dir/ext/protobuf/php_protobuf.h && \
echo '# define phpext_protobuf_ptr &protobuf_module_entry' >> $php_dir/ext/protobuf/php_protobuf.h && \
echo '#endif' >> $php_dir/ext/protobuf/php_protobuf.h
;;
readline)
if [ ! -d "/nom" ]; then
mkdir /nom
fi
mv /usr/lib/libreadline.so* /nom/ && \
mv /usr/lib/libncurses*.so* /nom
;;
shmop) ;;
sockets) ;;
sqlite3) ;;
tokenizer) ;;
zlib) ;;
zip) ;;
curl) cat "$self_dir/ac_override_1" "$php_dir/ext/curl/config.m4" "$self_dir/ac_override_2" > /tmp/aa && mv /tmp/aa "$php_dir/ext/curl/config.m4" ;;
dom|xml|libxml|xmlreader|xmlwriter|simplexml|soap) ;;
inotify) do_copy_extension inotify ;;
redis) do_copy_extension redis ;;
swoole) do_copy_extension swoole ;;
mongodb) do_copy_extension mongodb ;;
event) do_copy_extension event ;;
esac
done
case $1 in
8.*)
mv $self_dir/source/phpmicro $php_dir/sapi/micro && \
sed -ie 's/#include "php.h"/#include "php.h"\n#define PHP_MICRO_FAKE_CLI 1/g' $php_dir/sapi/micro/php_micro.c
;;
esac
}
function check_in_configure() {
php_configure=""
list=$(cat "$EXT_LIST_FILE" | sed 's/#.*//g' | sed 's/\^.*//g' | sed -e 's/[ ]*$//g' | grep -v "^\s*$")
for loop in $list
do
case $loop in
bcmath) php_configure="$php_configure --enable-bcmath" ;;
calendar) php_configure="$php_configure --enable-calendar" ;;
ctype) php_configure="$php_configure --enable-ctype" ;;
curl) php_configure="$php_configure --with-curl" ;;
dom) php_configure="$php_configure --enable-dom" ;;
exif) php_configure="$php_configure --enable-exif" ;;
event) php_configure="$php_configure --with-event-libevent-dir=/usr --with-event-core --with-event-extra --with-event-openssl" ;;
filter) php_configure="$php_configure --enable-filter" ;;
fileinfo) php_configure="$php_configure --enable-fileinfo" ;;
gd)
case $1 in
7.3.*|7.2.*) php_configure="$php_configure --with-gd" ;;
7.4.*|8.*) php_configure="$php_configure --enable-gd" ;;
esac
;;
hash)
case $1 in
7.3.*|7.2.*) php_configure="$php_configure --enable-hash" ;;
esac
;;
iconv) php_configure="$php_configure --with-iconv=/usr" ;;
inotify) php_configure="$php_configure --enable-inotify" ;;
json)
case $1 in
7.*) php_configure="$php_configure --enable-json" ;;
esac
;;
libxml)
case $1 in
7.3.*|7.2.*) php_configure="$php_configure --enable-libxml" ;;
7.4.*|8.*) php_configure="$php_configure --with-libxml" ;;
esac
;;
mbstring) php_configure="$php_configure --enable-mbstring" ;;
mongodb) php_configure="$php_configure --enable-mongodb" ;;
mysqlnd) php_configure="$php_configure --enable-mysqlnd" ;;
openssl) php_configure="$php_configure --with-openssl --with-openssl-dir=/usr" ;;
pcntl) php_configure="$php_configure --enable-pcntl" ;;
pdo) php_configure="$php_configure --enable-pdo" ;;
pdo_mysql) php_configure="$php_configure --with-pdo-mysql=mysqlnd" ;;
phar) php_configure="$php_configure --enable-phar" ;;
posix) php_configure="$php_configure --enable-posix" ;;
protobuf) php_configure="$php_configure --enable-protobuf" ;;
readline) php_configure="$php_configure --with-readline" ;;
redis) php_configure="$php_configure --enable-redis --disable-redis-session" ;;
shmop) php_configure="$php_configure --enable-shmop" ;;
simplexml) php_configure="$php_configure --enable-simplexml" ;;
sockets) php_configure="$php_configure --enable-sockets" ;;
soap) php_configure="$php_configure --enable-soap" ;;
sqlite3) php_configure="$php_configure --with-sqlite3" ;;
pdo_sqlite) php_configure="$php_configure --with-pdo-sqlite" ;;
swoole)
php_configure="$php_configure --enable-swoole"
have_openssl=$(echo $list | grep openssl)
if [ "$have_openssl" != "" ]; then
php_configure="$php_configure --enable-openssl --with-openssl --with-openssl-dir=/usr"
fi
have_hash=$(echo $list | grep hash)
if [ "$have_hash" = "" ]; then
case $1 in
7.3.*|7.2.*) php_configure="$php_configure --enable-hash" ;;
esac
fi
;;
tokenizer) php_configure="$php_configure --enable-tokenizer" ;;
xml) php_configure="$php_configure --enable-xml" ;;
xmlreader) php_configure="$php_configure --enable-xmlreader" ;;
xmlwriter) php_configure="$php_configure --enable-xmlwriter" ;;
zlib) php_configure="$php_configure --with-zlib" ;;
zip) php_configure="$php_configure --with-zip" ;;
*)
echo "Unsupported extension '$loop' !" >&2
exit 1
;;
esac
done
case $1 in
8.*) php_configure="$php_configure --with-ffi --enable-micro=all-static" ;;
esac
echo $php_configure
}
function check_after_configure() {
list=$(cat "$EXT_LIST_FILE" | grep -v "^#" | grep -v "^$")
for loop in $list
do
case $loop in
swoole)
sed -ie 's/swoole_clock_gettime(CLOCK_REALTIME/clock_gettime(CLOCK_REALTIME/g' "$php_dir/ext/swoole/include/swoole.h"
sed -ie 's/strcmp("cli", sapi_module.name) == 0/strcmp("cli", sapi_module.name) == 0 || strcmp("micro", sapi_module.name) == 0/g' "$php_dir/ext/swoole/ext-src/php_swoole.cc"
;;
esac
done
case $1 in
8.*) sed -ie 's/$(EXTRA_LIBS:-lresolv=-Wl,-Bstatic,-lresolv,-Bdynamic)/$(EXTRA_LIBS)/g' "$php_dir/Makefile" ;;
esac
}
function finish_compile() {
if [ -d "/nom" ]; then
mv /nom/* /usr/lib/ || echo "Empty directory"
rm -rf /nom/
fi
}
$1 $2

64
docker/compile-deps.sh Executable file
View File

@@ -0,0 +1,64 @@
#!/usr/bin/env bash
self_dir=$(cd "$(dirname "$0")";pwd)
function do_xml_compiler() {
cd $self_dir/source/xz-* && \
./configure --enable-static=yes && \
make -j$(cat /proc/cpuinfo | grep processor | wc -l) && \
make install && \
echo "xz compiled!" && \
cd ../libxml2-* && \
./configure --prefix=/usr --with-lzma --without-python && \
make -j$(cat /proc/cpuinfo | grep processor | wc -l) && \
make install && \
echo "libxml2 compiled!"
}
function do_libzip_compiler() {
cd $self_dir/source/libzip-* && \
mkdir build && \
cd build && \
cmake -DBUILD_SHARED_LIBS=no .. -Wno-dev -DENABLE_BZIP2=no -DENABLE_LZMA=no && \
make LDFLAGS="-llzma -lbz2" -j$(cat /proc/cpuinfo | grep processor | wc -l) && \
make install && \
echo "libzip compiled!"
}
function do_curl_compiler() {
cd $self_dir/source/curl-* && \
CC=gcc CXX=g++ CFLAGS=-fPIC CPPFLAGS=-fPIC ./configure \
--without-nghttp2 \
--with-ssl=/usr \
--with-pic=pic \
--enable-ipv6 \
--enable-shared=no \
--without-libidn2 \
--disable-ldap \
--without-libpsl \
--without-lber \
--enable-ares && \
make -j$(cat /proc/cpuinfo | grep processor | wc -l) && \
make install && \
echo "curl compiled!"
}
function do_iconv_compiler() {
cd $self_dir/source/libiconv-* && \
./configure --enable-static=yes --prefix=/usr && \
make -j$(cat /proc/cpuinfo | grep processor | wc -l) && \
make install && \
echo "libiconv compiled!"
}
if [ ! -f "$self_dir/source/.deps-compiled" ]; then
source ${self_dir}/deps-modules/libmcrypt.sh
source ${self_dir}/deps-modules/gmp.sh
do_xml_compiler && \
do_curl_compiler && \
do_libzip_compiler && \
do_iconv_compiler && \
touch "$self_dir/source/.deps-compiled"
else
echo "Skip compilation for dependencies"
fi

125
docker/compile-php.sh Executable file
View File

@@ -0,0 +1,125 @@
#!/usr/bin/env bash
self_dir=$(cd "$(dirname "$0")";pwd)
# 通过 extensions.txt 生成一个 dialog 命令
function generate_ext_dialog_cmd() {
list=$(cat "$self_dir/extensions.txt" | grep -v "^#" | grep -v "^$")
echo -n "dialog --backtitle \"static-php-cli Compile Options\" --checklist \"Please select the extension you don't want to compile.\n\nNOTE: Use <space> to select or deselect items\n\n** Default is compiling all **\" 24 60 20 " > $self_dir/.ask_cmd.sh
for loop in $list
do
case $loop in
^*)
loop=$(echo ${loop:1} | xargs)
echo -n "$loop '$loop Extension' off " >> $self_dir/.ask_cmd.sh
;;
*) echo -n "$loop '$loop Extension' on " >> $self_dir/.ask_cmd.sh ;;
esac
done
echo "2>$self_dir/extensions_install.txt" >> $self_dir/.ask_cmd.sh
}
# PHP 编译参数生成
function php_compile_args() {
_php_arg="--prefix=$self_dir/php-dist"
_php_arg="$_php_arg --disable-all"
_php_arg="$_php_arg --enable-shared=no"
_php_arg="$_php_arg --enable-static=yes"
_php_arg="$_php_arg --enable-inline-optimization"
_php_arg="$_php_arg --with-layout=GNU"
_php_arg="$_php_arg --with-pear=no"
_php_arg="$_php_arg --disable-cgi"
_php_arg="$_php_arg --disable-phpdbg"
_php_arg="$_php_arg --with-config-file-path=/etc"
_php_arg="$_php_arg $($self_dir/check-extensions.sh check_in_configure $1)"
echo $_php_arg
}
# 第一个参数用于使用镜像地址还是原地址mirror为镜像地址original为原地址
if [ "$1" = "" ]; then
dialog --backtitle "static-php-cli Compile Options" --yesno "<Yes>: Use mirror download address, mainland China users recommended.\n\n<No>: Use original address, global users recommended." 10 50
test $? == 0 && USE_BACKUP="no" || USE_BACKUP="yes"
else
test "$1" != "mirror" && USE_BACKUP="yes" || USE_BACKUP="no"
fi
# 第二个参数用于规定编译的 PHP 版本
if [ "$2" = "" ]; then
dialog --backtitle "static-php-cli Compile Options" --inputbox "Please input your PHP version to compile" 10 50 "8.1.7" 2>$self_dir/.phpver
if [ $? != 0 ]; then
clear
echo "canceled Compiling PHP." && rm -f $self_dir/.phpver
exit 1
else
VER_PHP=$(cat $self_dir/.phpver)
rm -f $self_dir/.phpver
fi
else
VER_PHP=$2
fi
# 第三个参数用于是否直接安装,如果留空则询问编译的扩展,如果填入 all则直接编译所有的扩展
if [ "$3" != "all" ]; then
generate_ext_dialog_cmd && cat $self_dir/.ask_cmd.sh && chmod +x $self_dir/.ask_cmd.sh && $self_dir/.ask_cmd.sh
if [ $? != 0 ]; then
clear
echo "canceled Compiling PHP while selecting extensions." && rm -rf $self_dir/.ask_cmd.sh
exit 1
fi
rm -f $self_dir/.ask_cmd.sh
else
cp $self_dir/extensions.txt $self_dir/extensions_install.txt
fi
# 第四个参数用于输出 PHP 和 micro 二进制文件的位置
if [ "$4" = "" ]; then
dialog --backtitle "static-php-cli Compile Options" --inputbox "Please input compiled output directory" 10 50 "/dist/" 2>$self_dir/.outdir
if [ $? != 0 ]; then
clear
echo "canceled setting output dir, compiling PHP stopped." && rm -f $self_dir/.outdir
exit 1
else
OUT_DIR=$(cat $self_dir/.outdir)
rm -f $self_dir/.outdir
fi
else
OUT_DIR=$4
fi
if [ ! -d "$OUT_DIR" ]; then
mkdir -p "$OUT_DIR"
fi
# 下载 PHP
echo "All done. Downloading PHP ..."
if [ -d "$self_dir/source/php-$VER_PHP" ]; then
rm -rf "$self_dir/source/php-$VER_PHP"
fi
$self_dir/download.sh php ${USE_BACKUP} ${VER_PHP} || { echo "Download PHP failed!" && exit 1 ; }
# 选择性编译依赖的库、移动需要安装的扩展到 PHP 目录
$self_dir/check-extensions.sh check_before_configure ${VER_PHP} || { echo "Install required library failed!" && exit 1 ; }
# 编译 PHP
echo "Compiling PHP ..."
php_dir=$(find $self_dir/source -name "php-$VER_PHP" -type d | tail -n1)
cd $php_dir && \
./buildconf --force && \
./configure LDFLAGS=-static $(php_compile_args $VER_PHP) && \
$self_dir/check-extensions.sh check_after_configure ${VER_PHP} && \
sed -ie 's/-export-dynamic//g' "Makefile" && \
sed -ie 's/-o $(SAPI_CLI_PATH)/-all-static -o $(SAPI_CLI_PATH)/g' "Makefile" && \
#sed -ie 's/$(PHP_GLOBAL_OBJS) $(PHP_BINARY_OBJS) $(PHP_MICRO_OBJS)/$(PHP_GLOBAL_OBJS:.lo=.o) $(PHP_BINARY_OBJS:.lo=.o) $(PHP_MICRO_OBJS:.lo=.o)/g' "Makefile" && \
make LDFLAGS="-ldl" -j$(cat /proc/cpuinfo | grep processor | wc -l) && \
make install-cli && \
$self_dir/check-extensions.sh finish_compile && \
strip $self_dir/php-dist/bin/php
if [ $? != 0 ]; then
exit 1
fi
# 将 PHP 和 micro 输出到指定目录
echo "Copying php binary to $OUT_DIR ..." && \
cp $self_dir/php-dist/bin/php $OUT_DIR/ && \
test -f $php_dir/sapi/micro/micro.sfx && \
echo "Copying micro.sfx binary to $OUT_DIR ..." && \
cp $php_dir/sapi/micro/micro.sfx $OUT_DIR/ || { exit 0 ; }

61
docker/config.json Executable file
View File

@@ -0,0 +1,61 @@
{
"php": {
"link": "http://mirrors.zhamao.xin/php/php-{version}.tar.gz",
"link_2": "https://www.php.net/distributions/php-{version}.tar.gz"
},
"protobuf": {
"version": "3.21.2",
"link": "http://mirrors.zhamao.xin/pecl/protobuf-{version}.tgz",
"link_2": "https://pecl.php.net/get/protobuf-{version}.tgz"
},
"swoole": {
"version": "4.8.10",
"link": "http://mirrors.zhamao.xin/pecl/swoole-{version}.tgz",
"link_2": "https://pecl.php.net/get/swoole-{version}.tgz"
},
"mongodb": {
"version": "1.13.0",
"link": "http://mirrors.zhamao.xin/pecl/mongodb-{version}.tgz",
"link_2": "https://pecl.php.net/get/mongodb-{version}.tgz"
},
"inotify": {
"version": "3.0.0",
"link": "http://mirrors.zhamao.xin/pecl/inotify-{version}.tgz",
"link_2": "https://pecl.php.net/get/inotify-{version}.tgz"
},
"event": {
"version": "3.0.8",
"link": "https://mirrors.zhamao.xin/library/php-event/event-{version}.tar.gz",
"link_2": "https://bitbucket.org/osmanov/pecl-event/get/{version}.tar.gz"
},
"redis": {
"version": "5.3.7",
"link": "http://mirrors.zhamao.xin/pecl/redis-{version}.tgz",
"link_2": "https://pecl.php.net/get/redis-{version}.tgz"
},
"libxml2": {
"version": "2.9.12",
"link": "http://mirrors.zhamao.xin/library/libxml2/libxml2-{version}.tar.gz",
"link_2": "http://xmlsoft.org/sources/libxml2-{version}.tar.gz"
},
"curl": {
"version": "7.83.1",
"link": "https://mirrors.zhamao.xin/library/curl/curl-{version}.tar.gz",
"link_2": "https://curl.haxx.se/download/curl-{version}.tar.gz"
},
"xz": {
"version": "5.2.5",
"link": "https://mirrors.zhamao.xin/library/xz/xz-{version}.tar.gz",
"link_2": "https://tukaani.org/xz/xz-{version}.tar.gz"
},
"libzip": {
"version": "1.9.2",
"link": "https://mirrors.zhamao.xin/library/libzip/libzip-{version}.tar.gz",
"link_2": "https://libzip.org/download/libzip-{version}.tar.gz"
},
"libiconv": {
"version": "1.17",
"link": "https://mirrors.zhamao.xin/library/libiconv/libiconv-{version}.tar.gz",
"link_2": "https://ftp.gnu.org/gnu/libiconv/libiconv-{version}.tar.gz"
}
}

View File

@@ -0,0 +1,32 @@
#!/bin/bash
if [ -n "$__MODULE_SH__" ]; then
return
fi
__MODULE_SH__='gmp.sh'
set -exu
__DIR__=$(
cd "$(dirname "$0")"
pwd
)
cd ${__DIR__}
# cpu 核数 前面为linux 后面为macos
cpu_nums=`nproc 2> /dev/null || sysctl -n hw.ncpu`
# cpu_nums=`grep "processor" /proc/cpuinfo | sort -u | wc -l`
function do_gmp_compiler() {
pwd
mkdir -p /app/source/builder_dir/gmp
tar --strip-components=1 -C ${__DIR__}/source/builder_dir/gmp -xf ${__DIR__}/source/libraries/gmp-6.2.1.tar.lz
cd ${__DIR__}/source/builder_dir/gmp
./configure --prefix=/usr/gmp --enable-static --disable-shared
make -j $cpu_nums
echo "gmp compiled!" && \
make install && \
echo "gmp compiled!"
return $?
}
do_gmp_compiler

View File

@@ -0,0 +1,35 @@
#!/bin/bash
if [ -n "$__MODULE_SH__" ]; then
return
fi
__MODULE_SH__='libmcrypt.sh'
set -exu
__DIR__=$(
cd "$(dirname "$0")"
pwd
)
cd ${__DIR__}
# cpu 核数 前面为linux 后面为macos
cpu_nums=`nproc 2> /dev/null || sysctl -n hw.ncpu`
# cpu_nums=`grep "processor" /proc/cpuinfo | sort -u | wc -l`
function do_libmcrypt_compiler() {
pwd
mkdir -p /app/source/builder_dir/libmcrypt
tar --strip-components=1 -C ${__DIR__}/source/builder_dir/libmcrypt -xf ${__DIR__}/source/libraries/libmcrypt-2.5.8-3.4.tar.gz
cd ${__DIR__}/source/builder_dir/libmcrypt
chmod a+x ./install-sh
sh ./configure --prefix=/usr/libmcrypt \
--enable-static=yes \
--enable-shared=no
make -j $cpu_nums
echo "libmcrypt compiled!" && \
make install && \
echo "libmcrypt compiled!"
return $?
}
do_libmcrypt_compiler

View File

@@ -0,0 +1,34 @@
#!/bin/bash
set -exu
__DIR__=$(
cd "$(dirname "$0")"
pwd
)
cd ${__DIR__}
# https://aria2.github.io/manual/en/html/aria2c.html#http-ftp-segmented-downloads
# https://aria2.github.io/manual/en/html/aria2c.html
# -with-config-file-path=/usr/local/php/etc
# -U, --user-agent
# aria2c -h
# aria2c --conf-path=/etc/aria2/aria2.conf
:<<EOF
-c, --continue [true|false]
-s, --split=<N>
-x, --max-connection-per-server=<NUM>
-k, --min-split-size=<SIZE>
-j, --max-concurrent-downloads=<N>
-i, --input-file=<FILE>
EOF
user_agent='Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/109.0.0.0 Safari/537.36'
test -f download_extension_urls.txt && aria2c -c -j 10 -s 10 -x 8 -k 10M --allow-overwrite=true --max-tries=30 --retry-wait=15 --user-agent=$user_agent \
-d extensions --input-file=download_extension_urls.txt
mkdir -p source/extensions
awk 'BEGIN { cmd="cp -ri extensions/* source/extensions/" ; print "n" |cmd; }'

20
docker/download-git.sh Executable file
View File

@@ -0,0 +1,20 @@
#!/usr/bin/env bash
self_dir=$(cd "$(dirname "$0")";pwd)
test -d "$self_dir/source/cache/" || mkdir -p "$self_dir/source/cache"
test "$3" != "yes" && GITHUB_ADDR="https://gh.api.99988866.xyz/" || GITHUB_ADDR=""
if [ -d "$self_dir/source/cache/$2" ]; then
echo "Using cache for $2"
cp -r "$self_dir/source/cache/$2" "$self_dir/source/"
else
wget -O $self_dir/source/master.zip "$GITHUB_ADDR""https://github.com/$1/archive/master.zip" && \
cd $self_dir/source/ && \
unzip master.zip && \
mv $2-master/ cache/$2 && \
cp -r cache/$2 ./
fi
# git clone https://$GITHUB_ADDR/$1.git --depth=1 $self_dir/source/$2

View File

@@ -0,0 +1,34 @@
#!/bin/bash
set -exu
__DIR__=$(
cd "$(dirname "$0")"
pwd
)
cd ${__DIR__}
# https://aria2.github.io/manual/en/html/aria2c.html#http-ftp-segmented-downloads
# https://aria2.github.io/manual/en/html/aria2c.html
# -with-config-file-path=/usr/local/php/etc
# -U, --user-agent
# aria2c -h
# aria2c --conf-path=/etc/aria2/aria2.conf
:<<EOF
-c, --continue [true|false]
-s, --split=<N>
-x, --max-connection-per-server=<NUM>
-k, --min-split-size=<SIZE>
-j, --max-concurrent-downloads=<N>
-i, --input-file=<FILE>
EOF
user_agent='Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/109.0.0.0 Safari/537.36'
test -f download_library_urls.txt && aria2c -c -j 10 -s 10 -x 8 -k 10M --allow-overwrite=true --max-tries=30 --retry-wait=15 --user-agent=$user_agent \
-d libraries --input-file=download_library_urls.txt
mkdir -p source/libraries
awk 'BEGIN { cmd="cp -ri libraries/* source/libraries/" ; print "n" |cmd; }'

60
docker/download.sh Executable file
View File

@@ -0,0 +1,60 @@
#!/bin/sh
_use_backup="$2"
SELF_DIR=$(cd "$(dirname "$0")";pwd)
if [ ! -d "source" ]; then
mkdir source
fi
if [ ! -d "source/cache" ]; then
mkdir source/cache
fi
function readconf() {
cat $SELF_DIR/config.json | jq $@ | sed 's/\"//g'
}
cd source
if [ "$_use_backup" = "yes" ]; then
_use_backup="_2"
else
_use_backup=""
fi
archive_find_tar=$(find cache/ -name "$1.*" | grep -E ".tgz" | tail -n1)
archive_find_zip=$(find cache/ -name "$1.*" | grep -E ".zip" | tail -n1)
if [ "$archive_find_tar" != "" ]; then
echo "Using cache for $1 ($archive_find_tar)"
tar -zxf "$archive_find_tar"
elif [ "$archive_find_zip" != "" ]; then
echo "Using cache for $1 ($archive_find_zip)"
unzip $archive_find_zip -d "$SELF_DIR/source" > /dev/null
else
if [ "$3" != "" ]; then
wget -q "$(readconf ".$1.link$_use_backup" | sed 's/{version}/'$3'/g')"
else
echo "Downloading $1"
wget -q "$(readconf ".$1.link$_use_backup" | sed 's/{version}/'$(readconf ".$1.version")'/g')"
fi
if [ $? == 0 ]; then
archive_file_tar=$(find . -name "*.*" -maxdepth 1 | grep -E ".tar|.gz|.tgz" | tail -n1)
archive_file_zip=$(find . -name "*.zip" -maxdepth 1 | tail -n1)
if [ "$archive_file_tar" != "" ]; then
tar -zxf $archive_file_tar && mv $archive_file_tar $SELF_DIR/source/cache/$1.tgz
elif [ "$archive_file_zip" != "" ]; then
unzip $archive_file_zip && mv $archive_file_zip $SELF_DIR/source/cache/$1.zip > /dev/null
else
find . -name "*$1*.*"
echo "Unable to find downloaded file, only support '.tar.gz', '.tgz', '.zip' file!"
exit 1
fi
else
echo "Download $1 failed! (at $?)"
exit 1
fi
fi

View File

@@ -0,0 +1,22 @@
https://pecl.php.net/get/redis-5.3.7.tgz
out=redis-5.3.7.tgz
https://pecl.php.net/get/yaml-2.2.2.tgz
out=yaml-2.2.2.tgz
https://pecl.php.net/get/imagick-3.6.0.tgz
out=imagick-3.6.0.tgz
https://pecl.php.net/get/mongodb-1.14.2.tgz
out=mongodb-1.14.2.tgz
https://pecl.php.net/get/apcu-5.1.22.tgz
out=apcu-5.1.22.tgz
https://pecl.php.net/get/ds-1.4.0.tgz
out=ds-1.4.0.tgz
https://pecl.php.net/get/inotify-3.0.0.tgz
out=inotify-3.0.0.tgz
https://pecl.php.net/get/xlswriter-1.5.2.tgz
out=xlswriter-1.5.2.tgz
https://pecl.php.net/get/zstd-0.12.1.tgz
out=zstd-0.12.1.tgz
https://pecl.php.net/get/event-3.0.8.tgz
out=event-3.0.8.tgz
https://pecl.php.net/get/mcrypt-1.0.5.tgz
out=mcrypt-1.0.5.tgz

View File

@@ -0,0 +1,4 @@
https://pecl.php.net/get/mcrypt-1.0.5.tgz
out=mcrypt-1.0.5.tgz
https://pecl.php.net/get/apcu-5.1.22.tgz
out=apcu-5.1.22.tgz

View File

@@ -0,0 +1,72 @@
https://www.openssl.org/source/openssl-1.1.1p.tar.gz
out=openssl-1.1.1p.tar.gz
https://ftp.gnu.org/pub/gnu/libiconv/libiconv-1.16.tar.gz
out=libiconv-1.16.tar.gz
https://gitlab.gnome.org/GNOME/libxml2/-/archive/v2.9.10/libxml2-v2.9.10.tar.gz
out=libxml2-v2.9.10.tar.gz
https://gitlab.gnome.org/GNOME/libxslt/-/archive/v1.1.34/libxslt-v1.1.34.tar.gz
out=libxslt-v1.1.34.tar.gz
https://github.com/google/brotli/archive/refs/tags/v1.0.9.tar.gz
out=brotli-1.0.9.tar.gz
https://c-ares.org/download/c-ares-1.19.0.tar.gz
out=c-ares-1.19.0.tar.gz
https://gmplib.org/download/gmp/gmp-6.2.1.tar.lz
out=gmp-6.2.1.tar.lz
https://mirrors.tuna.tsinghua.edu.cn/gnu/ncurses/ncurses-6.3.tar.gz https://mirrors.ustc.edu.cn/gnu/ncurses/ncurses-6.3.tar.gz https://ftp.gnu.org/pub/gnu/ncurses/ncurses-6.3.tar.gz
out=ncurses-6.3.tar.gz
https://mirrors.tuna.tsinghua.edu.cn/gnu/readline/readline-8.2.tar.gz https://mirrors.ustc.edu.cn/gnu/readline/readline-8.2.tar.gz https://ftp.gnu.org/gnu/readline/readline-8.2.tar.gz
out=readline-8.2.tar.gz
https://pyyaml.org/download/libyaml/yaml-0.2.5.tar.gz
out=yaml-0.2.5.tar.gz
https://download.libsodium.org/libsodium/releases/libsodium-1.0.18.tar.gz
out=libsodium-1.0.18.tar.gz
https://sourceware.org/pub/bzip2/bzip2-1.0.8.tar.gz
out=bzip2-1.0.8.tar.gz
https://udomain.dl.sourceforge.net/project/libpng/zlib/1.2.11/zlib-1.2.11.tar.gz
out=zlib-1.2.11.tar.gz
https://github.com/lz4/lz4/archive/refs/tags/v1.9.4.tar.gz
out=lz4-v1.9.4.tar.gz
https://github.com/tukaani-project/xz/releases/download/v5.4.1/xz-5.4.1.tar.gz
out=xz-5.4.1.tar.gz
https://github.com/facebook/zstd/releases/download/v1.5.2/zstd-1.5.2.tar.gz
out=zstd-1.5.2.tar.gz
https://libzip.org/download/libzip-1.9.2.tar.gz
out=libzip-1.9.2.tar.gz
https://www.sqlite.org/2021/sqlite-autoconf-3370000.tar.gz
out=sqlite-autoconf-3370000.tar.gz
https://github.com/unicode-org/icu/releases/download/release-60-3/icu4c-60_3-src.tgz
out=icu4c-60_3-src.tgz
https://codeload.github.com/kkos/oniguruma/tar.gz/refs/tags/v6.9.7
out=oniguruma-6.9.7.tar.gz
https://github.com/microsoft/mimalloc/archive/refs/tags/v2.0.7.tar.gz
out=mimalloc-2.0.7.tar.gz
https://codeload.github.com/libjpeg-turbo/libjpeg-turbo/tar.gz/refs/tags/2.1.2
out=libjpeg-turbo-2.1.2.tar.gz
https://nchc.dl.sourceforge.net/project/giflib/giflib-5.2.1.tar.gz
out=giflib-5.2.1.tar.gz
https://nchc.dl.sourceforge.net/project/libpng/libpng16/1.6.37/libpng-1.6.37.tar.gz
out=libpng-1.6.37.tar.gz
https://codeload.github.com/webmproject/libwebp/tar.gz/refs/tags/v1.2.1
out=libwebp-1.2.1.tar.gz
https://download.savannah.gnu.org/releases/freetype/freetype-2.10.4.tar.gz
out=freetype-2.10.4.tar.gz
https://github.com/ImageMagick/ImageMagick/archive/refs/tags/7.1.0-62.tar.gz
out=ImageMagick-v7.1.0-62.tar.gz
https://ftp.gnu.org/gnu/libidn/libidn2-2.3.4.tar.gz
out=libidn2-2.3.4.tar.gz
https://curl.se/download/curl-7.88.0.tar.gz
out=curl-7.88.0.tar.gz
https://ftp.postgresql.org/pub/source/v15.1/postgresql-15.1.tar.gz
out=postgresql-15.1.tar.gz
https://github.com/libffi/libffi/releases/download/v3.4.4/libffi-3.4.4.tar.gz
out=libffi-3.4.4.tar.gz
https://github.com/winlibs/libmcrypt/archive/refs/tags/libmcrypt-2.5.8-3.4.tar.gz
out=libmcrypt-2.5.8-3.4.tar.gz
https://github.com/jmcnamara/libxlsxwriter/archive/refs/tags/RELEASE_1.1.5.tar.gz
out=libxlsxwriter-1.1.5.tar.gz
https://github.com/libevent/libevent/releases/download/release-2.1.12-stable/libevent-2.1.12-stable.tar.gz
out=libevent-2.1.12-stable.tar.gz
https://github.com/libuv/libuv/archive/refs/tags/v1.44.2.tar.gz
out=libuv-v1.44.2.tar.gz
https://github.com/php/php-src/archive/refs/tags/php-8.1.12.tar.gz
out=php-8.1.12.tar.gz

View File

@@ -0,0 +1,4 @@
https://github.com/winlibs/libmcrypt/archive/refs/tags/libmcrypt-2.5.8-3.4.tar.gz
out=libmcrypt-2.5.8-3.4.tar.gz
https://gmplib.org/download/gmp/gmp-6.2.1.tar.lz
out=gmp-6.2.1.tar.lz

44
docker/extensions.txt Executable file
View File

@@ -0,0 +1,44 @@
# Start with '#' is comments
# Start with '^' is deselecting extensions, which is not installed as default
# Each line just leave the extension name or ^ character
bcmath
calendar
ctype
curl
dom
event
exif
fileinfo
filter
gd
hash
iconv
inotify
json
libxml
mbstring
mongodb
mysqlnd
openssl
pcntl
pdo
pdo_mysql
pdo_sqlite
phar
posix
^protobuf
^readline
redis
shmop
simplexml
soap
sockets
sqlite3
swoole
tokenizer
xml
xmlreader
xmlwriter
zlib
zip

63
docker/fast-compiler.sh Executable file
View File

@@ -0,0 +1,63 @@
#!/bin/sh
# This script needs alpine linux system.
self_dir=$(cd "$(dirname "$0")";pwd)
test "$VER_PHP" = "" && VER_PHP="8.1.7"
test "$USE_BACKUP" = "" && USE_BACKUP="no"
test "$ALL_EXTENSIONS" = "" && ALL_EXTENSIONS="all"
LINK_APK_REPO='mirrors.ustc.edu.cn'
LINK_APK_REPO_BAK='dl-cdn.alpinelinux.org'
if [ "${USE_BACKUP}" = "yes" ]; then \
echo "Using backup address..." && sleep 1s
LINK_APK_REPO=${LINK_APK_REPO_BAK}
else
echo "Using original address..." && sleep 1s
fi
sed -i 's/dl-cdn.alpinelinux.org/'${LINK_APK_REPO}'/g' /etc/apk/repositories
# build requirements
apk add bash file wget cmake gcc g++ jq autoconf git libstdc++ linux-headers make m4 libgcc binutils ncurses dialog
# php zlib dependencies
apk add zlib-dev zlib-static
# php mbstring dependencies
apk add oniguruma-dev
# php openssl dependencies
apk add openssl-libs-static openssl-dev openssl
# php gd dependencies
apk add libpng-dev libpng-static
# curl c-ares dependencies
apk add c-ares-static c-ares-dev
# php event dependencies
apk add libevent libevent-dev libevent-static
# php sqlite3 dependencies
apk add sqlite sqlite-dev sqlite-libs sqlite-static
# php libzip dependencies
apk add bzip2-dev bzip2-static bzip2
# php micro ffi dependencies
apk add libffi libffi-dev
# php gd event parent dependencies
apk add zstd-static
# php readline dependencies
apk add readline-static ncurses-static readline-dev
test "$USE_BACKUP" = "no" && PROMPT_1="mirror" || PROMPT_1="original"
$self_dir/download.sh swoole ${USE_BACKUP} && \
$self_dir/download.sh inotify ${USE_BACKUP} && \
$self_dir/download.sh mongodb ${USE_BACKUP} && \
$self_dir/download.sh event ${USE_BACKUP} && \
$self_dir/download.sh redis ${USE_BACKUP} && \
$self_dir/download.sh libxml2 ${USE_BACKUP} && \
$self_dir/download.sh xz ${USE_BACKUP} && \
$self_dir/download.sh protobuf ${USE_BACKUP} && \
$self_dir/download.sh curl ${USE_BACKUP} && \
$self_dir/download.sh libzip ${USE_BACKUP} && \
$self_dir/download.sh libiconv ${USE_BACKUP} && \
$self_dir/download-git.sh dixyes/phpmicro phpmicro ${USE_BACKUP} && \
$self_dir/compile-deps.sh && \
$self_dir/compile-php.sh $PROMPT_1 $VER_PHP $ALL_EXTENSIONS /dist/

69
install-runtime.sh Normal file
View File

@@ -0,0 +1,69 @@
#!/usr/bin/env bash
function download_file() {
downloader="wget"
type wget >/dev/null 2>&1 || { downloader="curl"; }
if [ "$downloader" = "wget" ]; then
_down_prefix="O"
else
_down_prefix="o"
fi
_down_symbol=0
if [ ! -f "$2" ]; then
echo $1
$downloader "$1" -$_down_prefix "$2" >/dev/null 2>&1 && \
echo "完成!" && _down_symbol=1
else
echo "已存在!" && _down_symbol=1
fi
if [ $_down_symbol == 0 ]; then
echo "失败!请检查网络连接!"
rm -rf "$2"
return 1
fi
return 0
}
function test_composer_and_php() {
succ=$("$(pwd)/runtime/composer" -n about | grep Manage)
if [ "$succ" = "" ]; then
echo "Download PHP binary and composer failed!"
return 1
fi
return 0
}
if [ "$(uname -s)" != "Linux" ]; then
echo "Only support Linux!!!"
exit 1
fi
ZM_PHP_VERSION="7.4"
if [ "$ZM_DOWN_PHP_VERSION" != "" ]; then
ZM_PHP_VERSION="$ZM_DOWN_PHP_VERSION"
echo "Using custom PHP version: $ZM_PHP_VERSION"
fi
mkdir "$(pwd)/runtime" >/dev/null 2>&1
if [ ! -f "$(pwd)/runtime/php" ]; then
download_file "https://dl.zhamao.xin/php-bin/down.php?php_ver=$ZM_PHP_VERSION&arch=$(uname -m)" "$(pwd)/runtime/php.tar.gz"
if [ $? -ne 0 ]; then
exit 1
fi
tar -xf "$(pwd)/runtime/php.tar.gz" -C "$(pwd)/runtime/"
fi
if [ ! -f "$(pwd)/runtime/composer" ]; then
download_file "https://mirrors.aliyun.com/composer/composer.phar" "$(pwd)/runtime/composer.phar"
if [ $? -ne 0 ]; then
exit 1
fi
echo '$(dirname $0)/php $(dirname $0)/composer.phar $@' > $(pwd)/runtime/composer
chmod +x $(pwd)/runtime/composer
test_composer_and_php
fi
if [ $? -ne 0 ]; then
exit 1
fi
echo "成功下载!" && \
echo -e "PHP使用\truntime/php -v" && \
echo -e "Composer使用\truntime/composer"

View File

@@ -1,23 +0,0 @@
#!/bin/sh
_main_dir="$(pwd)/"
_build_dir="$_main_dir/build"
mkdir "$_build_dir" > /dev/null 2>&1
for loop in "7.4.16" "8.0.3"
do
sed -i 's/_php_ver=.*/_php_ver="'$loop'"/g' "$_main_dir""static-compile-php.sh" && \
rm -rf "$_main_dir""source/php.tar.gz" "$_main_dir""source/php-*" "$_main_dir""php-dist" && \
"$_main_dir""static-compile-php.sh" && \
cp "$_main_dir""php-dist/bin/php" "$_build_dir/" && \
cd "$_build_dir/" && \
tar -zcvf "php-$loop-static-bin-"$(uname -m)".tar.gz" "./php" && \
mv "./php" "./php-$loop" && \
cd "$_main_dir"
if [ $? -ne 0 ]; then
echo "Compile static php-$loop failed!"
exit 1
fi
done

View File

@@ -1,245 +0,0 @@
#!/bin/bash
function downloadIt() {
downloader="wget"
type wget >/dev/null 2>&1 || { downloader="curl"; }
if [ "$downloader" = "wget" ]; then
_down_prefix="O"
else
_down_prefix="o"
fi
_down_symbol=0
if [ ! -f "$2" ]; then
$downloader "$1" -$_down_prefix "$2" >/dev/null 2>&1 && \
echo "$1 完成!" && _down_symbol=1
else
echo "$1 已存在!" && _down_symbol=1
fi
if [ $_down_symbol == 0 ]; then
echo "失败!请检查网络连接!"
rm -rf "$2"
return 1
fi
return 0
}
_script_ver="1.1.1"
_php_ver="7.4.16"
_swoole_ver="4.6.6"
_redis_ver="5.3.4"
_libxml2_ver="2.9.10"
_curl_ver="7.76.1"
# 默认编译在脚本当前目录
_home_dir=$(pwd)"/"
# PHP使用国内的搜狐镜像
_php_down_link="http://mirrors.sohu.com/php/php-$_php_ver.tar.gz"
# swoole使用自建的炸毛服务器的分发因为pecl有时候在国内奇慢
_swoole_down_link="https://dl.zhamao.me/swoole/swoole-$_swoole_ver.tgz"
_swoole_down_link_bak="https://pecl.php.net/get/swoole-$_swoole_ver.tgz"
# phpredis也使用自建的炸毛服务器分发
_redis_down_link="https://dl.zhamao.me/phpredis/redis-$_redis_ver.tgz"
_redis_down_link_bak="https://pecl.php.net/get/redis-$_redis_ver.tgz"
# libxml2也使用自建的服务器
_libxml2_down_link="https://dl.zhamao.me/libxml2/libxml2-$_libxml2_ver.tar.gz"
_libxml2_down_link_bak="http://xmlsoft.org/sources/libxml2-$_libxml2_ver.tar.gz"
# liblzma是自建的服务器如果需要找原始位置在GitHub搜索liblzma即可
_liblzma_down_link="https://dl.zhamao.me/liblzma/liblzma.tar.gz"
# curl/libcurl使用自建的服务器bak是源地址
_curl_down_link="https://dl.zhamao.me/curl/curl-$_curl_ver.tar.gz"
_curl_down_link_bak="https://curl.haxx.se/download/curl-$_curl_ver.tar.gz"
_curl_override_1='
AC_DEFUN([PHP_CHECK_LIBRARY], [
$3
])
'
_curl_override_2='
AC_DEFUN([PHP_CHECK_LIBRARY], [
save_old_LDFLAGS=$LDFLAGS
ac_stuff="$5"
save_ext_shared=$ext_shared
ext_shared=yes
PHP_EVAL_LIBLINE([$]ac_stuff, LDFLAGS)
AC_CHECK_LIB([$1],[$2],[
LDFLAGS=$save_old_LDFLAGS
ext_shared=$save_ext_shared
$3
],[
LDFLAGS=$save_old_LDFLAGS
ext_shared=$save_ext_shared
unset ac_cv_lib_$1[]_$2
$4
])dnl
])
'
function downloadAll() {
mkdir "$_home_dir""source" > /dev/null 2>&1
echo "正在下载 php 源码 "$_php_down_link" ..."
downloadIt $_php_down_link "$_home_dir""source/php.tar.gz" || { exit 1; } &
#echo "正在下载 openssl 源码 "$_openssl_down_link" ..."
#downloadIt $_openssl_down_link "$_home_dir""source/openssl.tar.gz" || { exit; } &
echo "正在下载 swoole 源码 "$_swoole_down_link" ..."
downloadIt $_swoole_down_link "$_home_dir""source/swoole.tar.gz" || { exit 1; } &
echo "正在下载 redis 源码 "$_redis_down_link" ..."
downloadIt $_redis_down_link "$_home_dir""source/redis.tar.gz" || { exit 1; } &
echo "正在下载 libxml2 源码 ..."
downloadIt $_libxml2_down_link "$_home_dir""source/libxml2.tar.gz" || { exit 1; } &
echo "正在下载 liblzma 源码 ..."
downloadIt $_liblzma_down_link "$_home_dir""source/liblzma.tar.gz" || { exit 1; } &
echo "正在下载 curl 源码 ..."
downloadIt $_curl_down_link "$_home_dir""source/curl.tar.gz" || { exit 1; } &
wait
}
function compileLiblzma() {
if [ -f "$_home_dir""opt/liblzma/lib/liblzma.so" ]; then
echo "已编译 liblzma" && return
fi
tar -xf "$_home_dir""source/liblzma.tar.gz" -C "$_home_dir""source/" && \
cd "$_home_dir""source/liblzma" && \
./configure --prefix="$_home_dir""opt/liblzma" && \
make -j4 && \
make install && \
echo "编译 liblzma 完成!"
}
function compileCurl() {
if [ -f "$_home_dir""opt/curl/bin/curl" ]; then
echo "已编译 curl" && return
fi
tar -xf "$_home_dir""source/curl.tar.gz" -C "$_home_dir""source/" && \
cd "$_home_dir""source/curl-""$_curl_ver" && \
CC=gcc CXX=g++ CFLAGS=-fPIC CPPFLAGS=-fPIC ./configure --prefix="$_home_dir""opt/curl" \
--without-nghttp2 \
--with-ssl=/usr \
--with-pic=pic \
--enable-ipv6 \
--enable-shared=no \
--without-libidn2 \
--disable-ldap \
--without-libpsl \
--without-lber \
--enable-ares && \
make -j4 && \
make install && \
echo "编译 curl 完成!"
}
function compileLibxml2() {
if [ -f "$_home_dir""opt/libxml2/lib/libxml2.so" ]; then
echo "已编译 libxml2" && return
fi
tar -xf "$_home_dir""source/libxml2.tar.gz" -C "$_home_dir""source/" && \
cd "$_home_dir""source/libxml2-""$_libxml2_ver" && \
./configure --with-lzma="$_home_dir""opt/liblzma" --prefix="$_home_dir""opt/libxml2" --exec-prefix="$_home_dir""opt/libxml2" --without-python && \
make -j4 && \
make install && \
echo "编译 libxml2 完成!"
}
function compilePHPWithSwoole() {
echo "正在编译 php ..." && \
rm -rf "$_home_dir""source/php-""$_php_ver" && \
tar -xf "$_home_dir""source/php.tar.gz" -C "$_home_dir""source/" && \
#git clone --depth=1 https://fgit.zhamao.me/swoole/swoole-src.git "$_home_dir""source/"swoole-$_swoole_ver && \
tar -xf "$_home_dir""source/swoole.tar.gz" -C "$_home_dir""source/" && \
mv "$_home_dir""source/swoole-""$_swoole_ver" "$_home_dir""source/php-""$_php_ver/ext/swoole" && \
"$_home_dir""source/php-""$_php_ver/ext/swoole/clear.sh" && \
tar -xf "$_home_dir""source/redis.tar.gz" -C "$_home_dir""source/" && \
mv "$_home_dir""source/redis-""$_redis_ver" "$_home_dir""source/php-""$_php_ver/ext/redis" && \
cd "$_home_dir""source/php-""$_php_ver/" && \
echo "$_curl_override_1" > "$_home_dir""ac_override_1" && \
echo "$_curl_override_2" > "$_home_dir""ac_override_2" && \
cat "$_home_dir""ac_override_1" "$_home_dir""source/php-""$_php_ver/ext/curl/config.m4" "$_home_dir""ac_override_2" > /tmp/aa && \
mv /tmp/aa "$_home_dir""source/php-""$_php_ver/ext/curl/config.m4" && \
./buildconf --force && \
PKG_CONFIG_PATH="$PKG_CONFIG_PATH:""$_home_dir""opt/libxml2/lib/pkgconfig" && \
PKG_CONFIG_PATH="$PKG_CONFIG_PATH:""$_home_dir""opt/curl/lib/pkgconfig" ./configure LDFLAGS=-static \
--prefix="$_home_dir""php-dist" \
--disable-all \
--enable-shared=no \
--enable-static=yes \
--enable-inline-optimization \
--with-layout=GNU \
--enable-calendar \
--enable-ctype \
--enable-filter \
--enable-openssl \
--enable-bcmath \
--with-openssl-dir="/usr" \
--enable-pcntl \
--enable-openssl \
--with-openssl \
--with-iconv \
--enable-json \
--enable-mbstring \
--enable-phar \
--enable-pdo \
--with-pdo-mysql=mysqlnd \
--enable-sockets \
--enable-swoole \
--enable-gd \
--enable-redis \
--disable-redis-session \
--enable-simplexml \
--enable-dom \
--with-libxml="$_home_dir""opt/libxml2" \
--enable-xml \
--enable-xmlwriter \
--enable-xmlreader \
--with-zlib \
--enable-posix \
--enable-mysqlnd \
--enable-tokenizer \
--with-curl="$_home_dir""opt/curl" \
--with-pear=no \
--disable-pear \
--disable-cgi \
--disable-phpdbg && \
sed -ie 's/-export-dynamic//g' "$_home_dir""source/php-""$_php_ver/Makefile" && \
sed -ie 's/-o $(SAPI_CLI_PATH)/-all-static -o $(SAPI_CLI_PATH)/g' "$_home_dir""source/php-""$_php_ver/Makefile" && \
sed -ie 's/swoole_clock_gettime(CLOCK_REALTIME/clock_gettime(CLOCK_REALTIME/g' "$_home_dir""source/php-""$_php_ver/ext/swoole/include/swoole.h" && \
make LDFLAGS=-ldl -j4 && \
make install && \
strip "$_home_dir""php-dist/bin/php"
}
#apk add g++ pkgconf autoconf nghttp2 libcurl \
# git gcc zlib-dev libstdc++ ncurses zlib linux-headers \
# readline make libssl1.1 libxml2 m4 libgcc vim binutils \
# oniguruma-dev openssl openssl-dev
# 编译必需的
apk add gcc g++ autoconf libstdc++ linux-headers make m4 libgcc binutils ncurses
# php的zlib支持
apk add zlib-dev zlib-static
# php的mbstring支持
apk add oniguruma-dev
# php的openssl支持
apk add openssl-libs-static openssl-dev openssl
# php的gd支持如果不需要gd则去掉--enable-gd和下面的依赖
apk add libpng-dev libpng-static
# curl的c-ares支持如果不需要curl则去掉
apk add c-ares-static c-ares-dev
downloadAll && \
compileLiblzma && \
compileLibxml2 && \
compileCurl && \
compilePHPWithSwoole && \
echo "完成!见 php-dist/bin/php"