nginx-php pthreads Apache Cannot load problem (Windows)

Source: Internet
Author: User
Native configuration:
Apache:2.2-x86
php:5.4 ts-x86
System: Windows 64

Pthreads Configuration
Download Address: http://windows.php.net/downloads/pecl/releases/pthreads/2.0.9/

Pthreads 5.4 Under Two files:
Php_pthreas.dll and PthreadVC2.dll

Php_pthreas.dll into the PHP ext file
PthreadVC2.dll into the PHP root directory

Ini
Extension=php_pthreads.dll

Apache http.conf Configuration
LoadFile "D:/wamp/php/pthreadvc2.dll"

Then reboot Apache cannot start cmd into Apache/bin command httpd-k start cannot load PthreadVC2.dll

Questions:
is PHP version 64-bit Apache to call PthreadVC2.dll?

Test code:


  
   arg = $arg;  }  public function run(){    if($this->arg){      printf("Hello %s\n", $this->arg);    }  }}$thread = new AsyncOperation("World");if($thread->start())  $thread->join();?>

By Apache does not load PthreadVC2.dll, directly can print out Helloword

Nginx:
Run test code without results

Questions:
PHP pthreads Multi-threaded extension nginx How to configure?

Reply content:

Native configuration:
Apache:2.2-x86
php:5.4 ts-x86
System: Windows 64

Pthreads Configuration
Download Address: http://windows.php.net/downloads/pecl/releases/pthreads/2.0.9/

Pthreads 5.4 Under Two files:
Php_pthreas.dll and PthreadVC2.dll

Php_pthreas.dll into the PHP ext file
PthreadVC2.dll into the PHP root directory

Ini
Extension=php_pthreads.dll

Apache http.conf Configuration
LoadFile "D:/wamp/php/pthreadvc2.dll"

Then reboot Apache cannot start cmd into Apache/bin command httpd-k start cannot load PthreadVC2.dll

Questions:
is PHP version 64-bit Apache to call PthreadVC2.dll?

Test code:


  
   arg = $arg;  }  public function run(){    if($this->arg){      printf("Hello %s\n", $this->arg);    }  }}$thread = new AsyncOperation("World");if($thread->start())  $thread->join();?>

By Apache does not load PthreadVC2.dll, directly can print out Helloword

Nginx:
Run test code without results

Questions:
PHP pthreads Multi-threaded extension nginx How to configure?

Personally think that pthreads this extension is not suitable for applications on APACHE/PHP-FPM These Web services, because these services themselves have their own process management model. Using pthreads under the CLI may be better. Also, it is important to note that Do not use the echo output in the thread, or there will be unpredictable errors and behavior, such as garbled (garbled). Especially in non-CLI environments, such as APACHE/PHP-FPM. Plus, I'm using nginx+ on Ubuntu. PHP-FPM Run the following multithreaded program, is capable of normal operation:


  '. Str_repeat (', 1024*4);    Ob_flush (); Flush ();}    Class Request extends Thread {public $url;    Public $data;    Public function __construct ($url) {$this->url = $url;            The public Function run () {//thread handles a 5-second task for ($i =0; $i <5; $i + +) {//Do not use the Echo output echo ' thread: '. Date (' H:i:s '). "            \ n ";            Do_flush ();        Sleep (1);        } $response = file_get_contents ($this->url);        $response = $this->url;        if ($response) {$this->data = array ($response); }//echo "Thread: Task complete
"; }} $request = new request (' hello.html ');//Run Thread: The start () method will trigger the run () running if ($request->start ()) {//master process to process a 10-second task, at which time the thread has After work for ($i =0; $i <10; $i + +) {echo ' process: '. Date (' H:i:s '). " \ n "; Do_flush (); Sleep (1); }}//synchronizes the thread and outputs the data returned by the $request->join (); Echo ' thread returns data: '. $request->data[0];ob_end_flush ();

Load Pthreads plugin must require PHP is ZTS Enabled (Thread Safety) version, please check the relevant version on your own

I changed the whole environment. apache2.4 PHP 5.6 ts-x64 Threads Extension Normal add

  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.