我有一个 Perl CGI 脚本,当我从命令行运行它时可以正常工作,./roster_return.cgi StudentID=101095
但是当我在 MAMP 中运行它时(http://localhost:8888/cgi-bin/roster_return.cgi?StudentID=101095)
,我的 apache 日志中出现以下错误:
[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 服务器的路径添加这个位置?
任何建议或帮助将不胜感激。谢谢!