9

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?

dfaulken
  • 476
  • 8
  • 18
  • There's a 17.04 tutorial here: https://www.phusionpassenger.com/library/install/apache/install/oss/zesty/ – Camden Narzt Sep 05 '17 at 16:40
  • What users are you testing with vs running capistrano as? and can you dump the shell env here for both? – Camden Narzt Sep 05 '17 at 16:41
  • Camden thanks, the steps in the tutorial are the same as far as I can see. Only one user for the moment for both setup and deploy. There's a couple semi-sensitive things in the ENV, but I can give you `PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin`. Nothing in there specifically related to Passenger (like customizing the instance registry directory). Let me know if any other ENV values would help you. – dfaulken Sep 05 '17 at 17:05
  • Is `$TMPDIR` the same in both envs? – Camden Narzt Sep 05 '17 at 17:52
  • Sorry, I misunderstood your question before. I have one remote and one local user. On the server (Ubuntu) `$TMPDIR` is not set. Locally (OSX) it's `/var/folders/50/m8x23f6s7lg6pb2sxpx_47g4m2j3m8/T/`. – dfaulken Sep 05 '17 at 17:59
  • You have to test the commands via ssh on the server, your local osx user environment isn't relevant. When I asked about the users I meant the user capistrano uses and the ssh user you log in as to run commands on the server. – Camden Narzt Sep 05 '17 at 20:08
  • Ah, okay. Then I didn't misunderstand. Just one remote user, whose `$TMPDIR` is unset. The `PATH` I gave you was remote as well. – dfaulken Sep 05 '17 at 20:20
  • Do you set the `PassengerInstanceRegistryDir`? If so then your CLI tools need the `PASSENGER_INSTANCE_REGISTRY_DIR` env var set to the same value. – Camden Narzt Sep 07 '17 at 16:47
  • No, I haven't set that value anywhere. – dfaulken Sep 07 '17 at 18:43
  • Then is there a `passenger.randomstring` dir in `/tmp`? – Camden Narzt Sep 08 '17 at 14:03
  • you might have multiple passenger installations – Saiqul Haq Sep 08 '17 at 17:34
  • Camden, no, that was locally (OSX). – dfaulken Sep 08 '17 at 19:24
  • Saiqul — how would I check? I believe I have only one Ruby on the machine at all. – dfaulken Sep 08 '17 at 19:24
  • https://stackoverflow.com/questions/40611068/centos-error-phusion-passenger-doesnt-seem-to-be-running – Tony Vincent Sep 11 '17 at 14:17
  • Tony, thanks, I'll try customizing the instance registry directory. – dfaulken Sep 12 '17 at 15:24
  • Tony, that worked. Specifically I did have to do the final step of configuring the environment variable in my passenger settings. If you want to submit that as an answer here, I'd be happy to credit you with the bounty. – dfaulken Sep 12 '17 at 16:08

2 Answers2

5

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' }
dfaulken
  • 476
  • 8
  • 18
  • 2
    I ran into this problem after upgrading my server from Debian Jessie to Debian Stretch (which upgraded Apache). This worked for me to fix it. Thanks! – Sage Ross Sep 22 '17 at 17:03
  • 1
    I also encountered this problem when installing phusion passenger in Debian Stretch for apache2. This seems like a defect in Phusion's operating system and server technology specific installation instructions. This information is necessary to get passenger-status to work properly. – Nels Jul 03 '18 at 06:30
  • 1
    You are the champion. +100000 – Awijeet Nov 23 '18 at 08:26
  • Passenger will complain because the directory given isn't safe. The fundamental issue here is that systemd sets up private tmp directories, so the actual path to a file that's in /tmp cannot be known ahead of time. I use method #1 from this writeup on the subject: https://www.pistolfly.com/weblog/en/2016/01/passenger-config-and-passenger-status-result-in-an-error-on-centos7.html I do not recommend putting Passenger's registry directory in a standard path as shown in this answer. – Michael Chaney Apr 05 '19 at 13:01
0

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..

Camden Narzt
  • 2,271
  • 1
  • 23
  • 42
  • No, I just misunderstood whether that was what you were asking. The only thing I'm running locally is `cap production deploy`. `passenger-config validate-install`, `passenger-memory-stats` and `apache2ctl restart` were all run remotely. `ls /tmp` remotely does not give me anything related to passenger. – dfaulken Sep 12 '17 at 15:21