在 Windows 中运行 PHP:如何解决“PHP 启动:无法加载动态库”问题?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/25415339/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Running PHP in Windows: how to fix "PHP Startup: Unable to load dynamic library" issues?
提问by Don Korleone
I have determined path to php folder and trying to run some php file and getting this message from command line.
我已经确定了 php 文件夹的路径并尝试运行一些 php 文件并从命令行获取此消息。
Microsoft Windows [Version 6.3.9600]
(c) 2013 Microsoft Corporation. All rights reserved.
C:\Users\U1>php
Failed loading \usr\local\php5\ext\php_xdebug-2.2.0-5.3-vc9.dll
PHP Warning: PHP Startup: Unable to load dynamic library '/usr/local/php5/ext\php_curl.dll' - The specified module could not be found.
in Unknown on line 0
<!--error-->
Warning: PHP Startup: Unable to load dynamic library '/usr/local/php5/ext\
php_curl.dll' - The specified module could not be found.
in Unknown on line 0
<script language=JavaScript src='/denwer/errors/phperror_js.php'></script>PHP Wa
rning: PHP Startup: Unable to load dynamic library '/usr/local/php5/ext\php_gd2
.dll' - The specified module could not be found.
in Unknown on line 0
<!--error-->
Warning: PHP Startup: Unable to load dynamic library '/usr/local/php5/ext\php_gd
2.dll' - The specified module could not be found.
in Unknown on line 0
<script language=JavaScript src='/denwer/errors/phperror_js.php'></script>PHP Wa
rning: PHP Startup: Unable to load dynamic library '/usr/local/php5/ext\php_mbstring.dll' - The specified module could not be found.
in Unknown on line 0
<!--error-->
Warning: PHP Startup: Unable to load dynamic library '/usr/local/php5/ext\php_mb
string.dll' - The specified module could not be found.
in Unknown on line 0
<script language=JavaScript src='/denwer/errors/phperror_js.php'></script>PHP Wa
rning: PHP Startup: Unable to load dynamic library '/usr/local/php5/ext\php_mysql.dll' - The specified module could not be found.
in Unknown on line 0
<!--error-->
Warning: PHP Startup: Unable to load dynamic library '/usr/local/php5/ext\php_my
sql.dll' - The specified module could not be found.
in Unknown on line 0
<script language=JavaScript src='/denwer/errors/phperror_js.php'></script>PHP Wa
rning: PHP Startup: Unable to load dynamic library '/usr/local/php5/ext\php_mys
qli.dll' - The specified module could not be found.
in Unknown on line 0
<!--error-->
Warning: PHP Startup: Unable to load dynamic library '/usr/local/php5/ext\php_my
sqli.dll' - The specified module could not be found.
in Unknown on line 0
<script language=JavaScript src='/denwer/errors/phperror_js.php'></script>PHP Wa
rning: PHP Startup: Unable to load dynamic library '/usr/local/php5/ext\php_pdo
_mysql.dll' - The specified module could not be found.
in Unknown on line 0
<!--error-->
Warning: PHP Startup: Unable to load dynamic library '/usr/local/php5/ext\php_pd
o_mysql.dll' - The specified module could not be found.
in Unknown on line 0
<script language=JavaScript src='/denwer/errors/phperror_js.php'></script>PHP Wa
rning: PHP Startup: Unable to load dynamic library '/usr/local/php5/ext\php_pdo
_sqlite.dll' - The specified module could not be found.
in Unknown on line 0
<!--error-->
Warning: PHP Startup: Unable to load dynamic library '/usr/local/php5/ext\php_pd
o_sqlite.dll' - The specified module could not be found.
in Unknown on line 0
<script language=JavaScript src='/denwer/errors/phperror_js.php'></script>PHP Wa
rning: PHP Startup: Unable to load dynamic library '/usr/local/php5/ext\php_sql
ite.dll' - The specified module could not be found.
in Unknown on line 0
<!--error-->
Warning: PHP Startup: Unable to load dynamic library '/usr/local/php5/ext\php_sq
lite.dll' - The specified module could not be found.
in Unknown on line 0
<script language=JavaScript src='/denwer/errors/phperror_js.php'></script>PHP Wa
rning: PHP Startup: Unable to load dynamic library '/usr/local/php5/ext\php_soa
p.dll' - The specified module could not be found.
in Unknown on line 0
<!--error-->
Warning: PHP Startup: Unable to load dynamic library '/usr/local/php5/ext\php_so
ap.dll' - The specified module could not be found.
in Unknown on line 0
<script language=JavaScript src='/denwer/errors/phperror_js.php'></script>PHP Wa
rning: PHP Startup: Unable to load dynamic library '/usr/local/php5/ext\php_sql
ite3.dll' - The specified module could not be found.
in Unknown on line 0
<!--error-->
Warning: PHP Startup: Unable to load dynamic library '/usr/local/php5/ext\php_sq
lite3.dll' - The specified module could not be found.
in Unknown on line 0
<script language=JavaScript src='/denwer/errors/phperror_js.php'></script>PHP Wa
rning: PHP Startup: Unable to load dynamic library '/usr/local/php5/ext\php_xsl
.dll' - The specified module could not be found.
in Unknown on line 0
<!--error-->
Warning: PHP Startup: Unable to load dynamic library '/usr/local/php5/ext\
php_xsl.dll' - The specified module could not be found.
in Unknown on line 0
<script language=JavaScript src='/denwer/errors/phperror_js.php'></script>
^A
All libraries are open on php.ini file. I have checked them all. I am wondering why command line tries to run library in incorrect path like
所有库都在 php.ini 文件中打开。我都检查过了。我想知道为什么命令行尝试在不正确的路径中运行库,例如
'/usr/local/php5/ext\php_xsl.dll'
Does it should be like
是不是应该像
'/usr/local/php5/ext/php_xsl.dll'
?
?
回答by Sverri M. Olsen
Open your php.ini
fileand set the following setting to a Windowsfile path:
打开您的php.ini
文件并将以下设置设置为Windows文件路径:
extension_dir = "X:/path/to/your/php/ext"
On Windows, paths that point to something on a normal hard drive have to start with a letter and then a colon, like "C:
". Paths that startwith a forward slash, /
, are Unix-like paths, and will not work on Windows.
在 Windows 上,指向普通硬盘驱动器上某些内容的路径必须以字母开头,然后是冒号,例如“ C:
”。以正斜杠 ,开头的路径/
是类 Unix 路径,在 Windows 上不起作用。
回答by NoDataFound
Adjust the following value in php.ini:
在 php.ini 中调整以下值:
; Directory in which the loadable extensions (modules) reside.
extension_dir = "C:\path to extension directory"
回答by Optimae
You can also specify the extensions directory without using the full path if it's in the same folder, at least in PHP 7.2.5 (have not tested other versions).
如果扩展目录在同一文件夹中,您也可以指定扩展目录而不使用完整路径,至少在 PHP 7.2.5 中(尚未测试其他版本)。
Example:
例子:
extension_dir = "ext"
extension_dir = "ext"
Where ext
is your extensions directory.
ext
你的扩展目录在哪里。