【问题标题】:Modify DYLD_LIBRARY_PATH for Apache? Perl CGI script not working when connecting to MySQL为 Apache 修改 DYLD_LIBRARY_PATH?连接到 MySQL 时 Perl CGI 脚本不起作用
【发布时间】:2012-05-12 04:20:27
【问题描述】:

我有一个 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 服务器的路径添加此位置??

任何建议或帮助将不胜感激。谢谢!

【问题讨论】:

    标签: mysql perl apache cgi dbi


    【解决方案1】:

    您可以在 VirtualHost 配置中尝试Apache's mod_env

    SetEnv DYLD_LIBRARY_PATH path/to/libs
    

    【讨论】:

      【解决方案2】:

      您也可以将这一行添加到apachectl 脚本中:

      export DYLD_LIBRARY_PATH="$DYLD_LIBRARY_PATH:/path/to/libs"

      它通常在 Apache 的 bin 目录中。我需要为一个项目加载 pdo_informix,这是唯一让它工作的地方。

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2012-12-28
        • 2010-11-16
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2012-10-15
        • 2023-03-17
        • 1970-01-01
        相关资源
        最近更新 更多