如何在MAMP中使用MacPorts的Perl安装?


1

我有MAMP 3.0.6和MacPorts 2.3.1。我需要使用一些Perl模块(通过一些CGI脚本),我将它们安装在MacPorts Perl安装上(例如p5.16-dbd-mysql),但我无法弄清楚如何让MAMP使用正确的Perl安装。一个错误如下:

install_driver(mysql) failed: Can't locate DBD/mysql.pm in @INC (@INC contains: ../../lib /Library/Perl/5.16/darwin-thread-multi-2level /Library/Perl/5.16 /Network/Library/Perl/5.16/darwin-thread-multi-2level /Network/Library/Perl/5.16 /Library/Perl/Updates/5.16.2 /System/Library/Perl/5.16/darwin-thread-multi-2level /System/Library/Perl/5.16 /System/Library/Perl/Extras/5.16/darwin-thread-multi-2level /System/Library/Perl/Extras/5.16 .) at (eval 10) line 3.
Perhaps the DBD::mysql perl module hasn't been fully installed,
or perhaps the capitalisation of 'mysql' isn't right.
Available drivers: DBM, ExampleP, File, Gofer, Proxy, SQLite, Sponge.

我尝试设置我的.bashrc文件,但它似乎没有帮助

export PERL5LIB=/opt/local/lib/perl5

我怎样才能解决这个问题?

Answers:


1

问题是MAMP-特别是MAMP中的Apache安装 - 无法看到模块。所以你需要在这个文件中调整Apache配置:

/Applications/MAMP/conf/apache/httpd.conf

要附加这样的内容 - 确保调整这些路径以匹配您的实际/工作环境 - 或者如果这些行已经存在则进行调整:

SetEnv PATH / opt / local / bin:/ opt / local / sbin:/ usr / local / bin:$ PATH

SetEnv PERL5LIB / usr / local / lib:/ opt / local / lib / perl5

然后在MAMP中重启Apache Web服务器,看看会发生什么。


谢谢。这肯定有帮助。现在我收到一个错误:Perl lib version (5.16.3) doesn't match executable 'the_path_to_cgi.cgi' version (v5.16.2) at /opt/local/lib/perl5/5.16.3/darwin-thread-multi-2level/Config.pm line 60.我已经升级了所有端口,重新启动了机器,但仍然看到了这一点。有什么建议?顺便说一句,它看起来像第二行需要:SetEnv PERL5LIB /usr/local/lib:/opt/local/lib/perl5/5.16.3
天花板猫

1
更新:事实证明我有另一个perl安装/usr/bin/perl。我改名了,现在工作正常。谢谢!
天花板猫

@ceilingcat很高兴为你效劳!我曾经假设我的作品“要有这样的东西附加到它......”暗示你必须调整这些路径以匹配你当地的环境。我可以看到它有点过于微妙的断言。所以我只是编辑了答案以澄清我的例子应该调整以匹配你的真实/工作环境。
JakeGould
By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.