我有一个Perl CGI脚本,当我使用./roster_return.cgi StudentID=101095
从命令行运行它时工作正常但是当我在MAMP (http://localhost:8888/cgi-bin/roster_return.cgi?StudentID=101095)
中运行它时,我的apache日志中出现以下错误:< / p>
[Wed May 02 10:56:47 2012] [error] [client 127.0.0.1] install_driver(mysql) failed: Can't load '/Library/Perl/5.10.0/darwin-thread-multi-2level/auto/DBD/mysql/mysql.bundle' for module DBD::mysql: dlopen(/Library/Perl/5.10.0/darwin-thread-multi-2level/auto/DBD/mysql/mysql.bundle, 1): Library not loaded: libmysqlclient.18.dylib
[Wed May 02 10:56:47 2012] [error] [client 127.0.0.1] Referenced from: /Library/Perl/5.10.0/darwin-thread-multi-2level/auto/DBD/mysql/mysql.bundle
[Wed May 02 10:56:47 2012] [error] [client 127.0.0.1] Reason: image not found at /System/Library/Perl/5.10.0/darwin-thread-multi-2level/DynaLoader.pm line 207.
[Wed May 02 10:56:47 2012] [error] [client 127.0.0.1] at (eval 11) line 3
[Wed May 02 10:56:47 2012] [error] [client 127.0.0.1] Compilation failed in require at (eval 11) line 3.
[Wed May 02 10:56:47 2012] [error] [client 127.0.0.1] Perhaps a required shared library or dll isn't installed where expected
[Wed May 02 10:56:47 2012] [error] [client 127.0.0.1] at /Users/jerickson/Desktop/helpfulscripts/cgi-bin/roster_return.cgi line 16
[Wed May 02 10:56:47 2012] [error] [client 127.0.0.1] Premature end of script headers: roster_return.cgi
我现在记得几年前我不得不将这一行添加到我的.bash_profile中:
export DYLD_LIBRARY_PATH="$DYLD_LIBRARY_PATH:/usr/local/mysql/lib/"
为了让命令行perl脚本工作。这可以解释为什么库没有从MAMP加载,因为它没有使用我的.bash_profile路径。我如何为MAMP服务器的路径添加此位置?
非常感谢任何建议或帮助。谢谢!
答案 0 :(得分:5)
您可以在VirtualHost配置中尝试Apache's mod_env:
SetEnv DYLD_LIBRARY_PATH path/to/libs
答案 1 :(得分:0)
您还可以将该行添加到apachectl
脚本:
export DYLD_LIBRARY_PATH="$DYLD_LIBRARY_PATH:/path/to/libs"
它通常位于Apache的 bin 目录中。我需要为项目加载 pdo_informix ,这是唯一让它工作的地方。