升级Phusion Passenger而不重新安装Nginx

时间:2013-05-12 12:44:35

标签: ruby-on-rails nginx passenger

是否可以将Phusion Passenger升级到更新的版本(在我的情况下使用Nginx)?

我使用passenger-install-nginx-module安装了Passenger 4.0.0.rc6。我的Nginx配置现在包含

passenger_root /usr/local/lib/ruby/gems/2.0.0/gems/passenger-4.0.rc6;
passenger_ruby /usr/local/bin/ruby;

现在我想升级到Passenger 4.0.2。我可以安装gem,但是当我再次运行passenger-install-nginx-module时,它会尝试重新编译并重新安装Nginx。 (我认为在我使用--prefix指定的位置已经安装了Nginx会非常聪明。)

我尝试手动将passenger_root更改为新的Passenger gem位置,但是我在Nginx错误日志中收到以下错误:

2013/05/12 12:30:13 [alert] 14298#0: Unable to start the Phusion Passenger watchdog because its executable (/usr/local/lib/ruby/gems/2.0.0/gems/passenger-4.0.2/agents/PassengerWatchdog) does not exist. This probably means that your Phusion Passenger installation is broken or incomplete, or that your 'passenger_root' directive is set to the wrong value. Please reinstall Phusion Passenger or fix your 'passenger_root' directive, whichever is applicable. (-1: Unknown error)

显然PassengerWatchdog是在运行passenger-install-nginx-module时构建的。我不想复制旧宝石上的PassengerWatchdog因为某些东西可能已经改变了。

那么......在不重新编译和重新安装Nginx(或Apache)的情况下升级Passenger的正确方法是什么?

2 个答案:

答案 0 :(得分:17)

@ Wukerplank的评论让我走上正轨。我再次运行passenger-install-nginx-module时检查了输出,它说:

Nginx doesn't support loadable modules such as some other web servers do,
so in order to install Nginx with Passenger support, it must be recompiled.

Do you want this installer to download, compile and install Nginx for you?

 1. Yes: download, compile and install Nginx for me. (recommended)
    The easiest way to get started. A stock Nginx 1.4.1 with Passenger
    support, but with no other additional third party modules, will be
    installed for you to a directory of your choice.

 2. No: I want to customize my Nginx installation. (for advanced users)
    Choose this if you want to compile Nginx with more third party modules
    besides Passenger, or if you need to pass additional options to Nginx's
    'configure' script. This installer will  1) ask you for the location of
    the Nginx source code,  2) run the 'configure' script according to your
    instructions, and  3) run 'make install'.

Whichever you choose, if you already have an existing Nginx configuration file,
then it will be preserved.

重要的是,Nginx必须重新编译才能与Passenger一起使用,并保留现有的Nginx配置。

因此升级Passenger的正确方法是

  1. 安装新的Passenger gem
  2. 使用与第一次完全相同的参数执行passenger-install-nginx-module(因此编译相同的Nginx版本和模块,它安装在同一目录中等。)
  3. 在安装之前,检查它是否显示“欢迎使用Phusion Passenger Nginx模块安装程序,v4.0.2”。最新版本(在我的情况下为4.0.2)
  4. 安装Nginx后,更改现有Nginx conf中的passenger_root(路径/到/ nginx / conf / nginx.conf)以指向新的gem版本(只需用旧版本替换旧版本号) )
  5. 重新启动Nginx
  6. 利润

答案 1 :(得分:5)

如果不重新编译Nginx,则无法升级。完整升级说明可在the Phusion Passenger for Nginx manual中找到。从手册:

  

Nginx与其他Web服务器的不同之处在于它不支持可加载模块。扩展Nginx的唯一方法是完全从源代码重新编译它。由于Phusion Passenger由一些外部可执行文件和一个Nginx模块组成,因此在首次安装Phusion Passenger时,以及升级Nginx本身或升级Phusion Passenger版本时,必须重新编译Nginx。

     

我们将在此步骤中重新编译Nginx和Phusion Passenger可执行文件。好消息是,Phusion Passenger提供了一种工具,使您可以轻松使用。

     

如果您之前已经安装过Nginx,但没有Phusion Passenger支持,那么您应该先卸载它。您不必这样做,因为您还可以与现有的Nginx并行安装另一个具有Phusion Passenger支持的Nginx。我们只是建议卸载现有的以避免用户混淆,但选择权在你手中。

     

如果您之前已经安装了具有Phusion Passenger支持的Nginx,并且您正在升级,那么您不必先卸载现有的Nginx。相反,我们将在此步骤覆盖它。但是,使用上次使用的配置参数重新编译Nginx非常重要。

相关问题