Search code examples
phpmultithreadingiispthreadshttp-status-code-500

Why will php pthreads not work? http error internal server code 500.0


I am attempting to make use of threading within my php application, but for reasons unknown to myself I cannot seem to set php up to use pthreads.

Here are a few details FYI to help diagnose the issue:

  • My environment is IIS on Windows 10.
  • My php version is 7.0.7.
  • Thread Safety is showing as 'enabled' in phpinfo()
  • My PHP Extension Build is 'API20151012,TS,VC14'
  • I have tried several pthreads releases of version 'VC14'
  • php_pthreads.dll has been copied to 'C:\Program Files\PHP\v7.0.7\ext'
  • pthreadVC2.dll has been copied to 'C:\Program Files\PHP\v7.0.7' and 'C:\Windows\System32'
  • extension=php_pthreads.dll has been added to php.ini

When I comment out extension=php_pthreads.dll and load the home page I get

Fatal error: Class 'Thread' not found

But when I un-comment the line I get:

HTTP Error 500.0 - Internal Server Error C:\Program Files\PHP\v7.0.7\php-cgi.exe - The FastCGI process exited unexpectedly

What could be the reasons for those problems?


Solution

  • 'The cgi-fcgi SAPI is not supported by pthreads'

    After doing some research on the above error I found out that since PHP 7.0.0 pthreads has only been available on the command line, so the answer is to either downgrade the PHP version or disable the threading for the web server, and you can see how to do that HERE