php教程

安装

pthreads 扩展由 PECL 主持,使用 » github 管理源代码。 使用标准的 PECL 包安装方式就可以完成安装:» https://pecl.php.net/package/pthreads

Windows 用户可以从 » PECL 下载已经构建的二进制发行包。

Caution

Windows 用户需要将 pthreadVC2.dll (包含在 Windows 版二进制发行包中)所在路径加入到 PATH 环境变量中。

User Contributed Notes

horica78 at yahoo dot com 15-Apr-2019 08:00
They can still be used in web server if used with exec('php script.php') and php-cli.ini .
agnelvishal at gmail dot com 11-Nov-2018 01:11
To compile PHP 7.2 with pthreads on Ubuntu 16.04 or Ubuntu 18.04 or Debian 9 Stretch, use this bash file at https://gist.github.com/agnelvishal/24f42c65af2f6cace1e9387617a0182a
and dot webdev at gmail dot com 08-Dec-2016 04:28
Also, possible by phpbrew

1. phpbrew install php-5.5.30 -- --enable-maintainer-zts
2. phpbrew use php-5.5.30
3. phpbrew ext install pthreads 2.0.10
Michel Phillipe Luca 20-Dec-2014 07:38
Here is how I got it working under Linux Ubuntu distro - WITHOUT USE PECL:

We will download both, PHP and Pthread without PECL

1 - Get PHP version
For this example we will use version: 5.4.36

# wget http://www.php.net/distributions/php-5.4.36.tar.gz

2- Get Pthreads version:
I'm using an old version but, you could take any one

# wget http://pecl.php.net/get/pthreads-1.0.0.tgz

Extract both, php and pthreads versions

#tar zxvf php-5.4.36.tar.gz
#tar zxvf pthreads-1.0.0.tgz

3- Move Pthreads to php/ext folder. Inside version of PHP downloaded at item 1.

4- Reconfigure sources
# ./buildconf --force
# ./configure --help | grep pthreads

You have to see --enable-pthreads listed. If do not, clear the buidls with this commands:

# rm -rf aclocal.m4
# rm -rf autom4te.cache/
# ./buildconf --force

5 - Inside php folder run configure command to set what we need:
# ./configure --enable-debug --enable-maintainer-zts --enable-pthreads --prefix=/usr --with-config-file-path=/etc

6 - Install PHP
We will run make clear just to be sure that no other crashed build will mess our new one.

# make clear
# make
# make install

7 - Copy configuration file of PHP and add local lib to include path
# cp php.ini-development /etc/php.ini

Edit php.ini and set Include_path to be like this:

Include_path = "/usr/local/lib/php"

9 - Check Modules
# php -m (check pthread loaded)

You have to see pthreads listed

10 - If pthread is not listed, update php.ini
# echo "extension=pthreads.so" >> /etc/php.ini
sawyer dot lin at gmail dot com 15-Dec-2014 05:42
To execute pecl install pthreads
The library autoconf shoud be installed at first
http://stackoverflow.com/questions/9322742/php-autoconf-errors-on-mac-os-x-10-7-3-when-trying-to-install-pecl-extensions
like
apt-get install pthreads
zahid dot smz at gmail dot com 11-May-2014 07:43
For Wampp (Windows)
-----------------------------------------------------------------------------------
1.  Find out what is your 'PHP Extension Build' version by using phpinfo(). You can use this - http://localhost/?phpinfo=1

2.  Download the pthreads that matches your php version (32 bit or 64 bit) and php extension build (currently used VC11). Use this link for download - http://windows.php.net/downloads/pecl/releases/pthreads/

3.  Extract the zip -
      Move php_pthreads.dll to the 'bin\php\ext\' directory.
      Move pthreadVC2.dll to the 'bin\php\' directory.
      Move pthreadVC2.dll to the 'bin\apache\bin' directory.
      Move pthreadVC2.dll to the 'C:\windows\system32' directory.

4.  Open php\php.ini and add
      extension=php_pthreads.dll

Now restart server and you are done. Thanks.
Pedro Proenca 12-Apr-2014 11:22
I haven't found any proper instructions on how to install pthreads in linux, so I'll leave the steps I followed:

# Required libraries
sudo apt-get install gcc make libzzip-dev libreadline-dev libxml2-dev \
libssl-dev libmcrypt-dev libcurl4-openssl-dev lib32bz2-dev

# Download PHP
cd /usr/local/src

wget http://www.php.net/distributions/php-<version>.tar.gz
( e.g. wget http://www.php.net/distributions/php-5.5.8.tar.gz )

# Extract
tar zxvf php-<version>.tar.gz
(e.g. tar zxvf php-5.5.8.tar.gz )

# Configure
cd /usr/local/src/php-<version>
( e.g. cd /usr/local/src/php-5.5.8 )

./configure --prefix=/usr --with-config-file-path=/etc --enable-maintainer-zts

# Compile
make && make install
( make -j3 && make -j3 install) -> Faster building

# Copy configuration
cp php.ini-development /etc/php.ini

# Install pthreads
pecl install pthreads
echo "extension=pthreads.so" >> /etc/php.ini

# Check installation
php -m | grep pthreads
pedro dot proenca at shapedfor dot me 12-Apr-2014 11:21
I haven't found any proper instructions on how to install pthreads in linux, so I'll leave the steps I followed:

# Required libraries
sudo apt-get install gcc make libzzip-dev libreadline-dev libxml2-dev \
libssl-dev libmcrypt-dev libcurl4-openssl-dev lib32bz2-dev

# Download PHP
cd /usr/local/src

wget http://www.php.net/distributions/php-<version>.tar.gz
( e.g. wget http://www.php.net/distributions/php-5.5.8.tar.gz )

# Extract
tar zxvf php-<version>.tar.gz
(e.g. tar zxvf php-5.5.8.tar.gz )

# Configure
cd /usr/local/src/php-<version>
( e.g. cd /usr/local/src/php-5.5.8 )

./configure --prefix=/usr --with-config-file-path=/etc --enable-maintainer-zts

# Compile
make && make install
( make -j3 && make -j3 install) -> Faster building

# Copy configuration
cp php.ini-development /etc/php.ini

# Install pthreads
pecl install pthreads
echo "extension=pthreads.so" >> /etc/php.ini

# Check installation
php -m | grep pthreads
rbfowler9lfc at hotmail dot com 19-Aug-2013 02:32
For those using XAMPP or other apache-php bundles, it's necessary to add LoadFile "C:/xampp/php/pthreadVC2.dll" to httpd-xampp.conf if you want to utilize pthreads in a browser window.
matias dot zumbo at gmail dot com 30-Jul-2013 11:54
HOW TO INSTALL IN LINUX SYSTEM'S:
------------------------------------

1) Download PHP sources and Unpack PHP

2) Download PEAR
     wget http://pear.php.net/go-pear.phar
     php go-pear.phar

3) Download pthreads
Get PECL extension (PECL is a repository for PHP Extensions)

# pecl install pthread-0.4.4

4) Unpack pthreads
copy pthread-0.4.4  to  php/ext
(for ./configure allow  add option --enable-pthreads)

# mv build/php-src-master/ext/pthreads-master    build/php-src-master/ext/pthreads

5)  Reconfigure sources
# ./buildconf --force
# ./configure --help | grep pthreads

You should see the appropriate --enable-pthreads option listed as a result, if you do not, then

# rm -rf aclocal.m4
# rm -rf autom4te.cache/
# ./buildconf --force

6) Build PHP
Compile PHP source code
Add:
# ./configure --enable-debug --enable-maintainer-zts --enable-pthreads

7) Installing PHP
# make
# sudo make install

8) Update php.ini
Add in php.ini
extension=pthreads.so
Include_path = "/usr/local/lib/php"

9) Check Modules
php -m (check pthread loaded)

10) Test Thread Class
# php SimpleTest.php
jason at jason-rush dot com 27-Jun-2013 08:54
The files are in the format:
php_pthreads-X.XX-Y.Y-ts-vcZZ-x86.zip

where
X.XX is the version of the phpthreads-win32
Y.Y is the base version of PHP that you are running
ZZ is ?? (version of compiler?)

Currently, 0.44 is the latest release of phpthreads-win32, so X.XX = 0.44
If you are running PHP 5.3.13, then Y.Y = 5.3
If you are running PHP 5.5.0, then Y.Y=5.5
etc

php_pthreads-0.44-5.3-ts-vc9-x86.zip
php_pthreads-0.44-5.4-ts-vc9-x86.zip
php_pthreads-0.44-5.5-ts-vc11-x64.zip
php_pthreads-0.44-5.5-ts-vc11-x86.zip
Jimmy Christensen 16-May-2013 08:55
On Windows the installation is as follows:

Download the pthreads that matches your php version.
I found mine at: http://windows.php.net/downloads/pecl/releases/pthreads/
(I used version 0.44 wich is the newest at the time of writing this, and then downloaded the one for php 5.3 which is the version I am using).

Extract the zip.
Move php_pthreads.dll to the php\ext\ directory.
Move pthreadVC2.dll to the php\ directory.

Open php\php.ini and add
extension=php_pthreads.dll

You are done.

CopyRight © 2008-2022 verySource.Com All Rights reserved. 京ICP备17048824号-1 京公网安备:11010502034788