mirror of
https://github.com/crazywhalecc/static-php-cli.git
synced 2026-07-02 22:35:43 +08:00
Compare commits
17 Commits
pure-shell
...
1.3.3
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
66942f866e | ||
|
|
7440fe3936 | ||
|
|
35395538b4 | ||
|
|
36f4833b71 | ||
|
|
33de213a66 | ||
|
|
9fa229fa36 | ||
|
|
6efa11d8af | ||
|
|
cc3fa7d1fd | ||
|
|
de5d92be70 | ||
|
|
cb679247fc | ||
|
|
f7e961c223 | ||
|
|
89fc7c6482 | ||
|
|
12b32ce1a0 | ||
|
|
cdf4d4999e | ||
|
|
6926a5c989 | ||
|
|
2944eb4a75 | ||
|
|
135259e0db |
127
README-en.md
Normal file → Executable file
127
README-en.md
Normal file → Executable file
@@ -1,72 +1,101 @@
|
||||
# static-php-swoole
|
||||
Compile A Statically Linked PHP With Swoole and other Extensions. [English README](/README-en.md)
|
||||
# static-php-cli
|
||||
Compile A Statically Linked PHP With Swoole and other Extensions.
|
||||
|
||||
BTW, It's only for CLI mode.
|
||||
|
||||
[]()
|
||||
[]()
|
||||
|
||||
## Requirements
|
||||
- Tested on `x86_64` and `aarch64` platform, others have not tested.
|
||||
- Requiring Alpine Linux (version >= 3.13), or requiring musl-libc
|
||||
- Support WSL2
|
||||
- Supporting PHP version >= 7.3
|
||||
- Docker required (or alpine linux when I write single script file)
|
||||
- Supporting PHP version from 7.2 to 8.0
|
||||
|
||||
## Start
|
||||
You can directly download static binary in Release.
|
||||
|
||||
Here's help command to compile it yourself:
|
||||
```bash
|
||||
# Compile script
|
||||
./static-compile-php.sh
|
||||
# And now you get `php-dist/bin/php` file!
|
||||
git clone https://github.com/crazywhalecc/static-php-cli.git
|
||||
cd static-php-cli/docker
|
||||
docker build -t static-php .
|
||||
```
|
||||
|
||||
## Library version
|
||||
- php: 7.4.18
|
||||
- libxml2: 2.9.10
|
||||
- curl: 7.76.1
|
||||
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
|
||||
```
|
||||
|
||||
## Including PHP extensions
|
||||
- bcmath
|
||||
- calendar
|
||||
- ctype
|
||||
- filter
|
||||
- openssl
|
||||
- pcntl
|
||||
- iconv
|
||||
- inotify (3.0.0)
|
||||
- json
|
||||
- mbstring
|
||||
- phar
|
||||
- curl
|
||||
- pdo
|
||||
- gd
|
||||
- pdo_mysql
|
||||
- mysqlnd
|
||||
- sockets
|
||||
- swoole (4.6.6)
|
||||
- redis (5.3.4)
|
||||
- simplexml
|
||||
- dom
|
||||
- xml
|
||||
- xmlwriter
|
||||
- xmlreader
|
||||
- posix
|
||||
- tokenizer
|
||||
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 | 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.
|
||||
- `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.
|
||||
|
||||
## 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)
|
||||
|
||||
## Running preview
|
||||
After-compile status
|
||||

|
||||
|
||||
Run Swoft framework directly
|
||||

|
||||

|
||||
|
||||
## Todo List
|
||||
- [X] curl/libcurl extension support
|
||||
- [ ] Alternative extension compiling
|
||||
- [ ] php.ini support
|
||||
- [ ] Make composer together
|
||||
- [ ] i18n
|
||||
Run Workerman directly
|
||||
|
||||

|
||||
|
||||
## References
|
||||
- <https://blog.terrywh.net/post/2019/php-static-openssl/>
|
||||
|
||||
100
README.md
Normal file → Executable file
100
README.md
Normal file → Executable file
@@ -5,9 +5,7 @@ Compile A Statically Linked PHP With Swoole and other Extensions. [English READM
|
||||
|
||||
注:只能编译 CLI 模式,暂不支持 CGI 和 FPM 模式
|
||||
|
||||
**这个分支是旧版本的纯 shell 脚本版本,新版本在 master 分支,换成了 Dockerfile 版本,可以更加便捷地在不同系统下进行构建了!**
|
||||
|
||||
[]()
|
||||
[]()
|
||||
|
||||
## 环境需求
|
||||
- 目前在 x86_64 和 aarch64(arm64) 架构上编译成功,其他架构需自行测试
|
||||
@@ -27,59 +25,81 @@ docker build -t static-php .
|
||||
编译之后可以使用下方命令将二进制 PHP 提取出来,用以下方式:
|
||||
```bash
|
||||
mkdir dist
|
||||
docker run --rm -v $(pwd)/dist:/dist/ -it static cp php-dist/bin/php /dist/
|
||||
docker run --rm -v $(pwd)/dist:/dist/ -it static-php cp php-dist/bin/php /dist/
|
||||
cd dist
|
||||
file ./php
|
||||
```
|
||||
|
||||
如果要选择安装的扩展,可以修改 `docker/extensions.txt` 文件,具体规则如下:
|
||||
- 文件内使用 `#` 可以注释,表示不安装
|
||||
- 扩展名一律使用小写,目前默认状态下文件内所列的扩展为支持的扩展,其他扩展暂不支持,如有需求请提 Issue 添加
|
||||
|
||||
## 支持的扩展(对勾为已支持的扩展,未打勾的正在努力兼容)
|
||||
- [X] bcmath
|
||||
- [X] calendar
|
||||
- [X] ctype
|
||||
- [X] filter
|
||||
- [X] openssl
|
||||
- [X] pcntl
|
||||
- [X] iconv
|
||||
- [X] inotify
|
||||
- [X] json
|
||||
- [X] mbstring
|
||||
- [X] phar
|
||||
- [X] curl
|
||||
- [X] pdo
|
||||
- [X] gd
|
||||
- [X] pdo_mysql
|
||||
- [X] mysqlnd
|
||||
- [X] sockets
|
||||
- [X] swoole
|
||||
- [X] redis
|
||||
- [X] simplexml
|
||||
- [X] dom
|
||||
- [X] xml
|
||||
- [X] xmlwriter
|
||||
- [X] xmlreader
|
||||
- [X] posix
|
||||
- [X] tokenizer
|
||||
- [ ] zip
|
||||
## 支持的扩展表
|
||||
| 是否支持 | PHP 扩展名称 | 支持版本 | 备注 |
|
||||
| -------- | ------------ | -------- | ------------------------------------------------------- |
|
||||
| yes | bcmath | * | |
|
||||
| yes | calendar | * | |
|
||||
| yes | ctype | * | |
|
||||
| yes | curl | * | |
|
||||
| yes | dom | * | |
|
||||
| | event | | |
|
||||
| yes | filter | * | |
|
||||
| yes | gd | * | |
|
||||
| yes | hash | * | PHP7.3及以下版本需指定 `--enable-hash`,7.4以上默认开启 |
|
||||
| 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 | * | |
|
||||
| yes | swoole | >=4.6.6 | 默认支持mysqlnd, sockets, openssl, redis |
|
||||
| yes | tokenizer | * | |
|
||||
| yes | xml | * | |
|
||||
| yes | xmlreader | * | |
|
||||
| yes | xmlwriter | * | |
|
||||
| | zip | | |
|
||||
| yes | zlib | * | |
|
||||
|
||||
## 目前的问题(待解决的)
|
||||
- [ ] event 扩展的 sockets 支持不能在静态编译中使用,因为静态内嵌编译暂时没办法调整扩展编译顺序。
|
||||
## 自定义
|
||||
- `docker/Dockerfile` 中修改 `VER_PHP=x.x.x` 来更换 PHP 版本。
|
||||
- `docker/Dockerfile` 中修改 `USE_BACKUP=yes` 使用备用下载源码地址(不在中国大陆可以使用备用地址)。
|
||||
- `docker/extensions.txt` 指定要编译安装的扩展。
|
||||
- `docker/compile-php.sh` 中的 `php_compile_args` 函数来调整 PHP 编译参数。
|
||||
- `docker/check-extensions.sh` 中的 `check_in_configure` 函数可调整 PHP 扩展编译的参数 。
|
||||
- `docker/config.json` 可调整要下载的扩展和依赖库版本和链接。
|
||||
|
||||
## 目前的问题(对勾为已解决)
|
||||
- [ ] 不支持 event(libevent) 扩展,event 扩展的 sockets 支持不能在静态编译中使用,因为静态内嵌编译暂时没办法调整扩展编译顺序,同时其本身也不支持静态编译。
|
||||
- [ ] Swoole 扩展不支持 `--enable-swoole-curl`,也是因为编译顺序和加载顺序的问题。
|
||||
- [ ] readline 扩展安装后无法正常使用 `php -a`,原因还没有弄清楚,可能是静态编译造成的 ncurses 库出现了问题。
|
||||
|
||||
## Todo List
|
||||
- [ ] 不支持 readline 扩展,readline 扩展安装后无法正常使用 `php -a`,原因还没有弄清楚,可能是静态编译造成的 ncurses 库出现了问题。
|
||||
- [X] curl/libcurl 扩展静态编译
|
||||
- [X] 可自行选择不需要编译进入的扩展
|
||||
- [ ] php.ini 内嵌或分发
|
||||
- [ ] i18n(国际化脚本本身和 README)
|
||||
|
||||
如果你对以上问题有解决方案,请提出 Issue 或 PR!
|
||||
|
||||
## 运行示例
|
||||
编译后的状态
|
||||

|
||||
|
||||
在不同系统直接运行 Swoft
|
||||

|
||||

|
||||
|
||||
直接运行 Workerman
|
||||
|
||||

|
||||
|
||||
## 参考资料
|
||||
- <https://blog.terrywh.net/post/2019/php-static-openssl/>
|
||||
|
||||
126
docker/Dockerfile
Normal file → Executable file
126
docker/Dockerfile
Normal file → Executable file
@@ -1,23 +1,16 @@
|
||||
from alpine:latest
|
||||
FROM alpine:latest
|
||||
|
||||
# define script basic information
|
||||
# Version of this Dockerfile
|
||||
ENV SCRIPT_VERSION=1.3.0
|
||||
ENV SCRIPT_VERSION=1.3.3
|
||||
# Download address uses backup address
|
||||
# (if downloading slowly, consider set it to yes)
|
||||
ENV USE_BACKUP=no
|
||||
|
||||
# Version of some manually-installed package
|
||||
ENV VER_PHP=7.4.19
|
||||
ENV VER_SWOOLE=4.6.7
|
||||
ENV VER_HASH=1.5
|
||||
ENV VER_INOTIFY=3.0.0
|
||||
ENV VER_REDIS=5.3.4
|
||||
ENV VER_LIBXML2=2.9.12
|
||||
ENV VER_CURL=7.77.0
|
||||
ENV VER_LIBLZMA=master
|
||||
ENV VER_PHP=7.4.21
|
||||
|
||||
# LINK_OF_ADDRESS_ORIGIN
|
||||
# APK repositories mirror address, if u r not in China, consider set USE_BACKUP=yes to boost
|
||||
ENV LINK_APK_REPO='mirrors.ustc.edu.cn'
|
||||
ENV LINK_APK_REPO_BAK='dl-cdn.alpinelinux.org'
|
||||
|
||||
@@ -30,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 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
|
||||
@@ -41,97 +34,40 @@ RUN apk add openssl-libs-static openssl-dev openssl
|
||||
RUN apk add libpng-dev libpng-static
|
||||
# curl c-ares dependencies
|
||||
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
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
COPY ac_override_1 /app/
|
||||
COPY ac_override_2 /app/
|
||||
COPY download.sh /app/
|
||||
COPY config.json /app/
|
||||
|
||||
RUN chmod +x /app/download.sh
|
||||
|
||||
RUN ./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}
|
||||
|
||||
RUN ./download.sh php ${USE_BACKUP} ${VER_PHP}
|
||||
|
||||
COPY extensions.txt /app/
|
||||
COPY check-extensions.sh /app/
|
||||
COPY compile-php.sh /app/
|
||||
|
||||
RUN chmod +x /app/download.sh && \
|
||||
chmod +x /app/compile-php.sh
|
||||
RUN chmod +x ./check-extensions.sh && \
|
||||
chmod +x ./compile-php.sh
|
||||
|
||||
RUN ./download.sh swoole ${USE_BACKUP} ${VER_SWOOLE}
|
||||
RUN ./download.sh hash ${USE_BACKUP} ${VER_HASH}
|
||||
RUN ./download.sh swoole ${USE_BACKUP} ${VER_SWOOLE}
|
||||
RUN ./download.sh swoole ${USE_BACKUP} ${VER_SWOOLE}
|
||||
RUN ./download.sh swoole ${USE_BACKUP} ${VER_SWOOLE}
|
||||
RUN ./download.sh swoole ${USE_BACKUP} ${VER_SWOOLE}
|
||||
RUN ./download.sh swoole ${USE_BACKUP} ${VER_SWOOLE}
|
||||
|
||||
RUN wget "http://mirrors.zhamao.xin/php/php-${VER_PHP}.tar.gz" -O php.tar.gz
|
||||
RUN wget "http://mirrors.zhamao.xin/pecl/swoole-${VER_SWOOLE}.tgz" -O swoole.tar.gz
|
||||
RUN wget "http://mirrors.zhamao.xin/pecl/hash-${VER_HASH}.tgz" -O hash.tar.gz
|
||||
RUN wget "http://mirrors.zhamao.xin/pecl/inotify-${VER_INOTIFY}.tgz" -O inotify.tar.gz
|
||||
RUN wget "http://mirrors.zhamao.xin/pecl/redis-${VER_REDIS}.tgz" -O redis.tar.gz
|
||||
RUN wget "https://dl.zhamao.me/libxml2/libxml2-${VER_LIBXML2}.tar.gz" -O libxml2.tar.gz
|
||||
RUN wget "https://dl.zhamao.me/liblzma/liblzma.tar.gz"
|
||||
RUN wget "https://dl.zhamao.me/curl/curl-${VER_CURL}.tar.gz" -O curl.tar.gz
|
||||
|
||||
RUN tar -xf php.tar.gz && \
|
||||
tar -xf swoole.tar.gz && \
|
||||
tar -xf hash.tar.gz && \
|
||||
tar -xf inotify.tar.gz && \
|
||||
tar -xf redis.tar.gz && \
|
||||
tar -xf libxml2.tar.gz && \
|
||||
tar -xf liblzma.tar.gz && \
|
||||
tar -xf curl.tar.gz
|
||||
|
||||
RUN cd liblzma && \
|
||||
./configure && \
|
||||
make -j4 && \
|
||||
make install && \
|
||||
echo "liblzma compiled!"
|
||||
|
||||
RUN cd "libxml2-${VER_LIBXML2}" && \
|
||||
./configure --with-lzma --without-python && \
|
||||
make -j4 && \
|
||||
make install && \
|
||||
echo "libxml2 compiled!"
|
||||
|
||||
RUN cd "curl-${VER_CURL}" && \
|
||||
CC=gcc CXX=g++ CFLAGS=-fPIC CPPFLAGS=-fPIC ./configure \
|
||||
--without-nghttp2 \
|
||||
--with-ssl=/usr \
|
||||
--with-pic=pic \
|
||||
--enable-ipv6 \
|
||||
--enable-shared=no \
|
||||
--without-libidn2 \
|
||||
--disable-ldap \
|
||||
--without-libpsl \
|
||||
--without-lber \
|
||||
--enable-ares && \
|
||||
make -j4 && \
|
||||
make install && \
|
||||
echo "curl compiled!"
|
||||
|
||||
COPY ac_override_1 /
|
||||
COPY ac_override_2 /
|
||||
COPY compile-php.sh /app/
|
||||
|
||||
RUN apk add bash
|
||||
|
||||
# copy
|
||||
RUN mv "swoole-${VER_SWOOLE}" "php-${VER_PHP}/ext/swoole" && \
|
||||
mv "redis-${VER_REDIS}" "php-${VER_PHP}/ext/redis" && \
|
||||
mv "inotify-${VER_INOTIFY}" "php-${VER_PHP}/ext/inotify"
|
||||
|
||||
RUN cat /ac_override_1 /app/php-${VER_PHP}/ext/curl/config.m4 /ac_override_2 > /app/aa
|
||||
RUN mv /app/aa /app/php-${VER_PHP}/ext/curl/config.m4
|
||||
|
||||
RUN cd "php-${VER_PHP}/ext/swoole/" && \
|
||||
./clear.sh && \
|
||||
cd ../../ && \
|
||||
./buildconf --force
|
||||
RUN ./check-extensions.sh check_before_configure
|
||||
|
||||
RUN ./compile-php.sh ${VER_PHP}
|
||||
|
||||
RUN cd "php-${VER_PHP}" && \
|
||||
sed -ie 's/-export-dynamic//g' "Makefile" && \
|
||||
sed -ie 's/-o \$(SAPI_CLI_PATH)/-all-static -o \$(SAPI_CLI_PATH)/g' "Makefile" && \
|
||||
sed -ie 's/swoole_clock_gettime(CLOCK_REALTIME/clock_gettime(CLOCK_REALTIME/g' "ext/swoole/include/swoole.h" && \
|
||||
make LDFLAGS=-ldl -j4 && \
|
||||
make install && \
|
||||
strip
|
||||
|
||||
|
||||
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
232
docker/check-extensions.sh
Executable file
232
docker/check-extensions.sh
Executable file
@@ -0,0 +1,232 @@
|
||||
#!/bin/sh
|
||||
|
||||
# Here are 3 steps in configuration of extensions
|
||||
# before_configure
|
||||
# in_configure
|
||||
# after_configure
|
||||
|
||||
self_dir=$(cd "$(dirname "$0")";pwd)
|
||||
php_dir=$(find $self_dir/source -name "php-*" -type d | tail -n1)
|
||||
|
||||
function do_xml_compiler() {
|
||||
cd $self_dir/source/liblzma-* && \
|
||||
./configure && \
|
||||
make -j4 && \
|
||||
make install && \
|
||||
echo "liblzma compiled!" && sleep 2s && \
|
||||
cd ../libxml2-* && \
|
||||
./configure --prefix=/usr --with-lzma --without-python && \
|
||||
make -j4 && \
|
||||
make install && \
|
||||
echo "libxml2 compiled!" && sleep 2s
|
||||
}
|
||||
|
||||
function do_curl_compiler() {
|
||||
cd $self_dir/source/curl-* && \
|
||||
CC=gcc CXX=g++ CFLAGS=-fPIC CPPFLAGS=-fPIC ./configure \
|
||||
--without-nghttp2 \
|
||||
--with-ssl=/usr \
|
||||
--with-pic=pic \
|
||||
--enable-ipv6 \
|
||||
--enable-shared=no \
|
||||
--without-libidn2 \
|
||||
--disable-ldap \
|
||||
--without-libpsl \
|
||||
--without-lber \
|
||||
--enable-ares && \
|
||||
make -j4 && \
|
||||
make install && \
|
||||
echo "curl compiled!" && \
|
||||
cat "$self_dir/ac_override_1" "$php_dir/ext/curl/config.m4" "$self_dir/ac_override_2" > /tmp/aa && \
|
||||
mv /tmp/aa "$php_dir/ext/curl/config.m4"
|
||||
}
|
||||
|
||||
function do_copy_extension() {
|
||||
ext_dir=$(find $self_dir/source -name "$1-*" -type d | tail -n1)
|
||||
mv $ext_dir $php_dir/ext/$1
|
||||
if [ $? != 0 ]; then
|
||||
echo "Compile error! ext: $1, ext_dir=$ext_dir"
|
||||
exit 1
|
||||
fi
|
||||
}
|
||||
|
||||
function check_before_configure() {
|
||||
list=$(cat "$self_dir/extensions.txt" | grep -v "^#" | grep -v "^$")
|
||||
xml_sign="no"
|
||||
for loop in $list
|
||||
do
|
||||
case $loop in
|
||||
bcmath) ;;
|
||||
calendar) ;;
|
||||
ctype) ;;
|
||||
filter) ;;
|
||||
gd) ;;
|
||||
hash) ;;
|
||||
iconv) ;;
|
||||
json) ;;
|
||||
mbstring) ;;
|
||||
mysqlnd) ;;
|
||||
openssl) ;;
|
||||
pcntl) ;;
|
||||
pdo) ;;
|
||||
pdo_mysql) ;;
|
||||
phar) ;;
|
||||
posix) ;;
|
||||
sockets) ;;
|
||||
sqlite3) ;;
|
||||
tokenizer) ;;
|
||||
zlib) ;;
|
||||
curl)
|
||||
do_curl_compiler
|
||||
if [ $? != 0 ]; then
|
||||
echo "Compile curl error!"
|
||||
exit 1
|
||||
fi
|
||||
;;
|
||||
dom|xml|libxml|xmlreader|xmlwriter|simplexml)
|
||||
if [ "$xml_sign" = "no" ]; then
|
||||
do_xml_compiler
|
||||
if [ $? != 0 ]; then
|
||||
echo "Compile curl error!"
|
||||
exit 1
|
||||
fi
|
||||
xml_sign="yes"
|
||||
fi
|
||||
;;
|
||||
inotify) do_copy_extension inotify ;;
|
||||
redis) do_copy_extension redis ;;
|
||||
swoole) do_copy_extension swoole ;;
|
||||
mongodb) do_copy_extension mongodb ;;
|
||||
event)
|
||||
PHP_EVENT=' PHP_EVENT_PHP_VERSION=$PHP_VERSION '
|
||||
PHP_EVENT="$PHP_EVENT"'\n PHP_EVENT_PHP_VERSION_ID=$PHP_VERSION_ID '
|
||||
PHP_EVENT="$PHP_EVENT"'\n if test -z "$PHP_EVENT_PHP_VERSION"; then '
|
||||
PHP_EVENT="$PHP_EVENT"'\n AC_MSG_ERROR(\[unknown source with no php version\]) '
|
||||
PHP_EVENT="$PHP_EVENT"'\n PHP_EVENT_SUBDIR="." '
|
||||
PHP_EVENT="$PHP_EVENT"'\n fi '
|
||||
PHP_EVENT="$PHP_EVENT"'\n if test "$PHP_EVENT_PHP_VERSION_ID" -ge "80000"; then '
|
||||
PHP_EVENT="$PHP_EVENT"'\n PHP_EVENT_SUBDIR=php8 '
|
||||
PHP_EVENT="$PHP_EVENT"'\n AC_MSG_RESULT(\[PHP 8.x\]) '
|
||||
PHP_EVENT="$PHP_EVENT"'\n elif test "$PHP_EVENT_PHP_VERSION_ID" -ge "70000"; then '
|
||||
PHP_EVENT="$PHP_EVENT"'\n PHP_EVENT_SUBDIR=php7 '
|
||||
PHP_EVENT="$PHP_EVENT"'\n AC_MSG_RESULT(\[PHP 7.x\]) '
|
||||
PHP_EVENT="$PHP_EVENT"'\n elif test "$PHP_EVENT_PHP_VERSION_ID" -ge "50000"; then '
|
||||
PHP_EVENT="$PHP_EVENT"'\n PHP_EVENT_SUBDIR=php5 '
|
||||
PHP_EVENT="$PHP_EVENT"'\n AC_MSG_RESULT(\[PHP 5.x\]) '
|
||||
PHP_EVENT="$PHP_EVENT"'\n else '
|
||||
PHP_EVENT="$PHP_EVENT"'\n AC_MSG_ERROR(\[unknown source lol\]) '
|
||||
PHP_EVENT="$PHP_EVENT"'\n PHP_EVENT_SUBDIR="." '
|
||||
PHP_EVENT="$PHP_EVENT"'\n fi '
|
||||
PHP_EVENT="$PHP_EVENT"'\n echo PHP_EXT_SRCDIR(event)\/$PHP_EVENT_SUBDIR '
|
||||
PHP_EVENT="$PHP_EVENT"'\n echo PHP_EXT_BUILDDIR(event)\/$PHP_EVENT_SUBDIR '
|
||||
PHP_EVENT="$PHP_EVENT"'\n if test "$PHP_EVENT_SUBDIR" -ne "."; then '
|
||||
PHP_EVENT="$PHP_EVENT"'\n PHP_ADD_BUILD_DIR(PHP_EXT_SRCDIR(event)\/$PHP_EVENT_SUBDIR, 1) '
|
||||
PHP_EVENT="$PHP_EVENT"'\n PHP_ADD_BUILD_DIR(PHP_EXT_SRCDIR(event)\/$PHP_EVENT_SUBDIR\/classes, 1) '
|
||||
PHP_EVENT="$PHP_EVENT"'\n PHP_ADD_BUILD_DIR(PHP_EXT_SRCDIR(event)\/$PHP_EVENT_SUBDIR\/src, 1) '
|
||||
PHP_EVENT="$PHP_EVENT"'\n PHP_ADD_INCLUDE(PHP_EXT_SRCDIR(event)\/\[$PHP_EVENT_SUBDIR\]) '
|
||||
PHP_EVENT="$PHP_EVENT"'\n PHP_ADD_INCLUDE(PHP_EXT_SRCDIR(event)\/\[$PHP_EVENT_SUBDIR\/classes\]) '
|
||||
PHP_EVENT="$PHP_EVENT"'\n PHP_ADD_INCLUDE(PHP_EXT_SRCDIR(event)\/\[$PHP_EVENT_SUBDIR\/src\]) '
|
||||
PHP_EVENT="$PHP_EVENT"'\n fi '
|
||||
|
||||
do_copy_extension event && \
|
||||
sed -ie 's/PHP_EVENT_SUBDIR="."//g' $php_dir/ext/event/config.m4 && \
|
||||
sed -ie 's/AC_MSG_ERROR(\[unknown source\])/'"$PHP_EVENT"'/g' $php_dir/ext/event/config.m4
|
||||
if [ $? != 0 ]; then
|
||||
exit 1
|
||||
fi
|
||||
;;
|
||||
esac
|
||||
done
|
||||
}
|
||||
|
||||
function check_in_configure() {
|
||||
php_configure=""
|
||||
list=$(cat "$self_dir/extensions.txt" | sed 's/#.*//g' | sed -e 's/[ ]*$//g' | grep -v "^\s*$")
|
||||
for loop in $list
|
||||
do
|
||||
case $loop in
|
||||
bcmath) php_configure="$php_configure --enable-bcmath" ;;
|
||||
calendar) php_configure="$php_configure --enable-calendar" ;;
|
||||
ctype) php_configure="$php_configure --enable-ctype" ;;
|
||||
curl) php_configure="$php_configure --with-curl" ;;
|
||||
dom) php_configure="$php_configure --enable-dom" ;;
|
||||
event) php_configure="$php_configure --with-event-core --with-event-extra --with-event-openssl --with-event-extra --disable-event-sockets" ;;
|
||||
filter) php_configure="$php_configure --enable-filter" ;;
|
||||
gd)
|
||||
case $1 in
|
||||
7.3.*|7.2.*) php_configure="$php_configure --with-gd" ;;
|
||||
7.4.*|8.*) php_configure="$php_configure --enable-gd" ;;
|
||||
esac
|
||||
;;
|
||||
hash)
|
||||
case $1 in
|
||||
7.3.*|7.2.*) php_configure="$php_configure --enable-hash" ;;
|
||||
esac
|
||||
;;
|
||||
iconv) php_configure="$php_configure --with-iconv" ;;
|
||||
inotify) php_configure="$php_configure --enable-inotify" ;;
|
||||
json)
|
||||
case $1 in
|
||||
7.*) php_configure="$php_configure --enable-json" ;;
|
||||
esac
|
||||
;;
|
||||
libxml)
|
||||
case $1 in
|
||||
7.3.*|7.2.*) php_configure="$php_configure --enable-libxml" ;;
|
||||
7.4.*|8.*) php_configure="$php_configure --with-libxml" ;;
|
||||
esac
|
||||
;;
|
||||
mbstring) php_configure="$php_configure --enable-mbstring" ;;
|
||||
mongodb) php_configure="$php_configure --enable-mongodb" ;;
|
||||
mysqlnd) php_configure="$php_configure --enable-mysqlnd" ;;
|
||||
openssl) php_configure="$php_configure --with-openssl --with-openssl-dir=/usr" ;;
|
||||
pcntl) php_configure="$php_configure --enable-pcntl" ;;
|
||||
pdo) php_configure="$php_configure --enable-pdo" ;;
|
||||
pdo_mysql) php_configure="$php_configure --with-pdo-mysql=mysqlnd" ;;
|
||||
phar) php_configure="$php_configure --enable-phar" ;;
|
||||
posix) php_configure="$php_configure --enable-posix" ;;
|
||||
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)
|
||||
if [ "$have_openssl" != "" ]; then
|
||||
php_configure="$php_configure --enable-openssl --with-openssl --with-openssl-dir=/usr"
|
||||
fi
|
||||
have_hash=$(echo $list | grep hash)
|
||||
if [ "$have_hash" = "" ]; then
|
||||
case $1 in
|
||||
7.3.*|7.2.*) php_configure="$php_configure --enable-hash" ;;
|
||||
esac
|
||||
fi
|
||||
;;
|
||||
tokenizer) php_configure="$php_configure --enable-tokenizer" ;;
|
||||
xml) php_configure="$php_configure --enable-xml" ;;
|
||||
xmlreader) php_configure="$php_configure --enable-xmlreader" ;;
|
||||
xmlwriter) php_configure="$php_configure --enable-xmlwriter" ;;
|
||||
zlib) php_configure="$php_configure --with-zlib" ;;
|
||||
*)
|
||||
echo "Unsupported extension '$loop' !" >&2
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
done
|
||||
echo $php_configure
|
||||
}
|
||||
|
||||
function check_after_configure() {
|
||||
list=$(cat "$self_dir/extensions.txt" | grep -v "^#" | grep -v "^$")
|
||||
for loop in $list
|
||||
do
|
||||
case $loop in
|
||||
swoole)
|
||||
sed -ie 's/swoole_clock_gettime(CLOCK_REALTIME/clock_gettime(CLOCK_REALTIME/g' "$php_dir/ext/swoole/include/swoole.h"
|
||||
;;
|
||||
esac
|
||||
done
|
||||
}
|
||||
|
||||
$1 $2
|
||||
77
docker/compile-php.sh
Normal file → Executable file
77
docker/compile-php.sh
Normal file → Executable file
@@ -2,86 +2,31 @@
|
||||
|
||||
VER_PHP="$1"
|
||||
|
||||
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"
|
||||
_php_arg="$_php_arg --enable-inline-optimization"
|
||||
_php_arg="$_php_arg --with-layout=GNU"
|
||||
_php_arg="$_php_arg --enable-calendar"
|
||||
_php_arg="$_php_arg --enable-ctype"
|
||||
_php_arg="$_php_arg --enable-filter"
|
||||
_php_arg="$_php_arg --enable-openssl"
|
||||
_php_arg="$_php_arg --enable-bcmath"
|
||||
_php_arg="$_php_arg --enable-pcntl"
|
||||
_php_arg="$_php_arg --enable-openssl"
|
||||
_php_arg="$_php_arg --with-openssl"
|
||||
_php_arg="$_php_arg --with-iconv"
|
||||
_php_arg="$_php_arg --enable-mbstring"
|
||||
_php_arg="$_php_arg --enable-phar"
|
||||
_php_arg="$_php_arg --enable-pdo"
|
||||
_php_arg="$_php_arg --with-pdo-mysql=mysqlnd"
|
||||
_php_arg="$_php_arg --enable-sockets"
|
||||
_php_arg="$_php_arg --enable-swoole"
|
||||
_php_arg="$_php_arg --enable-inotify"
|
||||
_php_arg="$_php_arg --enable-redis"
|
||||
_php_arg="$_php_arg --disable-redis-session"
|
||||
_php_arg="$_php_arg --enable-simplexml"
|
||||
_php_arg="$_php_arg --enable-dom"
|
||||
_php_arg="$_php_arg --enable-xml"
|
||||
_php_arg="$_php_arg --enable-xmlwriter"
|
||||
_php_arg="$_php_arg --enable-xmlreader"
|
||||
_php_arg="$_php_arg --with-zlib"
|
||||
_php_arg="$_php_arg --enable-posix"
|
||||
_php_arg="$_php_arg --enable-mysqlnd"
|
||||
_php_arg="$_php_arg --enable-tokenizer"
|
||||
_php_arg="$_php_arg --with-curl"
|
||||
_php_arg="$_php_arg --with-pear=no"
|
||||
_php_arg="$_php_arg --disable-cgi"
|
||||
_php_arg="$_php_arg --disable-phpdbg"
|
||||
|
||||
for loop in $(cat extension.txt)
|
||||
do
|
||||
case $loop in
|
||||
swoole)
|
||||
esac
|
||||
done
|
||||
|
||||
case $1 in
|
||||
7.3.*|7.2.*)
|
||||
_php_arg="$_php_arg --with-gd"
|
||||
_php_arg="$_php_arg --enable-libxml"
|
||||
_php_arg="$_php_arg --enable-hash"
|
||||
_php_arg="$_php_arg --enable-json"
|
||||
;;
|
||||
7.4.*)
|
||||
_php_arg="$_php_arg --enable-gd"
|
||||
_php_arg="$_php_arg --with-libxml"
|
||||
_php_arg="$_php_arg --enable-json"
|
||||
;;
|
||||
8.*)
|
||||
_php_arg="$_php_arg --enable-gd"
|
||||
_php_arg="$_php_arg --with-libxml"
|
||||
;;
|
||||
esac
|
||||
_php_arg="$_php_arg $($self_dir/check-extensions.sh check_in_configure $1)"
|
||||
echo $_php_arg
|
||||
}
|
||||
|
||||
function before_configure() {
|
||||
for loop in $(cat extension.txt)
|
||||
do
|
||||
case $loop in
|
||||
swoole)
|
||||
esac
|
||||
done
|
||||
}
|
||||
php_compile_args && sleep 1s
|
||||
|
||||
cd php-$VER_PHP && \
|
||||
before_configure && \
|
||||
cd $php_dir && \
|
||||
./buildconf --force && \
|
||||
./configure LDFLAGS=-static $(php_compile_args $VER_PHP) && \
|
||||
after_configure && \
|
||||
$self_dir/check-extensions.sh check_after_configure && \
|
||||
sed -ie 's/-export-dynamic//g' "Makefile" && \
|
||||
sed -ie 's/-o $(SAPI_CLI_PATH)/-all-static -o $(SAPI_CLI_PATH)/g' "Makefile" && \
|
||||
if [ "$(cat extension.txt | grep swoole)" != "" ]; then sed -ie 's/swoole_clock_gettime(CLOCK_REALTIME/clock_gettime(CLOCK_REALTIME/g' "ext/swoole/include/swoole.h" && \
|
||||
make LDFLAGS=-ldl -j4 && \
|
||||
make install && \
|
||||
strip $self_dir/php-dist/bin/php
|
||||
49
docker/config.json
Normal file → Executable file
49
docker/config.json
Normal file → Executable file
@@ -1,3 +1,46 @@
|
||||
swoole
|
||||
redis
|
||||
hello
|
||||
{
|
||||
"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"
|
||||
},
|
||||
"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"
|
||||
}
|
||||
}
|
||||
152
docker/download.sh
Normal file → Executable file
152
docker/download.sh
Normal file → Executable file
@@ -2,108 +2,58 @@
|
||||
|
||||
_use_backup="$2"
|
||||
|
||||
function download_file() {
|
||||
downloader="wget"
|
||||
type wget >/dev/null 2>&1 || { downloader="curl"; }
|
||||
if [ "$downloader" = "wget" ]; then
|
||||
_down_prefix="O"
|
||||
else
|
||||
_down_prefix="o"
|
||||
fi
|
||||
_down_symbol=0
|
||||
if [ ! -f "$2" ]; then
|
||||
$downloader "$1" -$_down_prefix "$2" >/dev/null 2>&1 && \
|
||||
echo "$1 完成! $2" && _down_symbol=1
|
||||
else
|
||||
echo "$2 已存在!" && _down_symbol=1
|
||||
fi
|
||||
if [ $_down_symbol == 0 ]; then
|
||||
echo "下载 $1 失败!请检查网络连接!"
|
||||
rm -rf "$2"
|
||||
return 1
|
||||
fi
|
||||
return 0
|
||||
SELF_DIR=$(cd "$(dirname "$0")";pwd)
|
||||
|
||||
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'
|
||||
}
|
||||
|
||||
function lib_download_link() {
|
||||
if [ "$_use_backup" = "yes" ]; then
|
||||
case $1 in
|
||||
"php") echo "https://www.php.net/distributions/php-$2.tar.gz" ;;
|
||||
"swoole") echo "https://pecl.php.net/get/swoole-$2.tgz" ;;
|
||||
"hash") echo "https://pecl.php.net/get/hash-$2.tgz" ;;
|
||||
"inotify") echo "https://pecl.php.net/get/inotify-$2.tgz" ;;
|
||||
"redis") echo "https://pecl.php.net/get/redis-$2.tgz" ;;
|
||||
"libxml2") echo "http://xmlsoft.org/sources/libxml2-$2.tar.gz" ;;
|
||||
"liblzma") echo "https://github.com/kobolabs/liblzma/archive/refs/heads/master.zip" ;;
|
||||
"curl") echo "https://curl.haxx.se/download/curl-$2.tar.gz" ;;
|
||||
*) echo "unknown" ;;
|
||||
esac
|
||||
else
|
||||
case $1 in
|
||||
"php") echo "http://mirrors.zhamao.xin/php/php-$2.tar.gz" ;;
|
||||
"swoole") echo "http://mirrors.zhamao.xin/pecl/swoole-$2.tgz" ;;
|
||||
"hash") echo "http://mirrors.zhamao.xin/pecl/hash-$2.tgz" ;;
|
||||
"inotify") echo "http://mirrors.zhamao.xin/pecl/inotify-$2.tgz" ;;
|
||||
"redis") echo "http://mirrors.zhamao.xin/pecl/redis-$2.tgz" ;;
|
||||
"libxml2") echo "https://dl.zhamao.me/libxml2/libxml2-$2.tar.gz" ;;
|
||||
"liblzma") echo "https://dl.zhamao.me/liblzma/liblzma.tar.gz" ;;
|
||||
"curl") echo "https://dl.zhamao.me/curl/curl-$2.tar.gz" ;;
|
||||
*) echo "unknown" ;;
|
||||
esac
|
||||
cd source
|
||||
|
||||
if [ "$_use_backup" = "yes" ]; then
|
||||
_use_backup="_2"
|
||||
else
|
||||
_use_backup=""
|
||||
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 [ "$archive_find_tar" != "" ]; then
|
||||
echo "Using cache for $1 ($archive_find_tar)"
|
||||
tar -zxvf "$archive_find_tar"
|
||||
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 "Downloading"
|
||||
wget -q --show-progress "$(readconf ".$1.link$_use_backup" | sed 's/{version}/'$(readconf ".$1.version")'/g')"
|
||||
fi
|
||||
}
|
||||
|
||||
function lib_x_cmd() {
|
||||
case $1 in
|
||||
"php"|"swoole"|"hash"|"inotify"|"redis"|"libxml2"|"curl")
|
||||
_x_cmd="tar"
|
||||
;;
|
||||
"liblzma") if [ "$_use_backup" = "yes" ]; then _x_cmd="unzip"; else _x_cmd="tar"; fi ;;
|
||||
*) _x_cmd="unknown" ;;
|
||||
esac
|
||||
case $2 in
|
||||
"cmd")
|
||||
echo $_x_cmd
|
||||
;;
|
||||
"file-prefix")
|
||||
case $_x_cmd in
|
||||
"tar") echo "-zxvf" ;;
|
||||
"unzip") echo "" ;;
|
||||
esac
|
||||
;;
|
||||
"out-prefix")
|
||||
case $_x_cmd in
|
||||
"tar") echo "-C" ;;
|
||||
"unzip") echo "-d" ;;
|
||||
esac
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
function lib_x() {
|
||||
$(lib_x_cmd $1 cmd) $(lib_x_cmd $1 file-prefix) "$_source_dir/$(lib_x_dirname $1 file)" $(lib_x_cmd $1 out-prefix) "$_source_dir/"
|
||||
}
|
||||
|
||||
# 获取解压后的源码根目录
|
||||
function lib_x_dirname() {
|
||||
case $1 in
|
||||
"php"|"swoole"|"hash"|"inotify"|"redis"|"libxml2"|"curl")
|
||||
if [ "$2" = "file" ]; then _name_prefix=".tar.gz"; else _name_prefix=""; fi
|
||||
echo "$1-$(lib_ver $1)$_name_prefix"
|
||||
;;
|
||||
"liblzma")
|
||||
if [ "$_use_backup" = "yes" ]; then
|
||||
if [ "$2" = "file" ]; then _name_prefix=".zip"; else _name_prefix=""; fi
|
||||
echo "$1-$(lib_ver $1)$_name_prefix"
|
||||
else
|
||||
if [ "$2" = "file" ]; then _name_prefix=".tar.gz"; else _name_prefix=""; fi
|
||||
echo "$1""$_name_prefix"
|
||||
fi
|
||||
;;
|
||||
*)
|
||||
echo "unknown"
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
download_file $(lib_download_link $1 $3) $(lib_x_firname $1 file)
|
||||
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
|
||||
fi
|
||||
31
docker/extensions.txt
Executable file
31
docker/extensions.txt
Executable file
@@ -0,0 +1,31 @@
|
||||
bcmath
|
||||
calendar
|
||||
ctype
|
||||
curl
|
||||
dom
|
||||
filter
|
||||
gd
|
||||
hash
|
||||
iconv
|
||||
inotify
|
||||
json
|
||||
libxml
|
||||
mbstring
|
||||
#mongodb
|
||||
mysqlnd
|
||||
openssl
|
||||
pcntl
|
||||
pdo
|
||||
pdo_mysql
|
||||
phar
|
||||
posix
|
||||
redis
|
||||
simplexml
|
||||
sockets
|
||||
sqlite3
|
||||
swoole
|
||||
tokenizer
|
||||
xml
|
||||
xmlreader
|
||||
xmlwriter
|
||||
zlib
|
||||
50
docker/fast-compiler.sh
Executable file
50
docker/fast-compiler.sh
Executable file
@@ -0,0 +1,50 @@
|
||||
#!/bin/sh
|
||||
|
||||
# This script needs alpine linux system.
|
||||
|
||||
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}
|
||||
|
||||
66
docker/multi-version-compiler.sh
Executable file
66
docker/multi-version-compiler.sh
Executable file
@@ -0,0 +1,66 @@
|
||||
#!/bin/sh
|
||||
|
||||
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}
|
||||
|
||||
if [ ! -d "multi-build" ]; then
|
||||
mkdir ./multi-build
|
||||
fi
|
||||
|
||||
for VER_PHP in "7.2.34" "7.3.29" "7.4.21" "8.0.8"
|
||||
do
|
||||
./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} && \
|
||||
cp ./php-dist/bin/php ./multi-build/php-${VER_PHP} && \
|
||||
rm -rf ./source
|
||||
done
|
||||
|
||||
|
||||
@@ -1,23 +0,0 @@
|
||||
#!/bin/sh
|
||||
|
||||
_main_dir="$(pwd)/"
|
||||
|
||||
_build_dir="$_main_dir/build"
|
||||
|
||||
mkdir "$_build_dir" > /dev/null 2>&1
|
||||
|
||||
for loop in "7.2.34" "7.3.28" "7.4.19" "8.0.6"
|
||||
do
|
||||
sed -i 's/phpver"|"php") echo ".*/phpver"|"php") echo "'$loop'" ;;/g' "$_main_dir""static-compile-php.sh" && \
|
||||
rm -rf "$_main_dir""source/php.tar.gz" "$_main_dir""source/php-*" "$_main_dir""php-dist" && \
|
||||
"$_main_dir""static-compile-php.sh" && \
|
||||
cp "$_main_dir""php-dist/bin/php" "$_build_dir/" && \
|
||||
cd "$_build_dir/" && \
|
||||
tar -zcvf "php-$loop-static-bin-"$(uname -m)".tar.gz" "./php" && \
|
||||
mv "./php" "./php-$loop" && \
|
||||
cd "$_main_dir"
|
||||
if [ $? -ne 0 ]; then
|
||||
echo "Compile static php-$loop failed!"
|
||||
exit 1
|
||||
fi
|
||||
done
|
||||
@@ -1,332 +0,0 @@
|
||||
#!/bin/sh
|
||||
|
||||
_script_ver="1.2.1"
|
||||
_use_backup="no"
|
||||
|
||||
_home_dir=$(pwd)"/"
|
||||
_source_dir="$_home_dir""source"
|
||||
_opt_dir="$_home_dir""opt"
|
||||
|
||||
function download_file() {
|
||||
downloader="wget"
|
||||
type wget >/dev/null 2>&1 || { downloader="curl"; }
|
||||
if [ "$downloader" = "wget" ]; then
|
||||
_down_prefix="O"
|
||||
else
|
||||
_down_prefix="o"
|
||||
fi
|
||||
_down_symbol=0
|
||||
if [ ! -f "$2" ]; then
|
||||
$downloader "$1" -$_down_prefix "$2" >/dev/null 2>&1 && \
|
||||
echo "$1 完成! $2" && _down_symbol=1
|
||||
else
|
||||
echo "$2 已存在!" && _down_symbol=1
|
||||
fi
|
||||
if [ $_down_symbol == 0 ]; then
|
||||
echo "下载 $1 失败!请检查网络连接!"
|
||||
rm -rf "$2"
|
||||
return 1
|
||||
fi
|
||||
return 0
|
||||
}
|
||||
|
||||
# 获取要下载的源码的版本号
|
||||
function lib_ver() {
|
||||
case $1 in
|
||||
"phpver"|"php") echo "7.3.28" ;;
|
||||
"swoole") echo "4.6.7" ;;
|
||||
"hash") echo "1.5" ;;
|
||||
"inotify") echo "3.0.0" ;;
|
||||
"redis") echo "5.3.4" ;;
|
||||
"libxml2") echo "2.9.10" ;;
|
||||
"curl") echo "7.76.1" ;;
|
||||
"liblzma") echo "master" ;;
|
||||
*) echo "unknown" ;;
|
||||
esac
|
||||
}
|
||||
|
||||
# 获取解压后的源码根目录
|
||||
function lib_x_dirname() {
|
||||
case $1 in
|
||||
"php"|"swoole"|"hash"|"inotify"|"redis"|"libxml2"|"curl")
|
||||
if [ "$2" = "file" ]; then _name_prefix=".tar.gz"; else _name_prefix=""; fi
|
||||
echo "$1-$(lib_ver $1)$_name_prefix"
|
||||
;;
|
||||
"liblzma")
|
||||
if [ "$_use_backup" = "yes" ]; then
|
||||
if [ "$2" = "file" ]; then _name_prefix=".zip"; else _name_prefix=""; fi
|
||||
echo "$1-$(lib_ver $1)$_name_prefix"
|
||||
else
|
||||
if [ "$2" = "file" ]; then _name_prefix=".tar.gz"; else _name_prefix=""; fi
|
||||
echo "$1""$_name_prefix"
|
||||
fi
|
||||
;;
|
||||
*)
|
||||
echo "unknown"
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
# 获取要下载的源码的链接地址
|
||||
function lib_download_link() {
|
||||
if [ "$_use_backup" = "yes" ]; then
|
||||
case $1 in
|
||||
"php") echo "https://www.php.net/distributions/php-$(lib_ver $1).tar.gz" ;;
|
||||
"swoole") echo "https://pecl.php.net/get/swoole-$(lib_ver $1).tgz" ;;
|
||||
"hash") echo "https://pecl.php.net/get/hash-$(lib_ver $1).tgz" ;;
|
||||
"inotify") echo "https://pecl.php.net/get/inotify-$(lib_ver $1).tgz" ;;
|
||||
"redis") echo "https://pecl.php.net/get/redis-$(lib_ver $1).tgz" ;;
|
||||
"libxml2") echo "http://xmlsoft.org/sources//libxml2-$(lib_ver $1).tar.gz" ;;
|
||||
"liblzma") echo "https://github.com/kobolabs/liblzma/archive/refs/heads/master.zip" ;;
|
||||
"curl") echo "https://curl.haxx.se/download/curl-$(lib_ver $1).tar.gz" ;;
|
||||
*) echo "unknown" ;;
|
||||
esac
|
||||
else
|
||||
case $1 in
|
||||
"php") echo "http://mirrors.zhamao.xin/php/php-$(lib_ver $1).tar.gz" ;;
|
||||
"swoole") echo "http://mirrors.zhamao.xin/pecl/swoole-$(lib_ver $1).tgz" ;;
|
||||
"hash") echo "http://mirrors.zhamao.xin/pecl/hash-$(lib_ver $1).tgz" ;;
|
||||
"inotify") echo "http://mirrors.zhamao.xin/pecl/inotify-$(lib_ver $1).tgz" ;;
|
||||
"redis") echo "http://mirrors.zhamao.xin/pecl/redis-$(lib_ver $1).tgz" ;;
|
||||
"libxml2") echo "https://dl.zhamao.me/libxml2/libxml2-$(lib_ver $1).tar.gz" ;;
|
||||
"liblzma") echo "https://dl.zhamao.me/liblzma/liblzma.tar.gz" ;;
|
||||
"curl") echo "https://dl.zhamao.me/curl/curl-$(lib_ver $1).tar.gz" ;;
|
||||
*) echo "unknown" ;;
|
||||
esac
|
||||
fi
|
||||
}
|
||||
|
||||
# 获取下载后源码包的解压命令
|
||||
function lib_x_cmd() {
|
||||
case $1 in
|
||||
"php"|"swoole"|"hash"|"inotify"|"redis"|"libxml2"|"curl")
|
||||
_x_cmd="tar"
|
||||
;;
|
||||
"liblzma") if [ "$_use_backup" = "yes" ]; then _x_cmd="unzip"; else _x_cmd="tar"; fi ;;
|
||||
*) _x_cmd="unknown" ;;
|
||||
esac
|
||||
case $2 in
|
||||
"cmd")
|
||||
echo $_x_cmd
|
||||
;;
|
||||
"file-prefix")
|
||||
case $_x_cmd in
|
||||
"tar") echo "-xf" ;;
|
||||
"unzip") echo "" ;;
|
||||
esac
|
||||
;;
|
||||
"out-prefix")
|
||||
case $_x_cmd in
|
||||
"tar") echo "-C" ;;
|
||||
"unzip") echo "-d" ;;
|
||||
esac
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
_curl_override_1='
|
||||
AC_DEFUN([PHP_CHECK_LIBRARY], [
|
||||
$3
|
||||
])
|
||||
'
|
||||
|
||||
_curl_override_2='
|
||||
AC_DEFUN([PHP_CHECK_LIBRARY], [
|
||||
save_old_LDFLAGS=$LDFLAGS
|
||||
ac_stuff="$5"
|
||||
|
||||
save_ext_shared=$ext_shared
|
||||
ext_shared=yes
|
||||
PHP_EVAL_LIBLINE([$]ac_stuff, LDFLAGS)
|
||||
AC_CHECK_LIB([$1],[$2],[
|
||||
LDFLAGS=$save_old_LDFLAGS
|
||||
ext_shared=$save_ext_shared
|
||||
$3
|
||||
],[
|
||||
LDFLAGS=$save_old_LDFLAGS
|
||||
ext_shared=$save_ext_shared
|
||||
unset ac_cv_lib_$1[]_$2
|
||||
$4
|
||||
])dnl
|
||||
])
|
||||
'
|
||||
|
||||
function lib_x() {
|
||||
$(lib_x_cmd $1 cmd) $(lib_x_cmd $1 file-prefix) "$_source_dir/$(lib_x_dirname $1 file)" $(lib_x_cmd $1 out-prefix) "$_source_dir/"
|
||||
}
|
||||
|
||||
function lib_move_ext() {
|
||||
_src_dir="$_source_dir/$(lib_x_dirname $1)"
|
||||
_dst_dir="$_source_dir/$(lib_x_dirname php)/ext/$1"
|
||||
mv $_src_dir $_dst_dir
|
||||
}
|
||||
|
||||
function download_all() {
|
||||
mkdir "$_source_dir" > /dev/null 2>&1
|
||||
|
||||
for loop in "php" "swoole" "inotify" "hash" "redis" "libxml2" "liblzma" "curl"
|
||||
do
|
||||
echo "正在下载 $loop 源码 ..."
|
||||
download_file $(lib_download_link $loop) "$_source_dir/$(lib_x_dirname $loop file)" || { exit 1; } &
|
||||
done
|
||||
|
||||
wait
|
||||
}
|
||||
|
||||
function compile_liblzma() {
|
||||
if [ -f "$_opt_dir/liblzma/lib/liblzma.so" ]; then
|
||||
echo "已编译 liblzma!" && return
|
||||
fi
|
||||
tar -xf "$_source_dir/$(lib_x_dirname liblzma file)" -C "$_source_dir/" && \
|
||||
cd "$_source_dir/$(lib_x_dirname liblzma)" && \
|
||||
./configure --prefix="$_opt_dir/liblzma" && \
|
||||
make -j4 && \
|
||||
make install && \
|
||||
echo "编译 liblzma 完成!"
|
||||
}
|
||||
|
||||
function compile_curl() {
|
||||
if [ -f "$_opt_dir/curl/bin/curl" ]; then
|
||||
echo "已编译 curl!" && return
|
||||
fi
|
||||
lib_x curl && \
|
||||
cd "$_source_dir/$(lib_x_dirname curl)" && \
|
||||
CC=gcc CXX=g++ CFLAGS=-fPIC CPPFLAGS=-fPIC ./configure --prefix="$_opt_dir/curl" \
|
||||
--without-nghttp2 \
|
||||
--with-ssl=/usr \
|
||||
--with-pic=pic \
|
||||
--enable-ipv6 \
|
||||
--enable-shared=no \
|
||||
--without-libidn2 \
|
||||
--disable-ldap \
|
||||
--without-libpsl \
|
||||
--without-lber \
|
||||
--enable-ares && \
|
||||
make -j4 && \
|
||||
make install && \
|
||||
echo "编译 curl 完成!"
|
||||
}
|
||||
|
||||
function compile_libxml2() {
|
||||
if [ -f "$_opt_dir/libxml2/lib/libxml2.so" ]; then
|
||||
echo "已编译 libxml2!" && return
|
||||
fi
|
||||
lib_x libxml2 && \
|
||||
cd "$_source_dir/$(lib_x_dirname libxml2)" && \
|
||||
./configure --with-lzma="$_opt_dir/liblzma" --prefix="$_opt_dir/libxml2" --exec-prefix="$_opt_dir/libxml2" --without-python && \
|
||||
make -j4 && \
|
||||
make install && \
|
||||
echo "编译 libxml2 完成!"
|
||||
}
|
||||
|
||||
function php_get_configure_args() {
|
||||
_php_arg="--prefix=$_home_dir""php-dist"
|
||||
_php_arg="$_php_arg --disable-all"
|
||||
_php_arg="$_php_arg --enable-shared=no"
|
||||
_php_arg="$_php_arg --enable-static=yes"
|
||||
_php_arg="$_php_arg --enable-inline-optimization"
|
||||
_php_arg="$_php_arg --with-layout=GNU"
|
||||
_php_arg="$_php_arg --enable-calendar"
|
||||
_php_arg="$_php_arg --enable-ctype"
|
||||
_php_arg="$_php_arg --enable-filter"
|
||||
_php_arg="$_php_arg --enable-openssl"
|
||||
_php_arg="$_php_arg --enable-bcmath"
|
||||
_php_arg="$_php_arg --with-openssl-dir=/usr"
|
||||
_php_arg="$_php_arg --enable-pcntl"
|
||||
_php_arg="$_php_arg --enable-openssl"
|
||||
_php_arg="$_php_arg --with-openssl"
|
||||
_php_arg="$_php_arg --with-iconv"
|
||||
_php_arg="$_php_arg --enable-json"
|
||||
_php_arg="$_php_arg --enable-mbstring"
|
||||
_php_arg="$_php_arg --enable-phar"
|
||||
_php_arg="$_php_arg --enable-pdo"
|
||||
_php_arg="$_php_arg --with-pdo-mysql=mysqlnd"
|
||||
_php_arg="$_php_arg --enable-sockets"
|
||||
_php_arg="$_php_arg --enable-swoole"
|
||||
_php_arg="$_php_arg --enable-inotify"
|
||||
_php_arg="$_php_arg --enable-redis"
|
||||
_php_arg="$_php_arg --disable-redis-session"
|
||||
_php_arg="$_php_arg --enable-simplexml"
|
||||
_php_arg="$_php_arg --enable-dom"
|
||||
_php_arg="$_php_arg --enable-xml"
|
||||
_php_arg="$_php_arg --enable-xmlwriter"
|
||||
_php_arg="$_php_arg --enable-xmlreader"
|
||||
_php_arg="$_php_arg --with-zlib"
|
||||
_php_arg="$_php_arg --enable-posix"
|
||||
_php_arg="$_php_arg --enable-mysqlnd"
|
||||
_php_arg="$_php_arg --enable-tokenizer"
|
||||
_php_arg="$_php_arg --with-curl"
|
||||
_php_arg="$_php_arg --with-pear=no"
|
||||
_php_arg="$_php_arg --disable-cgi"
|
||||
_php_arg="$_php_arg --disable-phpdbg"
|
||||
|
||||
case $(lib_ver php) in
|
||||
7.3.*|7.2.*)
|
||||
_php_arg="$_php_arg --with-gd"
|
||||
_php_arg="$_php_arg --enable-libxml"
|
||||
_php_arg="$_php_arg --with-libxml-dir=$_opt_dir/libxml2"
|
||||
_php_arg="$_php_arg --enable-hash"
|
||||
;;
|
||||
*)
|
||||
_php_arg="$_php_arg --enable-gd"
|
||||
_php_arg="$_php_arg --with-libxml"
|
||||
;;
|
||||
esac
|
||||
echo $_php_arg
|
||||
}
|
||||
|
||||
function compile_php() {
|
||||
echo "正在编译 php ..." && \
|
||||
rm -rf "$_source_dir/$(lib_x_dirname php)" && \
|
||||
lib_x php && \
|
||||
lib_x swoole && \
|
||||
lib_move_ext swoole && \
|
||||
"$_source_dir/$(lib_x_dirname php)/ext/swoole/clear.sh" && \
|
||||
lib_x redis && \
|
||||
lib_move_ext redis && \
|
||||
lib_x inotify && \
|
||||
lib_move_ext inotify && \
|
||||
cd "$_source_dir/$(lib_x_dirname php)/" && \
|
||||
echo "$_curl_override_1" > "$_home_dir""ac_override_1" && \
|
||||
echo "$_curl_override_2" > "$_home_dir""ac_override_2" && \
|
||||
cat "$_home_dir""ac_override_1" "ext/curl/config.m4" "$_home_dir""ac_override_2" > /tmp/aa && \
|
||||
mv /tmp/aa "ext/curl/config.m4" && \
|
||||
rm -rf "$_home_dir""ac_override_1" "$_home_dir""ac_override_2" && \
|
||||
PKG_CONFIG_PATH="$PKG_CONFIG_PATH:""$_opt_dir/libxml2/lib/pkgconfig" && \
|
||||
PKG_CONFIG_PATH="$PKG_CONFIG_PATH:""$_opt_dir/curl/lib/pkgconfig" && \
|
||||
./buildconf --force && \
|
||||
PKG_CONFIG_PATH=$PKG_CONFIG_PATH ./configure LDFLAGS=-static $(php_get_configure_args) && \
|
||||
sed -ie 's/-export-dynamic//g' "$_source_dir/$(lib_x_dirname php)/Makefile" && \
|
||||
sed -ie 's/-o $(SAPI_CLI_PATH)/-all-static -o $(SAPI_CLI_PATH)/g' "$_source_dir/$(lib_x_dirname php)/Makefile" && \
|
||||
sed -ie 's/swoole_clock_gettime(CLOCK_REALTIME/clock_gettime(CLOCK_REALTIME/g' "$_source_dir/$(lib_x_dirname php)/ext/swoole/include/swoole.h" && \
|
||||
make LDFLAGS=-ldl -j4 && \
|
||||
make install && \
|
||||
strip "$_home_dir""php-dist/bin/php" && \
|
||||
cd $_home_dir
|
||||
}
|
||||
|
||||
#apk add g++ pkgconf autoconf nghttp2 libcurl \
|
||||
# git gcc zlib-dev libstdc++ ncurses zlib linux-headers \
|
||||
# readline make libssl1.1 libxml2 m4 libgcc vim binutils \
|
||||
# oniguruma-dev openssl openssl-dev
|
||||
# 编译必需的
|
||||
apk add gcc g++ autoconf libstdc++ linux-headers make m4 libgcc binutils ncurses
|
||||
# php的zlib支持
|
||||
apk add zlib-dev zlib-static
|
||||
# php的mbstring支持
|
||||
apk add oniguruma-dev
|
||||
# php的openssl支持
|
||||
apk add openssl-libs-static openssl-dev openssl
|
||||
# php的gd支持,如果不需要gd则去掉--enable-gd和下面的依赖
|
||||
apk add libpng-dev libpng-static
|
||||
# curl的c-ares支持,如果不需要curl则去掉
|
||||
apk add c-ares-static c-ares-dev
|
||||
|
||||
|
||||
download_all && \
|
||||
compile_liblzma && \
|
||||
compile_libxml2 && \
|
||||
compile_curl && \
|
||||
compile_php && \
|
||||
echo "完成!见 php-dist/bin/php"
|
||||
|
||||
Reference in New Issue
Block a user