Comments (4)
experiment 分支新增:
- 允许指定扩展下载地址
- 可以使用curl 、 git 等方式下载库或者扩展,
- 新增简易webui 辅助: https://swoole-cli-ui.jingjingxyk.com/
- 新增快速初始化PHP 运行环境脚本setup-php-runtime.sh
- 编译gd 扩展,扩展启用依赖 libavif 库,为了支持 avif 格式的图片,编译时添加
--with-libavif=1
build_native_php分支新增:
- 继承 experiment 分支功能
- 可指定 PHP 版本,例如:
--with-php-version=8.2.11
- 可指定 C 编译器 为GCC,例如:
--with-c-compiler=gcc
- 可指定 构建类型,用于新增扩展时,验证扩展启用参数,例如:
--with-build-type=dev
- 可指定 http 代理,用于下载,扩展和依赖库 ,例如:
--with-http-proxy=http://192.168.3.26:8015
- 可编译swow扩展的PHP可执行文件,例如:
php prepare.php -swoole +swow
- 可在 debian 、ubuntu 容器环境中验证静态编译
from swoole-cli.
PHP 静态编译 完整的流程
(只启用redis 扩展 和 默认扩展)
要添加扩展,你只要依照添加redis 方式添加即可(过程中,你会发现需要解决很多很多静态链接库问题)
解决静态链接库问题,并且把解决步骤固定下来,也就是swoole-cli 项目做的事情
准备构建环境,alpine:3.17
运行容器,并将自动进入容器终端
docker run --rm -ti --init -w /work alpine:3.17
安装构建环境必要软件包
apk update
apk add vim alpine-sdk xz autoconf automake linux-headers clang-dev clang lld libtool cmake bison re2c gettext coreutils gcc g++
apk add bash p7zip zip unzip flex pkgconf ca-certificates
apk add wget git curl
apk add libc++-static libltdl-static
apk add vim
准备构建脚本
vi build-static-php.sh
#!/bin/env bash
set -uex
PHP_VERSION=8.1.21
test -f php-${PHP_VERSION}.tar.gz || wget -O php-${PHP_VERSION}.tar.gz https://github.com/php/php-src/archive/refs/tags/php-${PHP_VERSION}.tar.gz
test -d php-src && rm -rf php-src
mkdir -p php-src
tar --strip-components=1 -C php-src -xf php-${PHP_VERSION}.tar.gz
test -f redis-5.3.7.tgz || wget -O redis-5.3.7.tgz https://pecl.php.net/get/redis-5.3.7.tgz
mkdir -p redis
tar --strip-components=1 -C redis -xf redis-5.3.7.tgz
test -d php-src/ext/redis && rm -rf php-src/ext/redis
mv mongodb php-src/ext/
export CC=clang
export CXX=clang++
export LD=ld.lld
cd php-src
./buildconf --force
./configure \
--disable-all \
--disable-cgi \
--enable-shared=no \
--enable-static=yes \
--enable-cli \
--disable-phpdbg \
--without-valgrind \
--enable-session \
--enable-redis
make -j $(nproc)
file sapi/cli/php
readelf -h sapi/cli/php
执行构建即可
bash build-static-php.sh
# 构建完毕 ,生成的如下文件,就是希望得到的二进制文件
sapi/cli/php
sapi/cli/php -m
sapi/cli/php -v
sapi/cli/php --ri redis
from swoole-cli.
swoole-cli 就是在上述基础之上,做了进行裁剪 、优化、整合 、打包 等,并默认启用了swoole 扩展。
from swoole-cli.
一句命令即可 为 linux 、macOS 准备 PHP 运行环境 (依赖 curl 、wget 、bash 、xz)
curl https://github.com/swoole/swoole-cli/blob/main/setup-php-runtime.sh?raw=true -sSfL | bash -s -- --mirror china
curl https://swoole-cli.jingjingxyk.com/setup-php-runtime.sh -sSf | bash -s -- --mirror china
from swoole-cli.
Related Issues (20)
- GD 库 库支持.avif 格式的图片
- ./make.sh config 成功,但 ./make.sh build 报错 HOT 1
- 构建加速:方式
- 项目镜像地址
- Makefile:14198 HOT 4
- 是否不支持macos11 HOT 3
- macos 、linux 构建步骤 HOT 5
- gdb swoole-cli core.xx 提示 (no debugging symbols found) ...done. HOT 3
- 5.1 编译pdo 协程 有适配的方案吗? HOT 7
- 大佬,常用的国标加密库能不能加进去? HOT 4
- main分支 alpine 容器内构建 make openssl 失败 HOT 3
- swoole-cli /sync-source-code.php 代码有问题 HOT 1
- windows 使用 Cygwin 构建 swool-cli 不成功。 HOT 18
- swoole-cli 5.1.1 不支持php-fpm运行了吗? HOT 1
- Cygwin 环境中的这个 swoole-cli 似乎不能够很好的支持 phpstan HOT 1
- swoole-cli 是否对 try catch 捕获的协程异常做了一些调整,使调用栈的错误信息不在控制台打印出来了? HOT 7
- build提示 ext/phar/phar_internal.h:619:1: error: expected identifier or '(' HOT 4
- fpm下安装composer失败 HOT 5
- 配合hyperf使用提示 swoole_signalfd_event_callback HOT 4
- Linux 下构建 oci8、pdo_oci 扩展,遇到的 Oracle Instant Client 库不是 .tar.gz 格式和无 Makefile 文件的问题。 HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from swoole-cli.