【问题标题】:How to compile PHP 7.1 with ZTS如何使用 ZTS 编译 PHP 7.1
【发布时间】:2017-11-29 02:10:56
【问题描述】:

我在github PThread项目页面上看到支持php7+。

我在 ubuntu 发行版 (16.04) 上有 php7.1.6

我找不到任何提供 php7.1-zts 的 PPA。

如何在php7.1上启用zts来安装pthreads?

【问题讨论】:

    标签: php pthreads ubuntu-16.04 php-7.1 zts


    【解决方案1】:

    在 Ubuntu 服务器上

    我将版本更改为 7.4.16

    git clone https://github.com/php/php-src.git -b PHP-7.0.17 --depth=1

    在重新编译 PHP 之前,我必须安装一些依赖项。

    需要的包是:

    apt install bison re2c zlib1g-dev sqlite3 libsqlite3-dev libbz2-dev libcurl4-openssl-dev libenchant-dev libonig-dev libpspell-dev libedit-dev libreadline-dev libxslt-dev

    还有 警告:无法识别的选项:--enable-zip、--with-mcrypt、--with-gd、--with-jpeg-dir、--with-png-dir、--with-freetype-dir、--enable -hash,--enable-wddx,--with-pcre-regex

    因此,对于 php 7.4,您可能想要这样做: ./configure --prefix=/etc/php7 --with-bz2 --with-zlib --enable-zip --disable-cgi \ --enable-soap --enable-intl with-openssl --with-readline --with-curl \ --enable-ftp --enable-mysqlnd --with-mysqli=mysqlnd --with-pdo-mysql=mysqlnd \ --enable-sockets --enable-pcntl --with-pspell --with-enchant --with-gettext \ --enable-exif --with-xsl \ --enable-bcmath --enable-mbstring --enable-calendar --enable-simplexml --enable-json \ --enable-session --enable-xml --enable-opcache \ --with-config-file-path=/etc/php7/cli \ --with-config-file-scan-dir=/etc/php7/etc --enable-cli --enable-maintainer-zts \ --with-tsrm-pthreads --enable-debug --enable-fpm \ --with-fpm-user=www-data --with-fpm-group=www-data

    以后你会发现php7.4不兼容pthreads 你会发现这个错误,维护者已经停止开发 pthreads 并转移到并行。 https://github.com/krakjoe/pthreads/issues/929

    【讨论】:

      【解决方案2】:

      这是我的安装脚本

      #!/bin/bash
      
      mkdir -p /etc/php7
      mkdir -p /etc/php7/cli
      
      git clone https://github.com/php/php-src.git -b PHP-7.0.17 --depth=1
      cd php-src/ext
      git clone https://github.com/krakjoe/pthreads -b master pthreads
      
      cd ..
      
      ./buildconf --force
      
      ./configure --prefix=/etc/php7 --with-bz2 --with-zlib --enable-zip --disable-cgi \
         --enable-soap --enable-intl --with-mcrypt --with-openssl --with-readline --with-curl \
         --enable-ftp --enable-mysqlnd --with-mysqli=mysqlnd --with-pdo-mysql=mysqlnd \
         --enable-sockets --enable-pcntl --with-pspell --with-enchant --with-gettext \
         --with-gd --enable-exif --with-jpeg-dir --with-png-dir --with-freetype-dir --with-xsl \
         --enable-bcmath --enable-mbstring --enable-calendar --enable-simplexml --enable-json \
         --enable-hash --enable-session --enable-xml --enable-wddx --enable-opcache \
         --with-pcre-regex --with-config-file-path=/etc/php7/cli \
         --with-config-file-scan-dir=/etc/php7/etc --enable-cli --enable-maintainer-zts \
         --with-tsrm-pthreads --enable-debug --enable-fpm \
         --with-fpm-user=www-data --with-fpm-group=www-data
      
      make && make install
      
      chmod o+x /etc/php7/bin/phpize
      chmod o+x /etc/php7/bin/php-config
      
      cd ext/pthreads*
      /etc/php7/bin/phpize
      
      ./configure --prefix=/etc/php7 --with-libdir=/lib/x86_64-linux-gnu --enable-pthreads=shared --with-php-config=/etc/php7/bin/php-config
      
      make && make install
      
      cd ../../
      cp -r php.ini-development /etc/php7/cli/php.ini
      
      cp php.ini-development /etc/php7/cli/php-cli.ini
      echo "extension=pthreads.so" > /etc/php7/cli/php-cli.ini
      echo "zend_extension=opcache.so" >> /etc/php7/cli/php.ini
      
      ln --symbolic /etc/php7/bin/php /usr/bin/php
      
      export USE_ZEND_ALLOC=0
      

      你也可以使用我的 docker-container docker pull buildok/zts

      【讨论】:

      • 谢谢,它似乎工作正常。我将使用 php 7.1 分支进行测试。您现在是否可以在从源代码编译时拥有一个 php apache 模块?
      • @Khorwin 我通常使用 nginx。如果需要 apache-mod 支持,可以在 ./configure 中添加参数 --with-apxs2=/usr/local/apache2/bin/apxs 查看详细信息php.net/manual/en/install.unix.apache2.php
      • @Khorwin Pthreads 不能在 Web 服务器环境中使用,因此如果 PHP 作为 Apache 模块加载,您将无法启用 pthreads。
      • @buildok 你启用了调试模式——这对这里的大多数人来说可能并不理想。此外,TSRM 默认为 POSIX 线程,因此没有必要指定它。
      • 也许你是对的,无论如何我建议在编译之前使用 ./configure --help 找出这些参数
      猜你喜欢
      • 2021-07-18
      • 1970-01-01
      • 2015-07-21
      • 2015-07-26
      • 1970-01-01
      • 1970-01-01
      • 2015-07-12
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多