安装php扩展pthreads实现PHP多线程

php中文网
发布: 2016-06-23 13:36:30
原创
976人浏览过

下面介绍两种编译方式:


1、在已有的PHP上编译pthreads扩展

注:需要动态加载pthreads模块,之前在编译php时必须启用--enable-maintainer-zts;否则需要重新编译PHP。

pthreads源码包下载地址:http://pecl.php.net/package/pthreads

立即学习PHP免费学习笔记(深入)”;


tar xf pthreads-1.0.0.tgz 

cd pthreads-1.0.0

phpize

./configure  --enable-pthreads --with-php-config=/usr/local/php/bin/php-config

make && make install


2、重新编译PHP,加载pthreads


tar xf php-5.5.8.tar.gz

tar xf pthreads-1.0.0.tgz

mv pthreads-1.0.0  php-5.5.8/ext/pthreads  将pthreads解压,移动到php/ext/下,并改名为pthreads;


来到php源码目录

./buildconf  --force

./configure --help | grep thread 

是否能看到--enable-threads,如果没有则执行:

ViiTor实时翻译
ViiTor实时翻译

AI实时多语言翻译专家!强大的语音识别、AR翻译功能。

ViiTor实时翻译 116
查看详情 ViiTor实时翻译


rm -rf aclocal.m4

rm -rf autom4te.cache/

./buildconf --force

初始化编译配置:

./configure --prefix=/usr/local/php --enable-opcache --with-config-file-path=/etc --with-mysql=mysqlnd --with-mysqli=mysqlnd --with-pdo-mysql=mysqlnd --enable-fpm --enable-pthreads --enable-fastcgi --enable-static --enable-inline-optimization --enable-sockets --enable-wddx --enable-zip --enable-calendar --enable-bcmath --enable-soap --with-zlib --with-xmlrpc --enable-mbstring --without-sqlite --with-curl --enable-ftp --with-mcrypt  --with-freetype-dir=/usr/local/freetype.2.1.10 --with-jpeg-dir=/usr/local/jpeg.6 --with-png-dir=/usr/local/libpng.1.2.50 --disable-ipv6 --disable-debug --with-openssl --enable-maintainer-zts --disable-safe-mode --disable-fileinfo


make && make install 


cp php.ini-production /etc/php.ini


install -v -m755 ./php-5.5.7/sapi/fpm/init.d.php-fpm  /etc/init.d/php-fpm


启动php-fpm

/etc/init.d/php-fpm start


测试,查看phpinfo输出

官方文档:http://docs.php.net/manual/en/pthreads.installation.php#113019


PHP速学教程(入门到精通)
PHP速学教程(入门到精通)

PHP怎么学习?PHP怎么入门?PHP在哪学?PHP怎么学才快?不用担心,这里为大家提供了PHP速学教程(入门到精通),有需要的小伙伴保存下载就能学习啦!

下载
来源:php中文网
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn
最新问题
开源免费商场系统广告
热门教程
更多>
最新下载
更多>
网站特效
网站源码
网站素材
前端模板
关于我们 免责申明 举报中心 意见反馈 讲师合作 广告合作 最新更新 English
php中文网:公益在线php培训,帮助PHP学习者快速成长!
关注服务号 技术交流群
PHP中文网订阅号
每天精选资源文章推送
PHP中文网APP
随时随地碎片化学习

Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号