2021-06-06 11:42:21 +08:00
|
|
|
# static-php-cli
|
2021-06-06 11:41:55 +08:00
|
|
|
Compile A Statically Linked PHP With Swoole and other Extensions.
|
2021-05-07 09:33:06 +08:00
|
|
|
|
|
|
|
|
BTW, It's only for CLI mode.
|
|
|
|
|
|
2021-07-22 12:05:09 +00:00
|
|
|
[]()
|
2021-05-07 09:33:06 +08:00
|
|
|
|
2021-07-28 14:27:18 +08:00
|
|
|
## Compilation Requirements
|
2021-05-07 09:33:06 +08:00
|
|
|
- Tested on `x86_64` and `aarch64` platform, others have not tested.
|
2021-07-28 14:28:43 +08:00
|
|
|
- Docker required (or alpine linux 3.12+)
|
2021-06-06 11:41:55 +08:00
|
|
|
- Supporting PHP version from 7.2 to 8.0
|
2021-05-07 09:33:06 +08:00
|
|
|
|
2021-07-28 14:27:18 +08:00
|
|
|
## Running Requirements
|
|
|
|
|
Linux
|
|
|
|
|
|
2021-05-07 09:33:06 +08:00
|
|
|
## Start
|
|
|
|
|
You can directly download static binary in Release.
|
|
|
|
|
|
|
|
|
|
Here's help command to compile it yourself:
|
|
|
|
|
```bash
|
2021-06-06 11:41:55 +08:00
|
|
|
git clone https://github.com/crazywhalecc/static-php-cli.git
|
|
|
|
|
cd static-php-cli/docker
|
|
|
|
|
docker build -t static-php .
|
2021-05-07 09:33:06 +08:00
|
|
|
```
|
|
|
|
|
|
2021-06-06 11:41:55 +08:00
|
|
|
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
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
To customize PHP extensions, edit `docker/extensions.txt` file, and rules below:
|
|
|
|
|
- Use `#` as comment, to mark not install
|
|
|
|
|
- extensions name uses lower case, and default file contains all supported extensions, if u need other extensions, consider write an Issue
|
2021-05-07 09:33:06 +08:00
|
|
|
|
2021-06-06 11:41:55 +08:00
|
|
|
## Supported PHP extensions
|
2021-07-22 05:24:14 +00:00
|
|
|
| Support | PHP Ext Name | Version | Comments |
|
|
|
|
|
| ------- | ------------ | ------- | ---------------------------------------- |
|
|
|
|
|
| yes | bcmath | * | |
|
|
|
|
|
| yes | calendar | * | |
|
|
|
|
|
| yes | ctype | * | |
|
|
|
|
|
| yes | curl | * | |
|
|
|
|
|
| yes | dom | * | |
|
|
|
|
|
| | event | | |
|
|
|
|
|
| yes | filter | * | |
|
|
|
|
|
| yes | gd | * | |
|
2021-07-28 14:28:43 +08:00
|
|
|
| yes | hash | * | |
|
2021-07-22 05:24:14 +00:00
|
|
|
| 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 | * | |
|
|
|
|
|
| | pdo_pgsql | * | |
|
|
|
|
|
| yes | phar | * | |
|
|
|
|
|
| yes | posix | * | |
|
|
|
|
|
| yes | redis | * | |
|
|
|
|
|
| yes | simplexml | * | |
|
|
|
|
|
| yes | sockets | * | |
|
2021-07-23 14:31:51 +08:00
|
|
|
| yes | sqlite3 | * | |
|
2021-07-22 05:24:14 +00:00
|
|
|
| yes | swoole | >=4.6.6 | support mysqlnd, sockets, openssl, redis |
|
|
|
|
|
| yes | tokenizer | * | |
|
|
|
|
|
| yes | xml | * | |
|
|
|
|
|
| yes | xmlreader | * | |
|
|
|
|
|
| yes | xmlwriter | * | |
|
|
|
|
|
| | zip | | |
|
|
|
|
|
| yes | zlib | * | |
|
2021-06-06 11:41:55 +08:00
|
|
|
|
2021-06-06 11:53:16 +08:00
|
|
|
## 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).
|
|
|
|
|
- `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.
|
|
|
|
|
|
2021-06-06 11:41:55 +08:00
|
|
|
## Current Issue
|
|
|
|
|
- [ ] Not support event(libevent), because of its `config.m4` and code.
|
|
|
|
|
- [ ] Swoole not support `--enable-swoole-curl`.
|
|
|
|
|
- [ ] Not support readline, maybe caused by ncurses library.
|
|
|
|
|
- [X] Not support curl (solved)
|
|
|
|
|
- [X] Customize extensions to compile
|
|
|
|
|
- [ ] php.ini integration
|
|
|
|
|
- [X] i18n (including README and scripts)
|
2021-05-07 09:33:06 +08:00
|
|
|
|
|
|
|
|
## Running preview
|
|
|
|
|
After-compile status
|
|
|
|
|
|
2021-06-06 11:41:55 +08:00
|
|
|

|
|
|
|
|
|
|
|
|
|
Run Workerman directly
|
2021-05-07 09:33:06 +08:00
|
|
|
|
2021-06-06 11:41:55 +08:00
|
|
|

|
2021-05-07 09:33:06 +08:00
|
|
|
|
|
|
|
|
## 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/>
|