static-php-cli/README.md

78 lines
2.2 KiB
Markdown
Raw Normal View History

2021-05-07 10:06:00 +08:00
# static-php-cli
2021-05-06 14:44:16 +08:00
Compile A Statically Linked PHP With Swoole and other Extensions. [English README](/README-en.md)
2021-04-26 16:32:26 +08:00
编译纯静态的 PHP Binary 二进制文件带有各种扩展CLI 模式,暂不支持 CGI 和 FPM 模式)
2021-06-03 22:06:48 +08:00
[![版本](https://img.shields.io/badge/script--version-1.2.1-green.svg)]()
2021-04-28 00:03:14 +08:00
2021-04-26 16:32:26 +08:00
## 环境需求
2021-04-28 15:34:23 +08:00
- 目前在 x86_64 和 aarch64(arm64) 架构上编译成功,其他架构需自行测试
2021-06-03 22:06:48 +08:00
- 需要 Alpine Linux测试环境为 3.13 版本,其他版本未测试)系统(也就是说需要 musl或 DockerDockerfile 正在完善)
2021-04-26 16:32:26 +08:00
- WSL2 也是支持的
2021-06-03 22:06:48 +08:00
- 脚本支持编译的 PHP 版本7.2 ~ 8.0
2021-04-26 16:32:26 +08:00
## 开始
2021-04-28 01:27:52 +08:00
可以直接在旁边的 Release 中下载编译好的二进制,也可以自己编译。
2021-04-26 16:32:26 +08:00
```bash
2021-04-26 16:45:57 +08:00
# 自己编译
2021-04-26 16:32:26 +08:00
./static-compile-php.sh
2021-04-28 01:28:09 +08:00
# 完事后在 `php-dist/bin/php` 这个二进制文件可以随意拿着去任何一个 Linux 系统运行了!
2021-05-07 10:01:18 +08:00
# 多 PHP 版本一键编译
./multi-version-compile.sh
# 结束后多个 PHP 版本的二进制文件会在 build/ 目录下。
2021-04-28 01:27:52 +08:00
```
2021-04-26 16:32:26 +08:00
2021-05-06 14:43:12 +08:00
## 主分支版本
2021-05-06 14:44:36 +08:00
- php: 7.4.18
2021-05-06 14:43:12 +08:00
- libxml2: 2.9.10
- curl: 7.76.1
2021-06-03 22:06:48 +08:00
## 支持的扩展(对勾为已支持的扩展,未打勾的正在努力兼容)
- [X] bcmath
- [X] calendar
- [X] ctype
- [X] filter
- [X] openssl
- [X] pcntl
- [X] iconv
- [X] inotify
- [X] json
- [X] mbstring
- [X] phar
- [X] curl
- [X] pdo
- [X] gd
- [X] pdo_mysql
- [X] mysqlnd
- [X] sockets
- [X] swoole
- [X] redis
- [X] simplexml
- [X] dom
- [X] xml
- [X] xmlwriter
- [X] xmlreader
- [X] posix
- [X] tokenizer
- [ ] zip
2021-04-26 16:32:26 +08:00
## 运行示例
2021-04-26 16:35:36 +08:00
编译后的状态
2021-04-28 02:14:22 +08:00
![image](https://user-images.githubusercontent.com/20330940/116291663-6df47580-a7c7-11eb-8df3-6340c6f87055.png)
2021-04-26 16:35:36 +08:00
2021-04-26 16:32:26 +08:00
在不同系统直接运行 Swoft
![image](https://user-images.githubusercontent.com/20330940/116053161-f16d7400-a6ac-11eb-87b8-e510c6454861.png)
2021-04-26 20:12:30 +08:00
2021-04-28 00:01:42 +08:00
## Todo List
- [X] curl/libcurl 扩展静态编译
- [ ] 可自行选择不需要编译进入的扩展
- [ ] php.ini 内嵌或分发
- [ ] 尝试带进去个 composer其实自己下完全可以
2021-05-04 00:44:42 +08:00
- [ ] i18n国际化脚本本身和 README
2021-04-27 16:14:18 +08:00
## 参考资料
- <https://blog.terrywh.net/post/2019/php-static-openssl/>
- <https://stackoverflow.com/a/37245653>
- <http://blog.gaoyuan.xyz/2014/04/09/statically-compile-php/>