mirror of
https://github.com/crazywhalecc/static-php-cli.git
synced 2026-03-18 04:44:53 +08:00
Update README
This commit is contained in:
parent
6fab3e789d
commit
dc5bac99b0
31
README-en.md
31
README-en.md
@ -3,7 +3,7 @@ Compile A Statically Linked PHP With Swoole and other Extensions.
|
||||
|
||||
BTW, It's only for CLI mode.
|
||||
|
||||
[]()
|
||||
[]()
|
||||

|
||||
|
||||
## Compilation Requirements
|
||||
@ -55,18 +55,21 @@ 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 --build-arg COMPILE_PHP_VERSION=7.4.29
|
||||
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:
|
||||
After compilation you can use command to get static php binary file.
|
||||
|
||||
```bash
|
||||
mkdir dist
|
||||
docker run --rm -v $(pwd)/dist:/dist/ -it static-php cp php-dist/bin/php /dist/
|
||||
cd dist
|
||||
file ./php
|
||||
```
|
||||
|
||||
If you don't want to use docker, a single script for compiling:
|
||||
If you don't want to use docker, a single script for compiling in **Alpine Linux**:
|
||||
|
||||
```bash
|
||||
cd docker
|
||||
@ -126,8 +129,18 @@ To customize PHP extensions, edit `docker/extensions.txt` file, and rules below:
|
||||
| yes | zlib | * | |
|
||||
|
||||
## Customization
|
||||
- `docker/Dockerfile` edit `VER_PHP=x.x.x` to switch PHP version.
|
||||
- `docker/Dockerfile` edit `USE_BACKUP=yes` to use backup download address (download faster if you are not in mainland China).
|
||||
- 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.
|
||||
@ -139,7 +152,7 @@ To customize PHP extensions, edit `docker/extensions.txt` file, and rules below:
|
||||
- [ ] Not support readline, maybe caused by ncurses library.
|
||||
- [X] Not support curl (solved)
|
||||
- [X] Customize extensions to compile
|
||||
- [ ] php.ini integration
|
||||
- [X] php.ini integration
|
||||
- [X] i18n (including README and scripts)
|
||||
|
||||
## Running preview
|
||||
|
||||
33
README.md
33
README.md
@ -7,7 +7,7 @@ Compile A Statically Linked PHP With Swoole and other Extensions. [English READM
|
||||
|
||||
注:只能编译 CLI 模式,暂不支持 CGI 和 FPM 模式
|
||||
|
||||
[]()
|
||||
[]()
|
||||
[]()
|
||||

|
||||
|
||||
@ -61,16 +61,20 @@ cat micro.sfx code.php > single-app && chmod +x single-app
|
||||
```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=no --build-arg COMPILE_PHP_VERSION=7.4.28
|
||||
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
|
||||
mkdir dist
|
||||
docker run --rm -v $(pwd)/dist:/dist/ -it static-php cp php-dist/bin/php /dist/
|
||||
cd dist
|
||||
file ./php
|
||||
# 如果是 PHP 8.0 以上,同时会输出 micro 构建版本
|
||||
file ./micro.sfx
|
||||
```
|
||||
|
||||
如果你不想使用 Docker,想从Alpine环境直接编译,可以使用预置相同编译配置的脚本 `fast-compiler.sh`:
|
||||
@ -131,14 +135,24 @@ export VER_PHP="8.1.7"
|
||||
| yes, enabled | zlib | * | |
|
||||
|
||||
## 自定义
|
||||
- `docker/Dockerfile` 中修改 `VER_PHP=x.x.x` 来更换 PHP 版本。
|
||||
- `docker/Dockerfile` 中修改 `USE_BACKUP=yes` 使用备用下载源码地址(建议**不在中国大陆的用户**使用备用地址)。
|
||||
- 从 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/compile-php.sh` 中的 `php_compile_args` 函数来调整 PHP 编译参数。
|
||||
- `docker/check-extensions.sh` 中的 `check_in_configure` 函数可调整 PHP 扩展编译的参数 。
|
||||
- `docker/check-extensions.sh` 中的 `check_in_configure` 函数可调整 PHP 扩展编译的参数。
|
||||
- `docker/config.json` 可调整要下载的扩展和依赖库版本和链接。
|
||||
- `docker/fast-compiler.sh` 可以在 Alpine Linux 系统下直接运行。
|
||||
- `docker/multi-version-compiler.sh` 可以同时编译多个版本的 PHP。
|
||||
|
||||
## 目前的问题(对勾为已解决)
|
||||
- [X] 不支持 event(libevent) 扩展,event 扩展的 sockets 支持不能在静态编译中使用,因为静态内嵌编译暂时没办法调整扩展编译顺序,同时其本身也不支持静态编译。
|
||||
@ -146,9 +160,8 @@ export VER_PHP="8.1.7"
|
||||
- [ ] 不支持 readline 扩展,readline 扩展安装后无法正常使用 `php -a`,原因还没有弄清楚,可能是静态编译造成的 ncurses 库出现了问题。
|
||||
- [X] curl/libcurl 扩展静态编译
|
||||
- [X] 可自行选择不需要编译进入的扩展
|
||||
- [ ] php.ini 内嵌或分发
|
||||
- [X] php.ini 内嵌或分发
|
||||
- [X] i18n(国际化脚本本身和 README)
|
||||
- [ ] 在阿里云的部分阉割系统上可能缺少 openssl 配置,可能会导致 PHP 自身的 openssl 无法正常使用
|
||||
|
||||
如果你对以上问题有解决方案,请提出 Issue 或 PR!
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user