PHP 警告:无法加载动态库
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/6523504/
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
PHP Warning: Unable to load dynamic library
提问by StuStirling
Ok I have PHP working on my mac os x Apache 2 server. Problem I am having is it can't seem to find the extensions that allow me to connect to an sqlite database.
好的,我在我的 mac os x Apache 2 服务器上运行 PHP。我遇到的问题是它似乎无法找到允许我连接到 sqlite 数据库的扩展。
extension = php_sqlite.dll
extension = php_pdo_sqlite.dll
extension = php_sqlite3.dll
I get this error now that I have uncommented these extensions..
我现在收到这个错误,因为我已经取消了这些扩展的注释..
PHP Warning: PHP Startup: Unable to load dynamic library '/usr/lib/php/extensions/no-debug-non-zts-20090626/php_sqlite3.dll' - dlopen(/usr/lib/php/extensions/no-debug-non-zts-20090626/php_sqlite3.dll, 9): image not found in Unknown on line 0
It is the same error for all 3.
Now I have read in different places on the internet it could be that they aren't installed on my mac, but I can't find the PHP directory or anywhere where they would be!
I'm very new to this so any help would be grand
Disco
所有 3 个都是相同的错误。
现在我已经在互联网上的不同地方阅读过它们可能没有安装在我的 mac 上,但我找不到 PHP 目录或它们所在的任何地方!
我对此很陌生,所以任何帮助都是盛大的迪斯科舞厅
回答by Francois Deschenes
The DLL extension you've enabled are actually for Windows. On Mac and other *nix platforms, they're actually SO files.
您启用的 DLL 扩展实际上适用于 Windows。在 Mac 和其他 *nix 平台上,它们实际上是 SO 文件。
I'm on a Mac as well as it appears that the SQLite modules are already loaded. You should be able to comment out those lines in your php.ini
file, restart Apache and use SQLite without having to do anything. The SQLite modules have been included for as long as I can remember.
我在 Mac 上,而且似乎已经加载了 SQLite 模块。您应该能够注释掉php.ini
文件中的这些行,重新启动 Apache 并使用 SQLite,而无需执行任何操作。从我记事起,SQLite 模块就已包含在内。
If it's really not included, you'll have to compile the modules from source. That requires that you install the Apple Developer Tools.
如果确实没有包含,则必须从源代码编译模块。这要求您安装Apple Developer Tools。
To compile from scratch (from the command line):
从头开始编译(从命令行):
- Download the PHP's source code. You'll need to download the one that matches the version already installed on your system. To find out which one you're using, type
php -v
from the command line. - Extract the archive you downloaded using
tar -zxvf
followed by the filename. - Type
cd php-5.3.x/ext/sqlite3/
(where "5.3.x" should be replaced with your version number and "sqlite3" can be any of the modules you want to install from your list above minus the "php_" prefix). - Type
phpize
. - Type
./configure
. - Type
make
. - Type
sudo make install
. - Add
extension=sqlite3.so
to yourphp.ini
(again make sure to replace sqlite3.so with the name of the other extensions if you compile the others).
- 下载 PHP 的源代码。您需要下载与系统上已安装版本相匹配的版本。要找出您使用的是哪一种,请
php -v
从命令行键入。 - 使用
tar -zxvf
后跟文件名提取您下载的存档。 - 类型
cd php-5.3.x/ext/sqlite3/
(其中“5.3.x”应替换为您的版本号,“sqlite3”可以是您要从上面的列表中安装的任何模块减去“php_”前缀)。 - 键入
phpize
。 - 键入
./configure
。 - 键入
make
。 - 键入
sudo make install
。 - 添加
extension=sqlite3.so
到您的php.ini
(如果您编译其他扩展,再次确保将 sqlite3.so 替换为其他扩展的名称)。
Finally, restart Apache and you should be done.
最后,重新启动 Apache,您应该就完成了。
回答by mingos
Open php.ini. Look for the line that defines the location of your extensions. In my case (Windows machine), it goes like this:
打开 php.ini。查找定义扩展位置的行。在我的情况下(Windows 机器),它是这样的:
extension_dir = "C:\xampp\php\ext"
extension_dir = "C:\xampp\php\ext"
This gives you the location where all your extensions are located. Open it and check whether your SQLite extensions are indeed there.
这为您提供了所有扩展程序所在的位置。打开它并检查您的 SQLite 扩展是否确实存在。
Also, make sure your extensions are actually meant for a Mac computer. Their filename extension should be "dylib" or maybe "so" (not sure - I don't have a Mac), while "dll" is a Windows-specific dynamic library filename extension (AFAIK).
此外,请确保您的扩展程序实际上适用于 Mac 计算机。它们的文件扩展名应该是“dylib”或“so”(不确定 - 我没有 Mac),而“dll”是 Windows 特定的动态库文件扩展名(AFAIK)。
回答by minkyaw
Try removing and then reinstalling the packages:
尝试删除然后重新安装软件包:
brew rm mcrypt
brew install mcrypt