Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Upgrade Phusion Passenger without reinstalling Nginx

Is it possible to upgrade Phusion Passenger to a newer version when it is already running (with Nginx in my case)?

I installed Passenger 4.0.0.rc6 using passenger-install-nginx-module. My Nginx config now contains

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

Now I want to upgrade to Passenger 4.0.2. I can install the gem, but when I run passenger-install-nginx-module again, it tries to recompile and reinstall Nginx. (I thought it would be so clever to notice there is already a installed Nginx in the location I specify using --prefix)

I tried to manually change passenger_root to the new Passenger gem location but the I get the following error in the Nginx error log:

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)

Apparently the PassengerWatchdog is built when running passenger-install-nginx-module. I don't want to copy over PassengerWatchdog from the old gem because something might have changed.

So... what is the proper way to upgrade Passenger without recompiling and reinstalling Nginx (or Apache)?

like image 719
Manuel Meurer Avatar asked May 12 '13 12:05

Manuel Meurer


2 Answers

@Wukerplank's comment put me on the right track. I checked the output when running passenger-install-nginx-module again and it says:

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.

The important part being that Nginx has to be recompiled to work with Passenger and that existing Nginx configurations are preserved.

So the right way to upgrade Passenger is to

  1. install the new Passenger gem
  2. execute passenger-install-nginx-module with exactly the same parameters as the first time (so the same Nginx version and modules are compiled, it's installed in the same directory etc.)
  3. before installing, check that it says "Welcome to the Phusion Passenger Nginx module installer, v4.0.2." with the new version on top (4.0.2 in my case)
  4. after Nginx is installed, change the passenger_root in your existing Nginx conf (path/to/nginx/conf/nginx.conf) to point to the new gem version (just replace the old version number with the new)
  5. Restart Nginx
  6. Profit
like image 156
Manuel Meurer Avatar answered Nov 07 '22 19:11

Manuel Meurer


You cannot upgrade without recompiling Nginx. Full upgrade instructions can be found in the Phusion Passenger for Nginx manual. From the manual:

Nginx is a different from other web servers in that it does not support loadable modules. The only way to extend Nginx is to recompile it entirely from source. Since Phusion Passenger consists of some external executables plus an Nginx module, you must recompile Nginx when first installing Phusion Passenger, but also when upgrading Nginx itself or when upgrading the Phusion Passenger version.

Recompiling Nginx and the Phusion Passenger executables is what we will do in this step. The good news is that Phusion Passenger provides a tool to make this easy for you.

If you’ve already installed Nginx before, but without Phusion Passenger support, then you should uninstall it first. You don’t have to, because you can also install another Nginx with Phusion Passenger support, in parallel to the existing Nginx. We merely recommend uninstalling the existing in order to avoid user confusion, but the choice is yours.

If you had previously installed Nginx with Phusion Passenger support, and you are upgrading, then you don’t have to uninstall your existing Nginx first. Instead we’ll overwrite it this step. But it is important that you recompile Nginx with the configure parameters that you used last time.

like image 43
Hongli Avatar answered Nov 07 '22 20:11

Hongli