问题描述
我正在尝试使用MacPorts的PHP(mod_php53.so)在Mac OSX Yosemite中运行Apache.请注意,我使用的不是MacPorts的Apache,而是优胜美地的Apache和MacPorts的PHP.过去与OSX Mavericks和Mountain Lion配合使用时效果很好.
在优胜美地中运行/usr/sbin/apachectl -t时出现此错误:
事实上,/opt/local/lib/libaprutil-1.0.dylib的当前版本是6.4.0,因此它应该可以工作.
otool -L /opt/local/lib/libaprutil-1.0.dylib
/opt/local/lib/libaprutil-1.0.dylib:
/opt/local/lib/libaprutil-1.0.dylib (compatibility version 6.0.0, current version 6.4.0)
我猜想Apache正在加载位于/usr/lib中的系统的libaprutil-1.0.dylib:
otool -L /usr/lib/libaprutil-1.0.dylib
/usr/lib/libaprutil-1.0.dylib:
/usr/lib/libaprutil-1.0.dylib (compatibility version 4.0.0, current version 4.0.0)
这令人困惑,因为错误消息明确指出由于版本不兼容而未加载MacPorts的libaprutil,但我想它正在尝试使用系统的libaprutil,并且不知道如何强制Apache加载MacPorts的libaprutil. /p>
我已经尝试设置DYLD_LIBRARY_PATH
环境变量,但这无济于事.
有什么想法吗?
当环境包含DYLD_LIBRARY_PATH=/usr/lib
时,就会发生这种情况.取消设置,它应该可以工作.
在OS X上使用绝对路径来引用库.您已经正确地注意到/opt/local/apache2/modules/mod_php53.so
使用其绝对路径来引用/opt/local/lib/libaprutil-1.0.dylib
.但是,在DYLD_LIBRARY_PATH
存在的情况下,加载程序将忽略目录组件,并在DYLD_LIBRARY_PATH
中指定的目录中搜索文件名.
您看到的错误消息具有误导性:它试图告诉您尝试处理/opt/local/lib/libaprutil-1.0.dylib
加载命令的代码中发生了错误(由于env变量而被改编了).
此外,请注意,由于MacPorts是根据MacPorts Apache构建其PHP的,因此您的PHP模块不一定与系统Apache二进制兼容.它可能对您有用,但这只是一个巧合.
I'm trying to run Apache in Mac OSX Yosemite using MacPorts' PHP (mod_php53.so). Note that I'm not using MacPorts' Apache but Yosemite's Apache with MacPorts' PHP. This was working fine with OSX Mavericks and Mountain Lion in the past.
I get this error when running /usr/sbin/apachectl -t in Yosemite:
In fact, /opt/local/lib/libaprutil-1.0.dylib current version is 6.4.0, so it should work.
otool -L /opt/local/lib/libaprutil-1.0.dylib
/opt/local/lib/libaprutil-1.0.dylib:
/opt/local/lib/libaprutil-1.0.dylib (compatibility version 6.0.0, current version 6.4.0)
I guess that Apache is loading the system's libaprutil-1.0.dylib located in /usr/lib:
otool -L /usr/lib/libaprutil-1.0.dylib
/usr/lib/libaprutil-1.0.dylib:
/usr/lib/libaprutil-1.0.dylib (compatibility version 4.0.0, current version 4.0.0)
This is confusing because the error message clearly states that MacPorts' libaprutil was not load because of version incompatibility but I guess it is trying to use the system's libaprutil and don't know how to force Apache to load MacPorts' libaprutil.
I already tried to set the DYLD_LIBRARY_PATH
environment variable, but that did not help.
Any ideas?
This happens when the environment contains DYLD_LIBRARY_PATH=/usr/lib
. Unset that and it should work.
Libraries are referenced using absolute paths on OS X. You correctly noticed /opt/local/apache2/modules/mod_php53.so
references /opt/local/lib/libaprutil-1.0.dylib
using its absolute path. However, in the presence of DYLD_LIBRARY_PATH
the loader ignores the directory components and searches for the filename in the directories specified in DYLD_LIBRARY_PATH
.
The error message you see is misleading: It is trying to tell you that an error occurred in the code that attempted to handle the /opt/local/lib/libaprutil-1.0.dylib
load command (which was diverted due to the env variable).
Also, note that since MacPorts builds its PHP against MacPorts Apache, your PHP module is not necessarily binary-compatible to the system Apache. It might work for you, but that's only a coincidence.
这篇关于Mac OSX如何确定要加载的Dylib?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!