启用php 7.1的线程安全性

时间:2017-07-07 08:49:28

标签: php multithreading compilation pthreads

我克隆了php 7.1:

apshenichnikov@IAS-WS-UX02:~/php-src$ git status
On branch PHP-7.1

我制作./buildconf --force
我跑:

./configure \
  --enable-hash \
  --prefix=/usr/local/php \
  --enable-maintainer-zts \
  --with-tsrm-pthreads \
  --with-pdo-oci=shared,instantclient,/opt/oracle/instantclient,12.1

我成功地运行了make& make install:

apshenichnikov@IAS-WS-UX02:~/php-src$ sudo make install
Installing shared extensions:     /usr/local/php/lib/php/extensions/no-debug-zts-20151012/
Installing PHP CLI binary:        /usr/local/php/bin/
Installing PHP CLI man page:      /usr/local/php/php/man/man1/
Installing phpdbg binary:         /usr/local/php/bin/
Installing phpdbg man page:       /usr/local/php/php/man/man1/
Installing PHP CGI binary:        /usr/local/php/bin/
Installing PHP CGI man page:      /usr/local/php/php/man/man1/
Installing build environment:     /usr/local/php/lib/php/build/
Installing header files:           /usr/local/php/include/php/
Installing helper programs:       /usr/local/php/bin/
  program: phpize
  program: php-config
Installing man pages:             /usr/local/php/php/man/man1/
  page: phpize.1
  page: php-config.1
Installing PEAR environment:      /usr/local/php/lib/php/
[PEAR] Archive_Tar    - already installed: 1.4.0
[PEAR] Console_Getopt - already installed: 1.4.1
[PEAR] Structures_Graph- already installed: 1.1.1
[PEAR] XML_Util       - already installed: 1.3.0
[PEAR] PEAR           - already installed: 1.10.1
Warning! a PEAR user config file already exists from a previous PEAR installation at '/home/apshenichnikov/.pearrc'. You may probably want to remove it.
Wrote PEAR system config file at: /usr/local/php/etc/pear.conf
You may want to add: /usr/local/php/lib/php to your php.ini include_path
/home/apshenichnikov/php-src/build/shtool install -c ext/phar/phar.phar /usr/local/php/bin
ln -s -f phar.phar /usr/local/php/bin/phar
Installing PDO headers:           /usr/local/php/include/php/ext/pdo/

当我运行phpinfo时,我得到:“禁用线程安全”
当我尝试通过pecl安装pthreads时,我得到:

apshenichnikov@IAS-WS-UX02:~/php-src$ sudo pecl install pthreads
downloading pthreads-3.1.6.tgz ...
Starting to download pthreads-3.1.6.tgz (80,932 bytes)
...................done: 80,932 bytes
28 source files, building
running: phpize
Configuring for:
PHP Api Version:         20151012
Zend Module Api No:      20151012
Zend Extension Api No:   320151012
building in /tmp/pear/temp/pear-build-rootkhkb7n/pthreads-3.1.6
running: /tmp/pear/temp/pthreads/configure --with-php-config=/usr/bin/php-config
checking for grep that handles long lines and -e... /bin/grep
checking for egrep... /bin/grep -E
checking for a sed that does not truncate output... /bin/sed
checking for cc... cc
checking whether the C compiler works... yes
checking for C compiler default output file name... a.out
checking for suffix of executables...
checking whether we are cross compiling... no
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether cc accepts -g... yes
checking for cc option to accept ISO C89... none needed
checking how to run the C preprocessor... cc -E
checking for icc... no
checking for suncc... no
checking whether cc understands -c and -o together... yes
checking for system library directory... lib
checking if compiler supports -R... no
checking if compiler supports -Wl,-rpath,... yes
checking build system type... x86_64-pc-linux-gnu
checking host system type... x86_64-pc-linux-gnu
checking target system type... x86_64-pc-linux-gnu
checking for PHP prefix... /usr
checking for PHP includes... -I/usr/include/php/20151012 -I/usr/include/php/20151012/main -I/usr/include/php/20151012/TSRM -I/usr/include/php/20151012/Zend -I/usr/include/php/20151012/ext -I/usr/include/php/20151012/ext/date/lib
checking for PHP extension directory... /usr/lib/php/20151012
checking for PHP installed headers prefix... /usr/include/php/20151012
checking if debug is enabled... no
checking if zts is enabled... no
checking for re2c... re2c
checking for re2c version... 0.16 (ok)
checking for gawk... gawk
checking whether to enable pthreads... yes, shared
checking whether to enable AddressSanitizer for pthreads... no
checking whether to enable dmalloc for pthreads... no
checking for ZTS... configure: error: pthreads requires ZTS, please re-compile PHP with ZTS enabled
ERROR: `/tmp/pear/temp/pthreads/configure --with-php-config=/usr/bin/php-config' failed

我确信pecl和apache2使用最近编译的php 我使用不同的分支重新推荐PHP并使其干净 它总是一样的结果。

1 个答案:

答案 0 :(得分:0)

虽然您已经构建了PHP的新副本,但在构建pthreads扩展时却没有使用它。您可以在./configure命令的输出中看到这一点,其中包含文件指向您的(可能是旧的)PHP安装:

  

检查PHP包括... -I / usr / include / php / 20151012 -I / usr / include / php / 20151012 / main -I / usr / include / php / 20151012 / TSRM -I / usr / include / php / 20151012 / Zend -I / usr / include / php / 20151012 / ext -I / usr / include / php / 20151012 / ext / date / lib

您可以通过使用--with-php-config设置指定用于全新PHP构建的配置二进制文件的位置来解决此问题。根据您的安装,它应位于/usr/local/php/bin/php-config