首页 > 解决方案 > 在 Windows 中安装 pthread 时遇到问题

问题描述

PHP版本: 7.4.5

我正在运行 PHP 的线程安全版本,因为php -i|findstr "Thread"我得到:

Thread Safety => enabled
Thread API => Windows Threads

我从以下网址下载了最新版本的 pthreads (3.1.6):https ://windows.php.net/downloads/pecl/releases/pthreads/3.1.6/ (我尝试了 32 位和 64 位版本)。

我将pthreadVC2.dll文件放在我的php\目录中,将php_pthreads.dll文件放在我的php\ext\目录中,并将该行添加extension=php_pthreads.dll到我的php.ini文件中

然后通过命令行运行任何 php 命令后(在我的情况下,php -v)我在尝试 32 位版本时在控制台中得到以下内容:

PHP Warning:  PHP Startup: Unable to load dynamic library 'php_pthreads.dll' (tried: C:\xampp\php\ext\php_pthreads.dll (%1 is not a valid Win32 application.), C:\xampp\php\ext\php_php_pthreads.dll.dll (The specified module could not be found.)) in Unknown on line 0

Warning: PHP Startup: Unable to load dynamic library 'php_pthreads.dll' (tried: C:\xampp\php\ext\php_pthreads.dll (%1 is not a valid Win32 application.), C:\xampp\php\ext\php_php_pthreads.dll.dll (The specified module could not be found.)) in Unknown on line 0
PHP 7.4.5 (cli) (built: Apr 14 2020 16:17:34) ( ZTS Visual C++ 2017 x64 )
Copyright (c) The PHP Group
Zend Engine v3.4.0, Copyright (c) Zend Technologies

尝试 64 位版本时出现此错误:

PHP Warning:  PHP Startup: Unable to load dynamic library 'php_pthreads.dll' (tried: C:\xampp\php\ext\php_pthreads.dll (The specified procedure could not be found.), C:\xampp\php\ext\php_php_pthreads.dll.dll (The specified module could not be found.)) in Unknown on line 0

Warning: PHP Startup: Unable to load dynamic library 'php_pthreads.dll' (tried: C:\xampp\php\ext\php_pthreads.dll (The specified procedure could not be found.), C:\xampp\php\ext\php_php_pthreads.dll.dll (The specified module could not be found.)) in Unknown on line 0
PHP 7.4.5 (cli) (built: Apr 14 2020 16:17:34) ( ZTS Visual C++ 2017 x64 )
Copyright (c) The PHP Group
Zend Engine v3.4.0, Copyright (c) Zend Technologies

有任何想法吗?

标签: phpphp-pthread

解决方案


如果有人遇到这种情况,那么为我解决的问题是将我的文件中的extension_dir设置修复为实际从同一目录中存在的文件夹中php.ini提取。ext该行已被注释掉,所以我认为它的默认设置是尝试从C:\php\ext.


推荐阅读