从头编译PHP

in 日常 with 0 comment

前提配置

export PKG_CONFIG_PATH=/usr/local/armv7m-linux-musleabi/lib/pkgconfig/:/usr/local/armv7m-linux-musleabi/lib64/pkgconfig/

编译pcre2

./configure --host=armv7m-linux-musleabi --target=armv7m-linux-musleabi --prefix=/usr/local/armv7m-linux-musleabi/ LDFLAGS="-static" CCFLAGS="-fpic"
make && make install

编译openssl

光猫自带openssl 1.1.x,所以建议使用旧版本可以省去很多空间
https://www.openssl.org/source/old/1.1.1/index.html

./config -fpic no-shared no-asm no-zlib no-sse2 no-comp no-dso --prefix=/usr/local/armv7m-linux-musleabi/ --cross-compile-prefix=armv7m-linux-musleabi- 
make LDFLAGS="-latomic" CNF_CFLAGS="-pthread" CNF_CXXFLAGS="-std=c++11 -pthread" && make install

编译zlib

export CC=armv7m-linux-musleabi-gcc
export AR=armv7m-linux-musleabi-ar
./configure --prefix=/usr/local/armv7m-linux-musleabi/ --static
make && make install

编译libxml2

./configure -host=armv7m-linux-musleabi --target=armv7m-linux-musleabi --prefix=/usr/local/armv7m-linux-musleabi/ CCFLAGS="-fpic" --enable-static --without-python
make && make install

编译PHP

 ./configure \
    --with-fpm-group=daemon \
    --with-layout=GNU \
    --with-config-file-path=/usr/data/.php.ini \
    --with-config-file-scan-dir=/usr/data/php \
    --with-zlib \
    --with-openssl \
    --without-cdb \
    --disable-flatfile \
    --disable-phar \
    --disable-dom \
    --disable-fileinfo \
    --disable-filter \
    --without-iconv \
    --without-libxml \
    --disable-simplexml \
    --disable-xml \
    --disable-xmlreader \
    --disable-xmlwriter \
    --disable-mbregex \
    --disable-opcache \
    --disable-tokenizer \
    --enable-fpm \
    --without-sqlite3 \
    --disable-pdo \
    PHP_EXTRA_VERSION=" for ArmEL Rounger" \
    --host=armv7m-linux-musleabi \
    LDFLAGS="-latomic -s -w" CCFLAGS="-fpic"

喝杯咖啡慢慢等吧,此编译版本

附上我编译的版本

Responses