mirror of
https://github.com/crazywhalecc/static-php-cli.git
synced 2026-03-18 04:44:53 +08:00
6.3 KiB
Executable File
6.3 KiB
Executable File
static-php-cli
Compile A Statically Linked PHP With Swoole and other Extensions.
BTW, It's only for CLI mode.
Compilation Requirements
- Supporting architecture:
x86_64,arm64(aarch64),armv7(armv7l) - Docker required (or alpine linux 3.13+)
- Supporting PHP version from 7.2 to 8.1
Running Requirements
Linux
Start
- Directly download static binary from this link.
https://dl.zhamao.xin/php-bin/file/
- Use fast install script
install-runtime.shto download static php and composer distribution intoruntime/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 -c "`curl -fsSL https://raw.githubusercontent.com/crazywhalecc/static-php-cli/master/install-runtime.sh`"
- Here's help command to compile it yourself:
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.28
After compilation you can use command to get static php binary file:
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
Supported PHP extensions
| Support | PHP Ext Name | Version | Comments |
|---|---|---|---|
| yes | bcmath | * | |
| yes | calendar | * | |
| yes | ctype | * | |
| yes | curl | * | |
| yes | dom | * | |
| event | |||
| 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 | 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 | * | |
| zip | |||
| yes | zlib | * |
Customization
docker/DockerfileeditVER_PHP=x.x.xto switch PHP version.docker/DockerfileeditUSE_BACKUP=yesto use backup download address (download faster if you are not in mainland China).docker/extensions.txtedit extensions.docker/compile-php.shfilephp_compile_argsfunction to adjust PHP configure arguments.docker/check-extensions.shfilecheck_in_configurefunction to adjust extensions' configure arguments.docker/config.jsonedit extensions and dependencies version and download links.
Current Issue
- Not support event(libevent), because of its
config.m4and code. - Swoole not support
--enable-swoole-curl. - Not support readline, maybe caused by ncurses library.
- Not support curl (solved)
- Customize extensions to compile
- php.ini integration
- i18n (including README and scripts)
Running preview
After-compile status
Run Workerman directly

