尝试在 Apache 上 运行 乘客时出现问题

Issue when trying to run passenger on Apache

我在 运行

时遇到了这个问题

httpd -t

httpd: Syntax error on line 545 of /private/etc/apache2/httpd.conf: Syntax error on line 1 of /private/etc/apache2/other/passenger.conf: Cannot load /Users/sbaidon/.rvm/gems/ruby-2.2.5/gems/passenger-5.3.5/b uildout/apache2/mod_passenger.so into server: dlopen(/Users/sbaidon/.rvm/gems/ruby-2.2.5/gems/passenger-5.3.5/buildout/apache2/mod_passenger.so, 10): no suitable image found. Did find:\n\t/Users/sbaidon/.rv m/gems/ruby-2.2.5/gems/passenger-5.3.5/buildout/apache2/mod_passenger.so: code signature in (/Users/sbaidon/.rvm/gems/ruby-2.2.5/gems/passenger-5.3.5/buildout/apache2/mod_passenger.so) not valid for use in p rocess using Library Validation: mapped file has no cdhash, completely unsigned? Code has to be at least ad-hoc signed.\n\t/Users/sbaidon/.rvm/gems/ruby-2.2.5/gems/passenger-5.3.5/buildout/apache2/mod_passen ger.so: stat() failed with errno=22

客运安装就好

我 运行 也对此感兴趣:问题是 macOS Mojave 附带的内置 httpd 启用了库验证,这意味着它加载的任何模块都必须正确签名。不幸的是,mod_passenger.so 没有签名,所以加载失败。实际上,很多人在 macOS Mojave 上加载 Apache 模块时遇到这个问题(尤其是在 beta 期间),一些示例参考:

https://github.com/GrahamDumpleton/mod_wsgi/issues/357 https://github.com/phpredis/phpredis/issues/1406

我相信可以在某处设置一个 plist 以授权 httpd 禁用库验证(com.apple.security.cs.disable-library-validation),如 https://developer.apple.com/documentation/security/com_apple_security_cs_disable-library-validation. For instance, here's a recent WebKit patch where they add it to allow plugin loading: https://bugs.webkit.org/show_bug.cgi?id=183252. Similarly, here's the Mozilla people talking about how they need to enable this (and other) properties: https://bugzilla.mozilla.org/show_bug.cgi?format=default&id=1470597.

中所述

不幸的是,我不做 macOS 开发(我只是在 macOS 上做开发)而且我完全不知道如何将它应用到内置的 Apache,我对不起。

在这一点上,我有点厌倦了每一个主要的 macOS 更新都会削弱我所有的 httpd 设置并且通常是一种痛苦(它不常见但仍然很烦人),所以我正在做我几年前应该做的事情: 停止使用 OS/X 自带的内置 httpd,只使用 Homebrew httpd.

这是我找到的一些关于设置 Homebrew httpd(和禁用内置 macOS httpd)的说明,它非常简单,您不必遵循 all关于多个 PHP 版本等的说明:https://getgrav.org/blog/macos-mojave-apache-multiple-php-versions

如果有人知道如何在内置的 httpd 中禁用库验证,或者是否有某种方法可以提供登录 mod_passenger.so(似乎不太可能,因为 Homebrew 和 gem passenger 需要从源代码构建),你不需要垃圾内置的 httpd.但我个人认为最好的解决方案是完全摆脱它并改用 Homebrew 版本。

对于在 macOS Mojave 中遇到此问题或任何库验证问题的人,我发现了一个非常简单的修复方法来禁用它。 https://github.com/mologie/macos-disable-library-validation

这已在 macOS 10.14.4 中修复