【问题标题】:Compiling PHP with mbstring and zip modules使用 mbstring 和 zip 模块编译 PHP
【发布时间】:2020-03-05 16:52:26
【问题描述】:

centos 7、php 7.4

我们有一个项目的常规 php 7.4。这意味着它是使用包管理器定期安装的。但是现在我们需要重新编译 php,因为我们想要使用需要 CLI ZTS PHP 的并行扩展。现在在 windows 上编译 php 超级简单,但是在 Centos 上我就不能这么说了。

主要问题是我编译后缺少一些扩展。

编译过程:

cd
git clone https://github.com/php/php-src.git
cd php-src
git checkout PHP-7.4.3
./buildconf --force
./configure --prefix=/usr/local/php7 \
    --with-config-file-path=/usr/local/php7/etc \
    --with-config-file-scan-dir=/usr/local/php7/etc/conf.d \
    --enable-bcmath \
    --with-bz2 \
    --with-curl \
    --enable-filter \
    --enable-fpm \
    --enable-gd \
    --with-freetype \
    --with-jpeg \
    --enable-intl \
    --with-mysql-sock=/var/lib/mysql/mysql.sock \
    --with-openssl \
    --enable-simplexml \
    --enable-xmlreader \
    --enable-xmlwriter \
    --enable-pcntl \
    --enable-shmop \
    --enable-sysvmsg \
    --enable-sysvsem \
    --enable-sysvshm \
    --with-xsl \
    --enable-opcache \
    --enable-calendar \
    --enable-sockets \
    --enable-mbstring \
    --with-zlib=~/libzip-1.6.1/build/ \
    --with-zip \
    --enable-exif \
    --with-gettext \
    --without-sqlite3 \
    --with-mhash \
    --enable-maintainer-zts
make -j2
sudo make install

我的主要问题是编译完成后缺少 2 个“扩展”/模块。这些都是; mbstringzip

然后当我使用php -m | grep mbstringphp -m | grep zip 检查已安装的模块时,我看不到它们。

所以我的问题是; 我怎样才能完成这项工作? 我很确定有很多 ppl 编译自己的 PHP,这些都是非常基本的模块。

额外信息: 安装这些需要 mbstring:oniguruma oniguruma-devel 包 当这个丢失时,我在编译 php 时收到错误消息,mbstring 需要这个:oniguruma

但是安装后mbstring刚刚用php编译,没有任何错误,它仍然丢失。

情况与 zip 模块类似。它需要libzip,我是这样安装的:

wget -c https://cmake.org/files/LatestRelease/cmake-3.16.0-Linux-x86_64.tar.gz
tar zxvf cmake-3.*
export PATH=$PATH:~/cmake-3.16.0-Linux-x86_64/bin
wget -c http://www.zlib.net/zlib-1.2.11.tar.gz
tar zxvf zlib-1.2.11.tar.gz
./configure
sudo make -j2
sudo make install
cd libzip*
mkdir build
cd build
cmake ..
make
make test
# when you use sudo here the root user's PATH will be used, so update it
sudo make install
# in that case if there was an issue during copying the built stuff
export PATH=$PATH:~/libzip-1.6.1/build/lib/

同样的结果。 我还认为可以选择使用包管理器安装这些扩展,然后将 .so 文件放入模块文件夹并将它们包含在 modules.ini 中:

extension=zip.so
extension=mbstring.so

在那种情况下,我得到了这个错误:

PHP Warning:  PHP Startup: Unable to load dynamic library 'zip.so' (tried: /usr/local/php7/lib/php/extensions/no-debug-zts-20190902/zip.so (/usr/local/php7/lib/php/extensions/no-debug-zts-20190902/zip.so: undefined symbol: executor_globals), /usr/local/php7/lib/php/extensions/no-debug-zts-20190902/zip.so.so (/usr/local/php7/lib/php/extensions/no-debug-zts-20190902/zip.so.so: cannot open shared object file: No such file or directory)) in Unknown on line 0
PHP Warning:  PHP Startup: Unable to load dynamic library 'mbstring.so' (tried: /usr/local/php7/lib/php/extensions/no-debug-zts-20190902/mbstring.so (/usr/local/php7/lib/php/extensions/no-debug-zts-20190902/mbstring.so: cannot open shared object file: No such file or directory), /usr/local/php7/lib/php/extensions/no-debug-zts-20190902/mbstring.so.so (/usr/local/php7/lib/php/extensions/no-debug-zts-20190902/mbstring.so.so: cannot open shared object file: No such file or directory)) in Unknown on line 0

这些文件可以位于那里,并且目录在 PATH 环境变量中:

$ echo $PATH
/usr/local/bin:/usr/bin:/usr/local/sbin:/usr/sbin:/home/centos/.local/bin:/home/centos/bin:/usr/local/php7/bin:/home/centos/cmake-3.16.0-Linux-x86_64/bin:/home/centos/libzip-1.6.1/build/lib/:/home/centos/libzip-1.6.1/lib/:/usr/lib:/usr/lib/:/usr/include/:/usr/local/php7/lib/php/extensions/no-debug-zts-20190902/

另外,php 也可能无法加载这些模块,因为它们是 NTS 模块。

因此,如果有人之前使用这些扩展编译过 php,我可以使用一些帮助。 谢谢!

【问题讨论】:

    标签: php compilation centos7


    【解决方案1】:

    好的,我发现我做错了什么。问题是我将第一个构建复制到路径目录,每次执行 php 时,它都是从那里执行 php 而不是新版本。

    【讨论】:

      猜你喜欢
      • 2018-12-16
      • 2012-02-16
      • 2015-02-21
      • 2012-11-27
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-04-17
      相关资源
      最近更新 更多