mirror of
https://github.com/crazywhalecc/static-php-cli.git
synced 2026-03-18 12:54:52 +08:00
update to 1.3.2 version (support sqlite3)
This commit is contained in:
parent
36f4833b71
commit
35395538b4
75
README-en.md
Normal file → Executable file
75
README-en.md
Normal file → Executable file
@ -3,7 +3,7 @@ Compile A Statically Linked PHP With Swoole and other Extensions.
|
|||||||
|
|
||||||
BTW, It's only for CLI mode.
|
BTW, It's only for CLI mode.
|
||||||
|
|
||||||
[]()
|
[]()
|
||||||
|
|
||||||
## Requirements
|
## Requirements
|
||||||
- Tested on `x86_64` and `aarch64` platform, others have not tested.
|
- Tested on `x86_64` and `aarch64` platform, others have not tested.
|
||||||
@ -33,42 +33,43 @@ To customize PHP extensions, edit `docker/extensions.txt` file, and rules below:
|
|||||||
- extensions name uses lower case, and default file contains all supported extensions, if u need other extensions, consider write an Issue
|
- extensions name uses lower case, and default file contains all supported extensions, if u need other extensions, consider write an Issue
|
||||||
|
|
||||||
## Supported PHP extensions
|
## Supported PHP extensions
|
||||||
| Support | PHP Ext Name | Version | Comments |
|
| Support | PHP Ext Name | Version | Comments |
|
||||||
| -------- | ------------ | -------- | ------------------------------------------------------- |
|
| ------- | ------------ | ------- | ---------------------------------------- |
|
||||||
| yes | bcmath | * | |
|
| yes | bcmath | * | |
|
||||||
| yes | calendar | * | |
|
| yes | calendar | * | |
|
||||||
| yes | ctype | * | |
|
| yes | ctype | * | |
|
||||||
| yes | curl | * | |
|
| yes | curl | * | |
|
||||||
| yes | dom | * | |
|
| yes | dom | * | |
|
||||||
| | event | | |
|
| | event | | |
|
||||||
| yes | filter | * | |
|
| yes | filter | * | |
|
||||||
| yes | gd | * | |
|
| yes | gd | * | |
|
||||||
| yes | hash | * | PHP7.3 or older uses `--enable-hash` |
|
| yes | hash | * | PHP7.3 or older uses `--enable-hash` |
|
||||||
| yes | iconv | * | |
|
| yes | iconv | * | |
|
||||||
| yes | inotify | 3.0.0 | |
|
| yes | inotify | 3.0.0 | |
|
||||||
| yes | json | * | |
|
| yes | json | * | |
|
||||||
| yes | libxml | * | |
|
| yes | libxml | * | |
|
||||||
| yes | mbstring | * | |
|
| yes | mbstring | * | |
|
||||||
| yes | mongodb | >=1.9.1 | not tested |
|
| yes | mongodb | >=1.9.1 | not tested |
|
||||||
| | mysqli | | |
|
| | mysqli | | |
|
||||||
| yes | mysqlnd | * | |
|
| yes | mysqlnd | * | |
|
||||||
| yes | openssl | * | |
|
| yes | openssl | * | |
|
||||||
| yes | pcntl | * | |
|
| yes | pcntl | * | |
|
||||||
| yes | pdo | * | |
|
| yes | pdo | * | |
|
||||||
| yes | pdo_mysql | * | |
|
| yes | pdo_mysql | * | |
|
||||||
| | pdo_pgsql | * | |
|
| | pdo_pgsql | * | |
|
||||||
| yes | phar | * | |
|
| yes | phar | * | |
|
||||||
| yes | posix | * | |
|
| yes | posix | * | |
|
||||||
| yes | redis | * | |
|
| yes | redis | * | |
|
||||||
| yes | simplexml | * | |
|
| yes | simplexml | * | |
|
||||||
| yes | sockets | * | |
|
| yes | sockets | * | |
|
||||||
| yes | swoole | >=4.6.6 | support mysqlnd, sockets, openssl, redis |
|
| yes | sqlite3 | * | not tested |
|
||||||
| yes | tokenizer | * | |
|
| yes | swoole | >=4.6.6 | support mysqlnd, sockets, openssl, redis |
|
||||||
| yes | xml | * | |
|
| yes | tokenizer | * | |
|
||||||
| yes | xmlreader | * | |
|
| yes | xml | * | |
|
||||||
| yes | xmlwriter | * | |
|
| yes | xmlreader | * | |
|
||||||
| | zip | | |
|
| yes | xmlwriter | * | |
|
||||||
| yes | zlib | * | |
|
| | zip | | |
|
||||||
|
| yes | zlib | * | |
|
||||||
|
|
||||||
## Customization
|
## Customization
|
||||||
- `docker/Dockerfile` edit `VER_PHP=x.x.x` to switch PHP version.
|
- `docker/Dockerfile` edit `VER_PHP=x.x.x` to switch PHP version.
|
||||||
|
|||||||
3
README.md
Normal file → Executable file
3
README.md
Normal file → Executable file
@ -5,7 +5,7 @@ Compile A Statically Linked PHP With Swoole and other Extensions. [English READM
|
|||||||
|
|
||||||
注:只能编译 CLI 模式,暂不支持 CGI 和 FPM 模式
|
注:只能编译 CLI 模式,暂不支持 CGI 和 FPM 模式
|
||||||
|
|
||||||
[]()
|
[]()
|
||||||
|
|
||||||
## 环境需求
|
## 环境需求
|
||||||
- 目前在 x86_64 和 aarch64(arm64) 架构上编译成功,其他架构需自行测试
|
- 目前在 x86_64 和 aarch64(arm64) 架构上编译成功,其他架构需自行测试
|
||||||
@ -64,6 +64,7 @@ file ./php
|
|||||||
| yes | redis | * | |
|
| yes | redis | * | |
|
||||||
| yes | simplexml | * | |
|
| yes | simplexml | * | |
|
||||||
| yes | sockets | * | |
|
| yes | sockets | * | |
|
||||||
|
| yes | sqlite3 | * | not tested |
|
||||||
| yes | swoole | >=4.6.6 | 默认支持mysqlnd, sockets, openssl, redis |
|
| yes | swoole | >=4.6.6 | 默认支持mysqlnd, sockets, openssl, redis |
|
||||||
| yes | tokenizer | * | |
|
| yes | tokenizer | * | |
|
||||||
| yes | xml | * | |
|
| yes | xml | * | |
|
||||||
|
|||||||
6
docker/Dockerfile
Normal file → Executable file
6
docker/Dockerfile
Normal file → Executable file
@ -2,7 +2,7 @@ FROM alpine:latest
|
|||||||
|
|
||||||
# define script basic information
|
# define script basic information
|
||||||
# Version of this Dockerfile
|
# Version of this Dockerfile
|
||||||
ENV SCRIPT_VERSION=1.3.1
|
ENV SCRIPT_VERSION=1.3.2
|
||||||
# Download address uses backup address
|
# Download address uses backup address
|
||||||
# (if downloading slowly, consider set it to yes)
|
# (if downloading slowly, consider set it to yes)
|
||||||
ENV USE_BACKUP=no
|
ENV USE_BACKUP=no
|
||||||
@ -23,7 +23,7 @@ RUN if [ "${USE_BACKUP}" = "yes" ]; then \
|
|||||||
RUN sed -i 's/dl-cdn.alpinelinux.org/'${LINK_APK_REPO}'/g' /etc/apk/repositories
|
RUN sed -i 's/dl-cdn.alpinelinux.org/'${LINK_APK_REPO}'/g' /etc/apk/repositories
|
||||||
|
|
||||||
# build requirements
|
# build requirements
|
||||||
RUN apk add wget cmake gcc g++ jq autoconf git libstdc++ linux-headers make m4 libgcc binutils ncurses
|
RUN apk add bash wget cmake gcc g++ jq autoconf git libstdc++ linux-headers make m4 libgcc binutils ncurses
|
||||||
# php zlib dependencies
|
# php zlib dependencies
|
||||||
RUN apk add zlib-dev zlib-static
|
RUN apk add zlib-dev zlib-static
|
||||||
# php mbstring dependencies
|
# php mbstring dependencies
|
||||||
@ -36,6 +36,8 @@ RUN apk add libpng-dev libpng-static
|
|||||||
RUN apk add c-ares-static c-ares-dev
|
RUN apk add c-ares-static c-ares-dev
|
||||||
# php event dependencies
|
# php event dependencies
|
||||||
RUN apk add libevent libevent-dev libevent-static
|
RUN apk add libevent libevent-dev libevent-static
|
||||||
|
# php sqlite3 dependencies
|
||||||
|
RUN apk add sqlite sqlite-dev sqlite-libs sqlite-static
|
||||||
|
|
||||||
RUN mkdir /app
|
RUN mkdir /app
|
||||||
|
|
||||||
|
|||||||
0
docker/ac_override_1
Normal file → Executable file
0
docker/ac_override_1
Normal file → Executable file
0
docker/ac_override_2
Normal file → Executable file
0
docker/ac_override_2
Normal file → Executable file
@ -73,6 +73,7 @@ function check_before_configure() {
|
|||||||
phar) ;;
|
phar) ;;
|
||||||
posix) ;;
|
posix) ;;
|
||||||
sockets) ;;
|
sockets) ;;
|
||||||
|
sqlite3) ;;
|
||||||
tokenizer) ;;
|
tokenizer) ;;
|
||||||
zlib) ;;
|
zlib) ;;
|
||||||
curl)
|
curl)
|
||||||
@ -187,6 +188,8 @@ function check_in_configure() {
|
|||||||
redis) php_configure="$php_configure --enable-redis --disable-redis-session" ;;
|
redis) php_configure="$php_configure --enable-redis --disable-redis-session" ;;
|
||||||
simplexml) php_configure="$php_configure --enable-simplexml" ;;
|
simplexml) php_configure="$php_configure --enable-simplexml" ;;
|
||||||
sockets) php_configure="$php_configure --enable-sockets" ;;
|
sockets) php_configure="$php_configure --enable-sockets" ;;
|
||||||
|
sqlite3) php_configure="$php_configure --with-sqlite3" ;;
|
||||||
|
|
||||||
swoole)
|
swoole)
|
||||||
php_configure="$php_configure --enable-swoole"
|
php_configure="$php_configure --enable-swoole"
|
||||||
have_openssl=$(echo $list | grep openssl)
|
have_openssl=$(echo $list | grep openssl)
|
||||||
|
|||||||
@ -6,7 +6,7 @@ self_dir=$(cd "$(dirname "$0")";pwd)
|
|||||||
php_dir=$(find $self_dir/source -name "php-$VER_PHP" -type d | tail -n1)
|
php_dir=$(find $self_dir/source -name "php-$VER_PHP" -type d | tail -n1)
|
||||||
|
|
||||||
function php_compile_args() {
|
function php_compile_args() {
|
||||||
_php_arg="--prefix=/app/php-dist"
|
_php_arg="--prefix=$self_dir/php-dist"
|
||||||
_php_arg="$_php_arg --disable-all"
|
_php_arg="$_php_arg --disable-all"
|
||||||
_php_arg="$_php_arg --enable-shared=no"
|
_php_arg="$_php_arg --enable-shared=no"
|
||||||
_php_arg="$_php_arg --enable-static=yes"
|
_php_arg="$_php_arg --enable-static=yes"
|
||||||
@ -29,4 +29,4 @@ cd $php_dir && \
|
|||||||
sed -ie 's/-o $(SAPI_CLI_PATH)/-all-static -o $(SAPI_CLI_PATH)/g' "Makefile" && \
|
sed -ie 's/-o $(SAPI_CLI_PATH)/-all-static -o $(SAPI_CLI_PATH)/g' "Makefile" && \
|
||||||
make LDFLAGS=-ldl -j4 && \
|
make LDFLAGS=-ldl -j4 && \
|
||||||
make install && \
|
make install && \
|
||||||
strip /app/php-dist/bin/php
|
strip $self_dir/php-dist/bin/php
|
||||||
89
docker/config.json
Normal file → Executable file
89
docker/config.json
Normal file → Executable file
@ -1,46 +1,47 @@
|
|||||||
{
|
{
|
||||||
"php": {
|
"php": {
|
||||||
"link": "http://mirrors.zhamao.xin/php/php-{version}.tar.gz",
|
"link": "http://mirrors.zhamao.xin/php/php-{version}.tar.gz",
|
||||||
"link_2": "https://www.php.net/distributions/php-{version}.tar.gz"
|
"link_2": "https://www.php.net/distributions/php-{version}.tar.gz"
|
||||||
},
|
},
|
||||||
"swoole": {
|
"swoole": {
|
||||||
"version": "4.6.7",
|
"version": "4.7.0",
|
||||||
"link": "http://mirrors.zhamao.xin/pecl/swoole-{version}.tgz",
|
"link": "http://mirrors.zhamao.xin/pecl/swoole-{version}.tgz",
|
||||||
"link_2": "https://pecl.php.net/get/swoole-{version}.tgz"
|
"link_2": "https://pecl.php.net/get/swoole-{version}.tgz"
|
||||||
},
|
},
|
||||||
"mongodb": {
|
"mongodb": {
|
||||||
"version": "1.9.1",
|
"version": "1.9.1",
|
||||||
"link": "http://mirrors.zhamao.xin/pecl/mongodb-{version}.tgz",
|
"link": "http://mirrors.zhamao.xin/pecl/mongodb-{version}.tgz",
|
||||||
"link_2": "https://pecl.php.net/get/mongodb-{version}.tgz"
|
"link_2": "https://pecl.php.net/get/mongodb-{version}.tgz"
|
||||||
},
|
},
|
||||||
"inotify": {
|
"inotify": {
|
||||||
"version": "3.0.0",
|
"version": "3.0.0",
|
||||||
"link": "http://mirrors.zhamao.xin/pecl/inotify-{version}.tgz",
|
"link": "http://mirrors.zhamao.xin/pecl/inotify-{version}.tgz",
|
||||||
"link_2": "https://pecl.php.net/get/inotify-{version}.tgz"
|
"link_2": "https://pecl.php.net/get/inotify-{version}.tgz"
|
||||||
},
|
},
|
||||||
"event": {
|
"event": {
|
||||||
"version": "3.0.4",
|
"version": "3.0.4",
|
||||||
"link": "http://mirrors.zhamao.xin/pecl/event-{version}.tgz",
|
"link": "http://mirrors.zhamao.xin/pecl/event-{version}.tgz",
|
||||||
"link_2": "https://pecl.php.net/get/event-{version}.tgz"
|
"link_2": "https://pecl.php.net/get/event-{version}.tgz"
|
||||||
},
|
},
|
||||||
"redis": {
|
"redis": {
|
||||||
"version": "5.3.4",
|
"version": "5.3.4",
|
||||||
"link": "http://mirrors.zhamao.xin/pecl/redis-{version}.tgz",
|
"link": "http://mirrors.zhamao.xin/pecl/redis-{version}.tgz",
|
||||||
"link_2": "https://pecl.php.net/get/redis-{version}.tgz"
|
"link_2": "https://pecl.php.net/get/redis-{version}.tgz"
|
||||||
},
|
},
|
||||||
"libxml2": {
|
"libxml2": {
|
||||||
"version": "2.9.10",
|
"version": "2.9.10",
|
||||||
"link": "https://dl.zhamao.me/libxml2/libxml2-{version}.tar.gz",
|
"link": "https://dl.zhamao.me/libxml2/libxml2-{version}.tar.gz",
|
||||||
"link_2": "http://xmlsoft.org/sources/libxml2-{version}.tar.gz"
|
"link_2": "http://xmlsoft.org/sources/libxml2-{version}.tar.gz"
|
||||||
},
|
},
|
||||||
"liblzma": {
|
"liblzma": {
|
||||||
"version": "master",
|
"version": "master",
|
||||||
"link": "https://dl.zhamao.me/liblzma/liblzma.tar.gz",
|
"link": "https://dl.zhamao.me/liblzma/liblzma.tar.gz",
|
||||||
"link_2": "https://github.com/kobolabs/liblzma/archive/refs/heads/master.zip"
|
"link_2": "https://github.com/kobolabs/liblzma/archive/refs/heads/master.zip",
|
||||||
},
|
"alt_name": "master"
|
||||||
"curl": {
|
},
|
||||||
"version": "7.77.0",
|
"curl": {
|
||||||
"link": "https://dl.zhamao.me/curl/curl-{version}.tar.gz",
|
"version": "7.78.0",
|
||||||
"link_2": "https://curl.haxx.se/download/curl-{version}.tar.gz"
|
"link": "https://dl.zhamao.me/curl/curl-{version}.tar.gz",
|
||||||
}
|
"link_2": "https://curl.haxx.se/download/curl-{version}.tar.gz"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@ -8,6 +8,10 @@ if [ ! -d "source" ]; then
|
|||||||
mkdir source
|
mkdir source
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
if [ ! -d "source/cache" ]; then
|
||||||
|
mkdir source/cache
|
||||||
|
fi
|
||||||
|
|
||||||
function readconf() {
|
function readconf() {
|
||||||
cat $SELF_DIR/config.json | jq $@ | sed 's/\"//g'
|
cat $SELF_DIR/config.json | jq $@ | sed 's/\"//g'
|
||||||
}
|
}
|
||||||
@ -20,24 +24,36 @@ else
|
|||||||
_use_backup=""
|
_use_backup=""
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ "$3" != "" ]; then
|
archive_find_tar=$(find cache/ -name "$1.*" | grep -E ".tgz" | tail -n1)
|
||||||
wget -q --show-progress "$(readconf ".$1.link$_use_backup" | sed 's/{version}/'$3'/g')"
|
archive_find_zip=$(find cache/ -name "$1.*" | grep -E ".zip" | tail -n1)
|
||||||
else
|
|
||||||
wget -q --show-progress "$(readconf ".$1.link$_use_backup" | sed 's/{version}/'$(readconf ".$1.version")'/g')"
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [ $? == 0 ]; then
|
if [ "$archive_find_tar" != "" ]; then
|
||||||
archive_file_tar=$(find . -name "$1*.*" | grep -E ".tar|.gz|.tgz" | tail -n1)
|
echo "Using cache for $1 ($archive_find_tar)"
|
||||||
archive_file_zip=$(find . -name "$1*.*" | grep -E ".zip" | tail -n1)
|
tar -zxvf $archive_file_tar -C $SELF_DIR/source
|
||||||
if [ "$archive_file_tar" != "" ]; then
|
elif [ "$archive_find_zip" != "" ]; then
|
||||||
tar -zxvf $archive_file_tar && rm $archive_file_tar
|
echo "Using cache for $1 ($archive_find_zip)"
|
||||||
elif [ "$archive_file_zip" != "" ]; then
|
unzip $archive_find_zip -d $SELF_DIR/source
|
||||||
unzip $archive_file_zip && rm $archive_file_zip
|
else
|
||||||
|
if [ "$3" != "" ]; then
|
||||||
|
wget -q --show-progress "$(readconf ".$1.link$_use_backup" | sed 's/{version}/'$3'/g')"
|
||||||
else
|
else
|
||||||
echo "Unable to find downloaded file, only support '.tar.gz', '.tgz', '.zip' file!"
|
echo "Downloading"
|
||||||
|
wget -q --show-progress "$(readconf ".$1.link$_use_backup" | sed 's/{version}/'$(readconf ".$1.version")'/g')"
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ $? == 0 ]; then
|
||||||
|
archive_file_tar=$(find . -name "$1*.*" | grep -E ".tar|.gz|.tgz" | tail -n1)
|
||||||
|
archive_file_zip=$(find . -name "*.zip" | tail -n1)
|
||||||
|
if [ "$archive_file_tar" != "" ]; then
|
||||||
|
tar -zxvf $archive_file_tar && mv $archive_file_tar $SELF_DIR/source/cache/$1.tgz
|
||||||
|
elif [ "$archive_file_zip" != "" ]; then
|
||||||
|
unzip $archive_file_zip && mv $archive_file_zip $SELF_DIR/source/cache/$1.zip
|
||||||
|
else
|
||||||
|
echo "Unable to find downloaded file, only support '.tar.gz', '.tgz', '.zip' file!"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
echo "Download $1 failed! (at $?)"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
else
|
|
||||||
echo "Download failed! "
|
|
||||||
exit 1
|
|
||||||
fi
|
fi
|
||||||
1
docker/extensions.txt
Normal file → Executable file
1
docker/extensions.txt
Normal file → Executable file
@ -22,6 +22,7 @@ posix
|
|||||||
redis
|
redis
|
||||||
simplexml
|
simplexml
|
||||||
sockets
|
sockets
|
||||||
|
sqlite3
|
||||||
swoole
|
swoole
|
||||||
tokenizer
|
tokenizer
|
||||||
xml
|
xml
|
||||||
|
|||||||
48
docker/fast-compiler.sh
Executable file
48
docker/fast-compiler.sh
Executable file
@ -0,0 +1,48 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
VER_PHP="7.4.21"
|
||||||
|
USE_BACKUP="no"
|
||||||
|
|
||||||
|
LINK_APK_REPO='mirrors.ustc.edu.cn'
|
||||||
|
LINK_APK_REPO_BAK='dl-cdn.alpinelinux.org'
|
||||||
|
|
||||||
|
if [ "${USE_BACKUP}" = "yes" ]; then \
|
||||||
|
echo "Using backup address..." && sleep 1s
|
||||||
|
LINK_APK_REPO=${LINK_APK_REPO_BAK}
|
||||||
|
else
|
||||||
|
echo "Using original address..." && sleep 1s
|
||||||
|
fi
|
||||||
|
|
||||||
|
sed -i 's/dl-cdn.alpinelinux.org/'${LINK_APK_REPO}'/g' /etc/apk/repositories
|
||||||
|
|
||||||
|
# build requirements
|
||||||
|
apk add bash wget cmake gcc g++ jq autoconf git libstdc++ linux-headers make m4 libgcc binutils ncurses
|
||||||
|
# php zlib dependencies
|
||||||
|
apk add zlib-dev zlib-static
|
||||||
|
# php mbstring dependencies
|
||||||
|
apk add oniguruma-dev
|
||||||
|
# php openssl dependencies
|
||||||
|
apk add openssl-libs-static openssl-dev openssl
|
||||||
|
# php gd dependencies
|
||||||
|
apk add libpng-dev libpng-static
|
||||||
|
# curl c-ares dependencies
|
||||||
|
apk add c-ares-static c-ares-dev
|
||||||
|
# php event dependencies
|
||||||
|
apk add libevent libevent-dev libevent-static
|
||||||
|
# php sqlite3 dependencies
|
||||||
|
apk add sqlite sqlite-dev sqlite-libs sqlite-static
|
||||||
|
|
||||||
|
chmod +x download.sh check-extensions.sh compile-php.sh
|
||||||
|
|
||||||
|
./download.sh swoole ${USE_BACKUP} && \
|
||||||
|
./download.sh inotify ${USE_BACKUP} && \
|
||||||
|
./download.sh mongodb ${USE_BACKUP} && \
|
||||||
|
./download.sh event ${USE_BACKUP} && \
|
||||||
|
./download.sh redis ${USE_BACKUP} && \
|
||||||
|
./download.sh libxml2 ${USE_BACKUP} && \
|
||||||
|
./download.sh liblzma ${USE_BACKUP} && \
|
||||||
|
./download.sh curl ${USE_BACKUP} && \
|
||||||
|
./download.sh php ${USE_BACKUP} ${VER_PHP} && \
|
||||||
|
./check-extensions.sh check_before_configure && \
|
||||||
|
./compile-php.sh ${VER_PHP}
|
||||||
|
|
||||||
Loading…
x
Reference in New Issue
Block a user