日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 人文社科 > 生活经验 >内容正文

生活经验

php pthread安装编译,php 多线程扩展 pthreads 安装 及 使用

發布時間:2023/11/27 生活经验 41 豆豆
生活随笔 收集整理的這篇文章主要介紹了 php pthread安装编译,php 多线程扩展 pthreads 安装 及 使用 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

1、擴展的編譯安裝php(Linux),編輯參數 --enable-maintainer-zts 是必選項:

2、下載 php7:

http://tw2.php.net/get/php-7.1.2.tar.gz/from/a/mirrorduoxc

3、解壓并編譯php

tar -zxf php-7.1.2.tar.gz

cd php-7.1.2

./configure --prefix=/usr/local/php712 --with-config-file-path=/usr/local/php712/etc --with-config-file-scan-dir=/usr/local/php712/etc/php.d --with-mcrypt=/usr/include --enable-mysqlnd --with-mysqli --with-pdo-mysql --enable-fpm --with-gd --with-iconv --with-zlib --enable-xml --enable-shmop --enable-sysvsem --enable-inline-optimization --enable-mbregex --enable-mbstring --enable-ftp --enable-gd-native-ttf --enable-pcntl --enable-sockets --with-xmlrpc --enable-zip --enable-soap --without-pear --enable-session --with-curl --with-jpeg-dir --enable-sqlite-utf8 --enable-sysvmsg --enable-sysvshm --enable-wddx --with-xsl --enable-opcache --enable-maintainer-zts

sudo make -j8 && sudo make install

4、php編譯完之后開始編譯安裝 pthreads擴展

5、下載pthreads擴展

https://github.com/krakjoe/pthreads

6、解壓并安裝

tar -zxf pthreads-3.1.6.tgz

cd pthreads-3.1.6

./configure --with-php-config=/usr/local/php712/bin/php-config

sudo make -j8 && sudo make install

7、配置php.ini

sudo vim /usr/local/php712/etc/php.ini

在 php.ini 最后添加:

[pthreads]

extension=pthreads.so

8、測試pthreads擴展

Thread.php :

Class Thread {

public $hooks = array();

public $args = array();

public function thread() {

}

public function addthread($func) {

$args = array_slice(func_get_args(), 1);

$this->hooks[] = $func;

$this->args[] = $args;

return true;

}

public function runthread() {

if(isset($_GET['flag'])) {

$flag = intval($_GET['flag']);

}

if($flag || $flag === 0) {

call_user_func_array($this->hooks[$flag], $this->args[$flag]);

} else {

for($i = 0, $size = count($this->hooks); $i < $size; $i++) {

$fp=fsockopen($_SERVER['HTTP_HOST'],$_SERVER['SERVER_PORT']);

if($fp) {

$out = "GET {$_SERVER['PHP_SELF']}?flag=$i HTTP/1.1rn";

$out .= "Host: {$_SERVER['HTTP_HOST']}rn";

$out .= "Connection: Closernrn";

fputs($fp,$out);

fclose($fp);

}

}

}

}

}

test.php :

include('Thread.php');

Class AsyncOperation extends Thread {

public function __construct($arg){

$this->arg = $arg;

}

public function run(){

if($this->arg){

printf("Hello %s\n", $this->arg);

}

}

}

$thread = new AsyncOperation("World");

if($thread->start()){

$thread->join();

}

總結

以上是生活随笔為你收集整理的php pthread安装编译,php 多线程扩展 pthreads 安装 及 使用的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。