Redmine + apache+ Passenger: Passenger still runs as nobody - ruby-on-rails

I'm installing a new version of Redmine under Debian 8. I followed the steps described here: http://www.redmine.org/projects/redmine/wiki/HowTo_Install_Redmine_on_Debian_8_with_Apache2-Passenger
I had some problems with passenger so I installed it using:
gem install passenger
passenger-install-apache2-module
I added
PassengerDefaultUser www-data
on the passenger confing file and on the appache config file as well to avoid permission problems
The problem is that passenger is still running as nobody.
result of top | grep "passenger" gives 3 process named PassengerAgent, 2 of them runs as root and one runs as nobody. What should I do to have the effect of the configuration i added?
I have :
Redmine version 3.3.0.stable
Ruby version 2.1.5-p273 (2014-11-13)
Rails version 4.2.6

Try to set www-data as owner for /config.ru file.

Related

Error starting web application - Passenger, Rails, Raspberry PI

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.

Passenger PassengerAgent does not exist

I'm updating the passenger for my app with rvm. Afterwards I used passenger-config --root to find the passenger and added it to my nginx.conf. This is the directory:
shared/bundle/ruby/2.3.0/gems/passenger-5.0.30
I'm not sure why the passenger root is this one. I thought it'll be the one installed under .rvm. Anyway, I got this error:
Unable to start Phusion Passenger: Support binary PassengerAgent not found...
I am able to use back my previous passenger, and I noticed the difference is the new package has no buildout/support-binaries/PassengerAgent. Am I missing something here?
Setup:
Ubuntu 14.04
rvm 1.29.3
rails 4.2.10
ruby 2.3
capistrano 3
It seems that I installed passenger with rvm. So I need to follow the instructions here and run passenger-install-nginx-module to do it correctly.

Why when outside the installation directory do I get passenger: command not found?

I have just built a RackSpace cloud server with Ubuntu 12 LTS and performed a "standard" Ruby on Rails installation. I created a user (bob) and added it to the sudu group.
I then logged out of root and logged in as bob. Then issued sudo su from the /home/bob directory. I then installed everything needed to run the Rails Application 'as root'.
I then installed the Rails code in /home/bob and passenger started up when I issued:
RAILS_ENV=production passenger start -p 3000
however, since I want to run multiple Rails applications on this server, I then created another directory /home/bob/newapp and installed Rails code there. (ideally I would want to put all the different Rails applications in their own subdirectory below /home/bob)
When I issue the command (shown below) from /home/bob/newapp
RAILS_ENV=production passenger start -p 3000
I get
passenger: command not found
why is passenger only accessible from /home/bob ?
NEWS: just discovered, passenger is 'available' until the moment I complete the edit of the content of /config/database.yml thus as long as I do NOT edit the database.yml file, passenger will start. After I edit database.yml the "passenger: command not found" appears. How bizarre is that?
SNAP: looks like when I installed passenger it used Ruby-2.1.1 however the old application wants ruby-1.9.3-p194. I need to figure out how to get passenger to run with ruby 1.9.3 or install a second version of passenger (???)
More News:
Thank you,Hongli, for your response. I followed your links/suggestion to read the passenger documentation. I had read it before without recognizing the needed information. This time I found the "magical" command:
rvm-exec ruby-version ruby -S (eg: rvm-exec ruby-1.9.3-p194 ruby -S )
this has turned out to be very helpful, although I did end up following a process which has resulted in two different version of passenger being installed.
Read the About environment variables section of the Phusion Passenger manual to learn what "command not found" errors are, why they occur, and what you can generally do about them.
In your case, entering /home/bob automatically makes RVM change your PATH to include a specific Ruby version's bin directory. Read the When the system has multiple Ruby interpreters section of the Phusion Passenger manual to learn how to deal with that.
The article Hongli suggested I read definitely moved me in the correct direction.
The use of: rvm-exec 'ruby-version' ruby -S allows me to get passenger started, provided a version of passenger has been installed using the version of ruby required by the Rails application.
Thus if I load up a Rails application built with ruby-1.9.3-p194, I will need a version of passenger installed with the same version of ruby.
If I load up another Rails application built with ruby-1.9.3-p286, I will need a version of passenger installed with that version of ruby.
Then starting each version of passenger can be accomplished with the rvm-exec command with the appropriate ruby version.
Perhaps there is a more elegant solution, but the above works for me.

why isn't my rails install using the latest version of passenger?

I'm using VirtualBox on Windows to run an Ubuntu OS, which is running the turnkey rails package, which comes with ruby 1.8, rails 2.3.8, and passenger 2.2.5. When I first booted it up with just a vanilla rails app it worked fine, but now I'm getting the following error:
uninitialized constant PhusionPassenger::Utils::PseudoIO::StringIO
I googled this, and on the phusion/google groups it said this was an old error and to upgrade passenger, which I did with gem upgrade passenger. It said it was installing passenger 2.2.15, but it doesn't appear to be using it. I re-started the whole virtualbox and it is still giving me the same error, with the backtrace showing passenger-2.2.5.
I realize there are several layers here and plenty of places for things to go wrong, and to add to that, I'm pretty much a Linux newb. I've got some experience with rails. I'd appreciate any help.
It could well be your Apache configuration file. When Passenger installs it adds some code to the /etc/apache2/http.conf file so that Apache loads the Passenger extension. This code includes the version number so if you've changed the version of Apache you'll need to modify this file. The code you're looking for looks like this
LoadModule passenger_module /opt/local/lib/ruby/gems/1.8/gems/passenger-2.2.15/ext/apache2/mod_passenger.so
PassengerRoot /opt/local/lib/ruby/gems/1.8/gems/passenger-2.2.15
PassengerRuby /opt/local/bin/ruby
You'll have to be authenticated to edit the file so open a terminal window and type
sudo gedit /etc/apache2/http.conf
and enter your password to edit the file. Once you've made the changes close gedit then run
sudo /etc/init.d/apache2 restart
to restart Apache and try your Rails application again.
Try using
gem list
to make sure the new version was installed. Next to the passenger gem should see more than version listed.
You can use
gem clean
to remove old versions.

Passenger / REE can't find rails, it's in the $PATH, what gives?

I've got a fresh install of Ruby EE (1.8.6-20090610) and Passenger (2.2.5) on Debian Lenny. REE is installed in /opt/ruby-enterprise and it is added to the $PATH of all users through /etc/environment, and PassengerDefaultUser is set to root. The problem is when loading a rails app, the Passenger error says the rails 2.3.3 gem is missing. However it was installed with Passenger and a rails -v as root says it's there. What could be going wrong?
Found the error:
PassengerRuby /usr/bin/ruby1.8
should have been
PassengerRuby /opt/ruby-enterprise/bin/ruby

Resources