static-php-cli/README.md

71 lines
1.8 KiB
Markdown
Raw Normal View History

2021-04-26 16:15:06 +08:00
# static-php-swoole
Compile A Statically Linked PHP With Swoole and other Extensions
2021-04-26 16:32:26 +08:00
编译纯静态的 PHP Binary 二进制文件带有各种扩展CLI 模式,暂不支持 CGI 和 FPM 模式)
2021-04-28 15:34:23 +08:00
[![版本](https://img.shields.io/badge/version-1.1.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-04-26 16:32:26 +08:00
- 需要 Alpine Linux测试环境为 3.13 版本,其他版本未测试)系统(也就是说需要 musl
- WSL2 也是支持的
## 开始
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-04-28 01:27:52 +08:00
```
2021-04-26 16:32:26 +08:00
2021-05-06 14:43:12 +08:00
## 主分支版本
- php7.4.18
- libxml2: 2.9.10
- curl: 7.76.1
2021-04-26 16:32:26 +08:00
## 包含扩展
2021-04-28 01:27:52 +08:00
- bcmath
2021-04-26 16:32:26 +08:00
- calendar
- ctype
- filter
- openssl
- pcntl
- iconv
2021-05-06 14:43:12 +08:00
- inotify (3.0.0)
2021-04-26 16:32:26 +08:00
- json
- mbstring
- phar
2021-04-28 01:27:52 +08:00
- curl
2021-04-26 16:32:26 +08:00
- pdo
2021-04-26 16:33:58 +08:00
- gd
2021-04-26 16:32:26 +08:00
- pdo_mysql
- mysqlnd
- sockets
2021-05-06 14:43:12 +08:00
- swoole (4.6.6)
- redis (5.3.4)
2021-04-26 16:32:26 +08:00
- simplexml
- dom
- xml
- xmlwriter
- xmlreader
- posix
- tokenizer
## 运行示例
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/>