update to 1.3.2 version (support sqlite3)

This commit is contained in:
root 2021-07-22 05:24:14 +00:00
parent 36f4833b71
commit 35395538b4
11 changed files with 175 additions and 102 deletions

75
README-en.md Normal file → Executable file
View File

@ -3,7 +3,7 @@ Compile A Statically Linked PHP With Swoole and other Extensions.
BTW, It's only for CLI mode.
[![version](https://img.shields.io/badge/version-1.3.0-green.svg)]()
[![version](https://img.shields.io/badge/version-1.3.2-green.svg)]()
## Requirements
- 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
## Supported PHP extensions
| Support | PHP Ext Name | Version | Comments |
| -------- | ------------ | -------- | ------------------------------------------------------- |
| yes | bcmath | * | |
| yes | calendar | * | |
| yes | ctype | * | |
| yes | curl | * | |
| yes | dom | * | |
| | event | | |
| yes | filter | * | |
| yes | gd | * | |
| yes | hash | * | PHP7.3 or older uses `--enable-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 | * | |
| | pdo_pgsql | * | |
| yes | phar | * | |
| yes | posix | * | |
| yes | redis | * | |
| yes | simplexml | * | |
| yes | sockets | * | |
| yes | swoole | >=4.6.6 | support mysqlnd, sockets, openssl, redis |
| yes | tokenizer | * | |
| yes | xml | * | |
| yes | xmlreader | * | |
| yes | xmlwriter | * | |
| | zip | | |
| yes | zlib | * | |
| Support | PHP Ext Name | Version | Comments |
| ------- | ------------ | ------- | ---------------------------------------- |
| yes | bcmath | * | |
| yes | calendar | * | |
| yes | ctype | * | |
| yes | curl | * | |
| yes | dom | * | |
| | event | | |
| yes | filter | * | |
| yes | gd | * | |
| yes | hash | * | PHP7.3 or older uses `--enable-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 | * | |
| | pdo_pgsql | * | |
| yes | phar | * | |
| yes | posix | * | |
| yes | redis | * | |
| yes | simplexml | * | |
| yes | sockets | * | |
| yes | sqlite3 | * | not tested |
| yes | swoole | >=4.6.6 | support mysqlnd, sockets, openssl, redis |
| yes | tokenizer | * | |
| yes | xml | * | |
| yes | xmlreader | * | |
| yes | xmlwriter | * | |
| | zip | | |
| yes | zlib | * | |
## Customization
- `docker/Dockerfile` edit `VER_PHP=x.x.x` to switch PHP version.

3
README.md Normal file → Executable file
View File

@ -5,7 +5,7 @@ Compile A Statically Linked PHP With Swoole and other Extensions. [English READM
注:只能编译 CLI 模式,暂不支持 CGI 和 FPM 模式
[![版本](https://img.shields.io/badge/script--version-1.3.0-green.svg)]()
[![版本](https://img.shields.io/badge/script--version-1.3.2-green.svg)]()
## 环境需求
- 目前在 x86_64 和 aarch64(arm64) 架构上编译成功,其他架构需自行测试
@ -64,6 +64,7 @@ file ./php
| yes | redis | * | |
| yes | simplexml | * | |
| yes | sockets | * | |
| yes | sqlite3 | * | not tested |
| yes | swoole | >=4.6.6 | 默认支持mysqlnd, sockets, openssl, redis |
| yes | tokenizer | * | |
| yes | xml | * | |

6
docker/Dockerfile Normal file → Executable file
View File

@ -2,7 +2,7 @@ FROM alpine:latest
# define script basic information
# Version of this Dockerfile
ENV SCRIPT_VERSION=1.3.1
ENV SCRIPT_VERSION=1.3.2
# Download address uses backup address
# (if downloading slowly, consider set it to yes)
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
# 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
RUN apk add zlib-dev zlib-static
# php mbstring dependencies
@ -36,6 +36,8 @@ RUN apk add libpng-dev libpng-static
RUN apk add c-ares-static c-ares-dev
# php event dependencies
RUN apk add libevent libevent-dev libevent-static
# php sqlite3 dependencies
RUN apk add sqlite sqlite-dev sqlite-libs sqlite-static
RUN mkdir /app

0
docker/ac_override_1 Normal file → Executable file
View File

0
docker/ac_override_2 Normal file → Executable file
View File

View File

@ -73,6 +73,7 @@ function check_before_configure() {
phar) ;;
posix) ;;
sockets) ;;
sqlite3) ;;
tokenizer) ;;
zlib) ;;
curl)
@ -187,6 +188,8 @@ function check_in_configure() {
redis) php_configure="$php_configure --enable-redis --disable-redis-session" ;;
simplexml) php_configure="$php_configure --enable-simplexml" ;;
sockets) php_configure="$php_configure --enable-sockets" ;;
sqlite3) php_configure="$php_configure --with-sqlite3" ;;
swoole)
php_configure="$php_configure --enable-swoole"
have_openssl=$(echo $list | grep openssl)

View File

@ -6,7 +6,7 @@ self_dir=$(cd "$(dirname "$0")";pwd)
php_dir=$(find $self_dir/source -name "php-$VER_PHP" -type d | tail -n1)
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 --enable-shared=no"
_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" && \
make LDFLAGS=-ldl -j4 && \
make install && \
strip /app/php-dist/bin/php
strip $self_dir/php-dist/bin/php

89
docker/config.json Normal file → Executable file
View File

@ -1,46 +1,47 @@
{
"php": {
"link": "http://mirrors.zhamao.xin/php/php-{version}.tar.gz",
"link_2": "https://www.php.net/distributions/php-{version}.tar.gz"
},
"swoole": {
"version": "4.6.7",
"link": "http://mirrors.zhamao.xin/pecl/swoole-{version}.tgz",
"link_2": "https://pecl.php.net/get/swoole-{version}.tgz"
},
"mongodb": {
"version": "1.9.1",
"link": "http://mirrors.zhamao.xin/pecl/mongodb-{version}.tgz",
"link_2": "https://pecl.php.net/get/mongodb-{version}.tgz"
},
"inotify": {
"version": "3.0.0",
"link": "http://mirrors.zhamao.xin/pecl/inotify-{version}.tgz",
"link_2": "https://pecl.php.net/get/inotify-{version}.tgz"
},
"event": {
"version": "3.0.4",
"link": "http://mirrors.zhamao.xin/pecl/event-{version}.tgz",
"link_2": "https://pecl.php.net/get/event-{version}.tgz"
},
"redis": {
"version": "5.3.4",
"link": "http://mirrors.zhamao.xin/pecl/redis-{version}.tgz",
"link_2": "https://pecl.php.net/get/redis-{version}.tgz"
},
"libxml2": {
"version": "2.9.10",
"link": "https://dl.zhamao.me/libxml2/libxml2-{version}.tar.gz",
"link_2": "http://xmlsoft.org/sources/libxml2-{version}.tar.gz"
},
"liblzma": {
"version": "master",
"link": "https://dl.zhamao.me/liblzma/liblzma.tar.gz",
"link_2": "https://github.com/kobolabs/liblzma/archive/refs/heads/master.zip"
},
"curl": {
"version": "7.77.0",
"link": "https://dl.zhamao.me/curl/curl-{version}.tar.gz",
"link_2": "https://curl.haxx.se/download/curl-{version}.tar.gz"
}
"php": {
"link": "http://mirrors.zhamao.xin/php/php-{version}.tar.gz",
"link_2": "https://www.php.net/distributions/php-{version}.tar.gz"
},
"swoole": {
"version": "4.7.0",
"link": "http://mirrors.zhamao.xin/pecl/swoole-{version}.tgz",
"link_2": "https://pecl.php.net/get/swoole-{version}.tgz"
},
"mongodb": {
"version": "1.9.1",
"link": "http://mirrors.zhamao.xin/pecl/mongodb-{version}.tgz",
"link_2": "https://pecl.php.net/get/mongodb-{version}.tgz"
},
"inotify": {
"version": "3.0.0",
"link": "http://mirrors.zhamao.xin/pecl/inotify-{version}.tgz",
"link_2": "https://pecl.php.net/get/inotify-{version}.tgz"
},
"event": {
"version": "3.0.4",
"link": "http://mirrors.zhamao.xin/pecl/event-{version}.tgz",
"link_2": "https://pecl.php.net/get/event-{version}.tgz"
},
"redis": {
"version": "5.3.4",
"link": "http://mirrors.zhamao.xin/pecl/redis-{version}.tgz",
"link_2": "https://pecl.php.net/get/redis-{version}.tgz"
},
"libxml2": {
"version": "2.9.10",
"link": "https://dl.zhamao.me/libxml2/libxml2-{version}.tar.gz",
"link_2": "http://xmlsoft.org/sources/libxml2-{version}.tar.gz"
},
"liblzma": {
"version": "master",
"link": "https://dl.zhamao.me/liblzma/liblzma.tar.gz",
"link_2": "https://github.com/kobolabs/liblzma/archive/refs/heads/master.zip",
"alt_name": "master"
},
"curl": {
"version": "7.78.0",
"link": "https://dl.zhamao.me/curl/curl-{version}.tar.gz",
"link_2": "https://curl.haxx.se/download/curl-{version}.tar.gz"
}
}

View File

@ -8,6 +8,10 @@ if [ ! -d "source" ]; then
mkdir source
fi
if [ ! -d "source/cache" ]; then
mkdir source/cache
fi
function readconf() {
cat $SELF_DIR/config.json | jq $@ | sed 's/\"//g'
}
@ -20,24 +24,36 @@ else
_use_backup=""
fi
if [ "$3" != "" ]; then
wget -q --show-progress "$(readconf ".$1.link$_use_backup" | sed 's/{version}/'$3'/g')"
else
wget -q --show-progress "$(readconf ".$1.link$_use_backup" | sed 's/{version}/'$(readconf ".$1.version")'/g')"
fi
archive_find_tar=$(find cache/ -name "$1.*" | grep -E ".tgz" | tail -n1)
archive_find_zip=$(find cache/ -name "$1.*" | grep -E ".zip" | tail -n1)
if [ $? == 0 ]; then
archive_file_tar=$(find . -name "$1*.*" | grep -E ".tar|.gz|.tgz" | tail -n1)
archive_file_zip=$(find . -name "$1*.*" | grep -E ".zip" | tail -n1)
if [ "$archive_file_tar" != "" ]; then
tar -zxvf $archive_file_tar && rm $archive_file_tar
elif [ "$archive_file_zip" != "" ]; then
unzip $archive_file_zip && rm $archive_file_zip
if [ "$archive_find_tar" != "" ]; then
echo "Using cache for $1 ($archive_find_tar)"
tar -zxvf $archive_file_tar -C $SELF_DIR/source
elif [ "$archive_find_zip" != "" ]; then
echo "Using cache for $1 ($archive_find_zip)"
unzip $archive_find_zip -d $SELF_DIR/source
else
if [ "$3" != "" ]; then
wget -q --show-progress "$(readconf ".$1.link$_use_backup" | sed 's/{version}/'$3'/g')"
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
fi
else
echo "Download failed! "
exit 1
fi

1
docker/extensions.txt Normal file → Executable file
View File

@ -22,6 +22,7 @@ posix
redis
simplexml
sockets
sqlite3
swoole
tokenizer
xml

48
docker/fast-compiler.sh Executable file
View 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}