真正的PHP多线程(绝非fork或者用http再开进程)_PHP教程

WBOY
Release: 2016-07-13 17:54:26
Original
1084 people have browsed it

[plain]
#如果你的autoconfig版本高于2.59,则只能安装php5.4
#否则你只可以安装5.3.17。如果知道你的autoconf的版本——如果你已经安装了php.5.4那么,你就安装照5.4的安装;如果装了5.3就装5.3

#5.4
wget
tar zxvf php-5.4.7.tar.gz
cd php-5.4.7/ext

#5.3
wget
tar -xf php-5.3.17.tar.gz
cd php-5.3.17/ext


#下面装pthreads
wget https://github.com/krakjoe/pthreads/tarball/master -O pthreads.tar.gz
tar -xf pthreads.tar.gz
mv krakjoe-pthreads* pthreads
cd ../
./buildconf --force
./configure --enable-maintainer-zts --enable-pthreads --prefix=/usr/local/php-threads#其它参数自行配置,这里只是必须的参数
make
make install

源码包里面有例子,像这样执行:

/usr/local/php-threads/bin/php AdvancedSynchronization.php

[plain]
Process: running
ScopeTest: 140703850592000 running
ScopeTest2: 140703839512320 running
ScopeTest2: 140703839512320 working ...
ScopeTest2: 140703839512320 notified: 1
Process: notifying 140703839512320: 1
ScopeTest: 140703850592000 notified: 1
Process: notifying 140703850592000: 1

通过apache执行的还没有试过,因为我不想破坏现有的php环境,而且我也不打算在非cli模式下执行。

www.bkjia.com true http://www.bkjia.com/PHPjc/477965.html TechArticle [plain] #如果你的autoconfig版本高于2.59,则只能安装php5.4 #否则你只可以安装5.3.17。如果知道你的autoconf的版本如果你已经安装了php.5.4那么,你...
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!