OSX:PHP 错误 localhost 并且无法加载动态库
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/22384764/
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
OSX: PHP Error localhost and unable to load dynamic library
提问by cch
How can i fix this php error?
我该如何解决这个 php 错误?
PHP Warning: PHP Startup: Unable to load dynamic library '/usr/lib/php/extensions/no-debug-non-zts-20100525/php_pdo_mysql.dll' - dlopen(/usr/lib/php/extensions/no-debug-non-zts-20100525/php_pdo_mysql.dll, 9): image not found in Unknown on line 0
I am on a mac/mavericks and I have made a mistake and did a sudo cp /private/etc/php.ini.default /private/etc/php.iniso now I get the error stated above when I run php -v
我在 mac/mavericks 上,我犯了一个错误并做了一个,sudo cp /private/etc/php.ini.default /private/etc/php.ini所以现在我在运行时遇到了上面提到的错误php -v
采纳答案by cch
Originally, I followed these step-by-step guides to set up apache, php, mysql, etc and and get my localhost working:
最初,我按照这些分步指南来设置 apache、php、mysql 等,并让我的本地主机工作:
- http://brianflove.com/2013/10/23/os-x-mavericks-and-apache/
- http://coolestguidesontheplanet.com/install-mcrypt-php-mac-osx-10-9-mavericks-development-server/
- http://brianflove.com/2013/10/23/os-x-mavericks-and-apache/
- http://coolestguidesontheplanet.com/install-mcrypt-php-mac-osx-10-9-mavericks-development-server/
Then, I accidentally replaced my php.ini file and got the error stated above in the question. Actually, at first I got the mcryptmissing error.
然后,我不小心替换了我的 php.ini 文件,并在问题中得到了上述错误。实际上,起初我得到了mcrypt缺失的错误。
So, after fixing all of these, I had few things left to do in the php.ini file:
因此,在修复所有这些之后,我在 php.ini 文件中几乎没有要做的事情:
Declared mcrypt like this:
extension=mcrypt.soUncommented the extension_dir line and added:
extension_dir = "/usr/lib/php/extensions/no-debug-non-zts-20100525/"I commented out the line:
extension=php_pdo_mysql.dllDone a
sudo apachectl restart
像这样声明 mcrypt:
extension=mcrypt.so取消注释 extension_dir 行并添加:
extension_dir = "/usr/lib/php/extensions/no-debug-non-zts-20100525/"我注释掉了这一行:
extension=php_pdo_mysql.dll做了一个
sudo apachectl restart
Finally, everything works as is expected.
最后,一切都按预期进行。
回答by Aditya Seth
Follow this as it worked for me...
按照这个,因为它对我有用......
The error coming for me was:
我的错误是:
$ sudo php -v
# PHP Warning: PHP Startup: Unable to load dynamic library '/usr/lib/php/extensions/no-debug-non-zts-20121212/phalcon.so' - dlopen(/usr/lib/php/extensions/no-debug-non-zts-20121212/phalcon.so, 9): image not found in Unknown on line 0
# PHP 5.5.14 (cli) (built: Sep 9 2014 19:09:25)
# Copyright (c) 1997-2014 The PHP Group
# Zend Engine v2.5.0, Copyright (c) 1998-2014 Zend Technologies
Run this as root:
以 root 身份运行:
$ locate phalcon.so
# /opt/local/lib/php55/extensions/no-debug-non-zts-20121212/phalcon.so
Run this also as root:
也以 root 身份运行:
$ cp -rp /opt/local/lib/php55/extensions/no-debug-non-zts-20121212/phalcon.so /usr/lib/php/extensions/no-debug-non-zts-20121212/
Just edit the directories as they might differ for you.
只需编辑目录,因为它们可能对您有所不同。
回答by Delabi
In the php.ini file, if you had a unique extensions folder as required in macOS Sierra, make sure the extensions directory read like:
在 php.ini 文件中,如果您有 macOS Sierra 中所需的唯一扩展文件夹,请确保扩展目录如下所示:
extension=/usr/local/lib/php/extensions/mcrypt.so
It's easy to forget to add the first "/"
很容易忘记添加第一个“/”

