Deploying a Rails app using Capistrano to an Ubuntu VM running Apache with Passenger enabled.
I followed this tutorial: https://www.phusionpassenger.com/library/install/apache/install/oss/trusty/ with a few changes given that I'm on 17.04, not 14.04 LTS.
passenger-config validate-install says everything looks fine with both Passenger and Apache. passenger-memory-stats shows both Passenger and Apache processes.
I have sudo apache2ctl restarted several times, with no warnings. But passenger-status, and therefore the passenger-config restart-app that Capistrano runs, reports that Passenger "doesn't seem to be running." So my deploy stops.
There's only one Ruby on the machine, ruby-2.4.1 installed using ruby-install. I have apt-get update and upgraded in case of version mismatches.
Apache logs don't show any errors, certainly none related to Passenger.
Why would Passenger internally disagree, saying that it's both configured properly and there are processes running, but then later saying that it's not running?
I needed to customize the instance registry directory, as suggested by Tony Vincent:
/etc/apache2/mods-enabled/passenger.conf on the server:
PassengerInstanceRegistryDir /home/MYUSER/passenger_temp
config/deploy/production.rb in the Rails app:
set :default_env, { 'PASSENGER_INSTANCE_REGISTRY_DIR' => '/home/MYUSER/passenger_temp' }
Sorry to harp on this but did you run passenger-config validate-install on the ubuntu server (not osx)? Same for passenger-memory-stats and sudo apache2ctl restart.
Based on /tmp not having a passenger.randomstring dir, it sounds like you are confusing local and remote commands. /tmp is the default location for PassengerInstanceRegistryDirs on Ubuntu so if Passenger is running there should be a dir in /tmp that starts with passenger..
Related
I have a ROR app (version 6.1.4.1) with Ruby 2.7.4 on a Raspberry Pi 4 with 4 GB RAM and a 32 GB SD card. I installed Passenger 6.0.12 using the tarball installation and am running it with nginx. passenger start in the app directory works successfully, but when I try running it as with nginx (/opt/nginx/sbin/nginx) on port 80, I get the above error when visiting the site.
I'm accessing the app via IP address, which is configured in the nginx.conf and the app is installed in /home/pi/src/bogie_can. There is a .bundle directory with a config file in the app directory, and that's where the gems are installed. I'm running the app in "development" mode, which is configured in the server section of the nginx.conf file using passenger_app_env.
The specific error is that the app cannot find racc-1.5.2. The Bundler info is #<struct Bundler::Settings::Path explicit_path="/home/pi/src/bogie_can/.bundle", system_path=false, default_install_uses_path=false>.. So, we note that the .bundle path is correct and in the .bundle/ruby/2.7.0/gems/ directory, racc-1.5.2 is indeed installed and owned by the user "pi".
I've cleared out old bundle installations and tried switching the app user from pi to root (which was nobody) and back. Also, I'm using rbenv, so I also ran rbenv rehash after the fresh bundle install. I've also carefully reviewed the "Detailed diagnostics" from the Passenger error page (which is super helpful!) and do not see anything that is obviously wrong.
Using the Passenger error page as a guide, it seems that:
The gems are indeed installed as needed
The user, either root or pi, have permissions to access the gems
pi is a reasonable user to run the app
The passenger_root and passenger_ruby are coming from the passenger-config about subcommands and are verified as well.
At this point, there must be some configuration I've overlooked or gotten wrong and I would greatly appreciate some questions and pointers.
I found the root cause of the problem.
I had set passenger_ruby to the result of passenger-command about ruby-command, which gave me:
passenger-config was invoked through the following Ruby interpreter:
Command: /usr/bin/ruby2.7
Version: ruby 2.7.4p191 (2021-07-07 revision a21a3b7d23) [arm-linux-gnueabihf]
To use in Apache: PassengerRuby /usr/bin/ruby2.7
To use in Nginx : passenger_ruby /usr/bin/ruby2.7
To use with Standalone: /usr/bin/ruby2.7 /usr/src/passenger-6.0.12/bin/passenger start
The following Ruby interpreter was found first in $PATH:
Command: /home/pi/.rbenv/shims/ruby
Version: ruby 2.7.4p191 (2021-07-07 revision a21a3b7d23) [arm-linux-gnueabihf]
To use in Apache: PassengerRuby /home/pi/.rbenv/shims/ruby
To use in Nginx : passenger_ruby /home/pi/.rbenv/shims/ruby
To use with Standalone: /home/pi/.rbenv/shims/ruby /usr/src/passenger-6.0.12/bin/passenger start
I was using /usr/bin/ruby2.7 and having the problem with racc not being found. I switched it to use the rbenv shim and Passenger was able to correctly find all the gems in the [APP_ROOT]/.bundle/ directory
I also cleared out the default nginx installation, which was still trying to be started with nginx.service and then added my own /etc/init.d/nginx script and added it to the init.d database so that it now starts with the OS.
Upgrading passenger to 5.1.11 makes all my requests fail with HTTP status code 403, downgrading to 5.1.10 works. I run nginx as root and all my rails applications reside in my non-root user's home directory. passenger and nginx-extras were installed from passenger apt repos as decribed here. There is no error in nginx or rails application logs other than the 403 status in access logs.
I have verified that all the rails application directories and their parent directories have read and executable permissions enabled for all users in the system.
I think this has something to do with https://blog.phusion.nl/2017/10/13/passenger-security-advisory-5-1-11/. What should I do to fix it?
OS: Ubuntu 17.04
Nginx: 1.10.3
Edit: you mentioned your OS is 17.04 and not 17.10. Phusion's instructions for 17.04 tell you to remove nginx-extras, not to install it (as you say you've done).
So, for 17.04, try removing nginx-extras, then installing nginx and libnginx-mod-http-passenger.
--
You list your OS as Ubuntu 17.10 Artful, but the instructions you linked are for Ubuntu 17.04 Zesty, so that's not going to work.
Ubuntu 17.10 was released yesterday, there are no Passenger packages for it yet (usually available when the next Passenger version is released).
You can either wait for those packages or install Passenger via gem or tarball (Option Other: www.phusionpassenger.com/library/install/nginx/install/oss/).
After update to version 5.0.18 passenger standalone refuses to perform graceful restart with command passenger-config restart-app if there are several passenger intances running on the same machine.
Configuration:
ruby 2.2.3
cuba
passenger standalone 5.0.14 and 5.0.18 involved
reproduced on Mint 17.1 and CentOS 6.4
For example, two passengers with application group names sample_app1 and sample_app2 are running, from folder sample1 and from folder sample2. passenger-config restart-app surprisingly detects several passenger instances even if full path to application folder or application group name passed:
$ passenger-config restart-app path_to_app/sample1
$ passenger-config restart-app --name sample_app1
$ cd path_to_app/sample1 && passenger-config restart-app .
These commands produce the same output:
It appears that multiple Phusion Passenger instances are running. Please select
a specific one by passing:
--instance
The following Phusion Passenger instances are running:
Name Description
------------------------------------------------------------------
oithHie6 nginx/1.8.0 Phusion_Passenger/5.0.14
uftk5e6O nginx/1.8.0 Phusion_Passenger/5.0.18
Is there any other way to make passenger restart gracefully, without using --instance option? Any ideas would be greatly appreciated.
This is normal, even in versions before 5.0.18. Passenger Standalone does not run multiple apps inside the same Passenger instances. Instead, you are starting up multiple Passenger instances. Passing a path to passenger-config restart-app only selects the app within a specific Passenger instance, but does not select which Passenger instance you want to communicate with.
You can solve this problem by setting a different instance registry dir per app, so that it is unambiguous which Passenger instance you are communicating with: https://www.phusionpassenger.com/library/config/standalone/reference/#--instance-registry-dir-instance_registry_dir
I have done a Phusion Passenger setup on Ubuntu 10.04, with Apache2. Whenever I restart the Apache server I got the following error message, and the Rails application is not running.
[error] *** Passenger could not be initialized because of this error: Unable to start the Phusion Passenger watchdog because its executable (/usr/lib/phusion-passenger/agents/PassengerWatchdog) does not exist. This probably means that your Phusion Passenger installation is broken or incomplete, or that your 'PassengerRoot' directive is set to the wrong value. Please reinstall Phusion Passenger or fix your 'PassengerRoot' directive, whichever is applicable.
I ran into the same problem when compiling from source, but it was intermittent, which was really frustrating (I think it has to w/ Rails environments). We couldn't use the passenger-install-apache2-module/passenger-install-nginx-module scripts, because we needed a customized nginx installation.
I finally fixed the problem by going to whatever the passenger-config --root is, then running: rake nginx.
Update February 2016 (by Passenger author):
The officially supported method to compile PassengerAgent (without also compiling Nginx, as passenger-install-nginx-module does) is with this command:
passenger-config compile-agent
Passenger 5.0.26 and later will automatically detect the error described in this StackOverflow question, and will automatically suggest running the above command.
I've just hit this error myself and struggled to find a good answer, so here's my writeup.
In my setup I'm going for Ubuntu, Apache2, the latest Passenger and Rails 2.3.
Install Ruby and Rubygems NB: make (very) sure your gem -v is correct, if it's wrong you'll do all this twice
sudo gem install passenger
cd /usr/lib
wget http://rubyforge.org/frs/download.php/76005/passenger-3.0.12.tar.gz
tar zxvf passenger-3.0.12.tar.gz
cd passenger-3.0.12
./bin/passenger-install-apache2-module
Add export PATH=/var/lib/gems/1.8/bin:$PATH to ~/.bashrc
ln -s /usr/lib/passenger-3.0.12 /usr/share/phusion-passenger # => this fixes a world of hurt to do with PassengerWatchdog. NB: PassengerWatchdog doesn't come down with apt-get which is why we grabbed the binaries.
ln -s /usr/lib/passenger-3.0.12 /usr/lib/phusion-passenger # => similar issues.
This is from memory following thrashing it through for the last day and a half, I'll tidy up when I have to go through it again.
Try to install passenger module by running script passenger-install-apache2-module .
I had same problem but on nginx; I installed passenger via gem and then recompiled nginx manually with passenger module - this caused error described by you. After running passenger-install-nginx-module such error disappeared.
It had been a while since I had restarted nginx and in the meantime the path to passenger had changed. I looked in the nginx.conf to see what the passenger_root was set to and realized that it was the old value:
http {
passenger_root /home/nginx/rails_app/myapp/shared/bundle/ruby/1.9.1/gems/passenger-enterprise-server-3.0.17;
There are often two places to change:
server {
listen 8888;
root /home/nginx/rails_app/myapp/current/public;
I restarted nginx and the error was gone.
I had the same issue on my Nginx-Server.
In my case, the passenger_root directory was not correct, because of gem update.
[1] On Linux, i searched the passenger Directory with the following Command:
find / -name PassengerWatchdog
[2] Now i changed my 'passenger_root' Value to this Directory.
[3] And restart the Server.
suvankar, Maybe you should change your Passenger Path too.
The problem is simple.
I use the following command to install Passenger
passenger-install-nginx-module
When Passenger automatically installs nginx, I can't launch it.
nginx -v
Returns there's no nginx installed.
How can I fix this?
Notice that passenger-install-nginx-module asks you where to install Nginx to? The nginx binary is in there. Make sure the appropriate directory is in your $PATH. If you don't know what $PATH is or how to use it then you should read a book about basic Unix/Linux command line skills.
You need install Nginx. the webserver.
If you use passenger 3 in standalone, you just need launch passenger start command
I solved this.
Actually, Passenger did install nginx, it just wasn't in the default category.
I recommend to tell passenger to install nginx in /usr/local/nginx