Passenger stand alone uses wrong ruby version?
I had the same problem: passenger standalone uses nginx, and after upgrading my app to use ruby 2.1.1 (specified in the .ruby-version), I saw similar errors.
On my production server, I know where the nginx configuration lives, so I could fix the path to the ruby interpreter.
However on the standalone setup I couldn't find it in less a minute, so I did a gem uninstall passenger
followed by gem install passenger
to have it recompile nginx.
Now it works, at least until the next ruby interpreter bump.
Default ruby in server
After 8 hours of failed intents, this is what solved it:
All I had to do was configure Apache/Passenger again.
rvm use 1.9.2
gem install passenger --pre
passenger-install-apache2-module
followed the instructions to install apache. Then configured the file apache2.conf as told my the instructions before. Here I pasted the lines of code given in the instruction (and found out other lines that made reference to ruby1.8 so now the refer to ruby 1.9.2)
then restarted apache with
sudo apache2ctl restart
thanks to this post but I didnt need to edit the vhost file (that I was unable to find) as suggested in the site, with reinstalling, adding the new lines and restarting apache solved the problem
Upgrade Phusion Passenger without reinstalling Nginx
@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
- install the new Passenger gem
- 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.) - 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)
- 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) - Restart Nginx
- Profit
Ubuntu, Apache, Passenger, Ruby/Rails on Ec2 - passenger-install-apache2-module broken pipe
wit this issue Write failed: Broken pipe
, here are some steps you can try:
1. run it with root permission with full path.
2. if you manage ruby with rvm, you need source it first
source "$HOME/.rvm/scripts/rvm
3. if the package can be installed directly with `gem install`, just do it.
Hope these help.
How do I upgrade a rails 3.2 app from ruby 1.9.3 to ruby 2.1.5 using rvm
Per comments from @Santiago and @Milind, the answer is to
1) edit the .rvmrc file and give environment_id a new value such as'= ruby-2.1.5@new_foogems
and also edit the Gemfile to specify ruby "2.1.5"
2) leave directory (cd ..)
3) go back into directory (to reload the .rvmrc)
4) says "yes" to alert the .rvmrc file changed
RVM will create the new blank gemset.
5) Run rvm install 2.1.5
6) run bundle install
Multitenancy Passenger Rails Multiple Apps Different Versions Same Domain
ZOMG it works! So a big thanks to tadman for suggesting that I use Nginx as a reverse proxy server. That is, one Nginx serves individual Apache processes for each app. I am able to go to mywebsite.com and get the main app. I go to mywebsite.com/subapp and get my second app (same Ruby/Rails version as the main one). I can go to mywebsite.com/mea and get a third app (that has a different Ruby and Rails version than the first two!).
Part of this is possible because both Nginx and Apache have a Passenger component that you can install, giving you all sorts of Directives you can use to specify what kind of app each url should serve up (passenger_ruby lets you tell Nginx which ruby interpreter to use). I've never seen documentation as comprehensive and beautiful as on Phusion's website.
Figuring this out was fun. Here is my setup so that you can see what I did. And please let me know if there's anything I could do better.
Nginx config:
/etc/nginx/sites-enabled/apache
server {
listen 80;
server_name mywebsite.com www.mywebsite.com;
passenger_enabled on;
location / {
passenger_ruby /usr/local/rvm/gems/ruby-2.3.4/wrappers/ruby;
proxy_pass http://my_website_ip:8080;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
}
location /subapp {
passenger_ruby /usr/local/rvm/gems/ruby-2.3.4/wrappers/ruby;
proxy_pass http://my_website_ip:8081;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
}
location /mea {
passenger_ruby /usr/local/rvm/gems/ruby-2.5.0/wrappers/ruby;
proxy_pass http://my_website_ip:8082;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
}
}
My Ports file listens for the ports served by Nginx:
/etc/apache2/ports.conf
# If you just change the port or add more ports here, you will likely also
# have to change the VirtualHost statement in
# /etc/apache2/sites-enabled/000-default.conf
Listen 8080
Listen 8081
Listen 8082
<IfModule ssl_module>
Listen 443
</IfModule>
<IfModule mod_gnutls.c>
Listen 443
</IfModule>
My Apache VirtualHost definitions.
/etc/apache2/sites-enabled/login_app.conf
<VirtualHost *:8080>
ServerName mywebsite.com
# Tell Apache and Passenger where your app's 'public' directory is
DocumentRoot /var/www/login_app/code/public
PassengerRuby /usr/local/rvm/gems/ruby-2.3.4/wrappers/ruby
# Relax Apache security settings
<Directory /var/www/login_app/code/public>
Allow from all
Options -MultiViews
# Uncomment this if you're on Apache >= 2.4:
Require all granted
</Directory>
</VirtualHost>
<VirtualHost *:8081>
ServerName mywebsite.com
# Tell Apache and Passenger where your app's 'public' directory is
DocumentRoot /var/www/second_app/code/public
PassengerRuby /usr/local/rvm/gems/ruby-2.3.4/wrappers/ruby
# Adding a subapp to the base url
Alias /subapp /var/www/second_app/code/public
<Location /subapp>
PassengerBaseURI /subapp
PassengerAppRoot /var/www/second_app/code
</Location>
# Relax Apache security settings
<Directory /var/www/second_app/code/public>
Allow from all
Options -MultiViews
# Uncomment this if you're on Apache >= 2.4:
Require all granted
</Directory>
</VirtualHost>
<VirtualHost *:8082>
ServerName mywebsite.com
# Tell Apache and Passenger where your app's 'public' directory is
DocumentRoot /var/www/third_app/code/public
PassengerRuby /usr/local/rvm/gems/ruby-2.5.0/wrappers/ruby
# Adding a subapp to the base url
Alias /mea /var/www/third_app/code/public
<Location /mea>
PassengerBaseURI /mea
PassengerAppRoot /var/www/third_app/code
</Location>
# Relax Apache security settings
<Directory /var/www/third_app/code/public>
Allow from all
Options -MultiViews
# Uncomment this if you're on Apache >= 2.4:
Require all granted
</Directory>
</VirtualHost>
And the processes produced, from the command line: passenger-memory-stats
Version: 5.2.0
Date : 2018-02-09 03:22:39 +0000
--------- Apache processes ----------
PID PPID VMSize Private Name
-------------------------------------
148.9 MB 0.4 MB /usr/sbin/apache2 -k start
813.3 MB 3.1 MB /usr/sbin/apache2 -k start
557.3 MB 3.2 MB /usr/sbin/apache2 -k start
### Processes: 3
### Total private dirty RSS: 6.74 MB
---------- Nginx processes -----------
PID PPID VMSize Private Name
--------------------------------------
174.8 MB 0.7 MB nginx: master process /usr/sbin/nginx -g daemon on; master_process on;
174.8 MB 0.8 MB nginx: worker process
### Processes: 2
### Total private dirty RSS: 1.57 MB
----- Passenger processes -----
PID VMSize Private Name
-------------------------------
379.5 MB 4.7 MB Passenger watchdog
666.2 MB 7.1 MB Passenger core
378.9 MB 4.2 MB Passenger watchdog
662.5 MB 5.5 MB Passenger core
318.0 MB 63.0 MB Passenger RubyApp: /var/www/login_app/code (production)
314.5 MB 60.3 MB Passenger RubyApp: /var/www/third_app/code (production)
315.7 MB 61.4 MB Passenger RubyApp: /var/www/second_app/code (production)
### Processes: 7
### Total private dirty RSS: 206.14 MB
How do I recompile nginx
The given answers will not work, because you are trying to use Nginx with Passenger, and Nginx needs the Passenger module also compiled.
Simply running passenger-install-nginx-module
again will recompile nginx for you. If it doesn't, you can try rm -r
on /opt/nginx (which is the default location nginx is installed into by Passenger). Be sure to backup your /opt/nginx/conf/nginx.conf if you value it.
If you are using passenger standalone, and you need to recompile that, remove ~/.passenger/YOUR-MOST-RECENT-INSTALL and simply run passenger start again.
Related Topics
Multiple Level Nesting in Yaml
How to Add "Somewhere" a 'Before(:Each)' Hook So That All Spec File Can Run It
Saml 2.0 Sso for Ruby on Rails
Rails 3.2 Activeadmin 'Collection Is Not a Paginated Scope.' Error
Soap Client for Ruby 1.9 and Rails
Best Way to Handle Category/Subcategory Relationship Ruby on Rails
Ruby - Test Whether Database Connection Is Possible
Rails Generate Error: No Such File or Directory - Getcwd
How to Increment/Decrement a Character in Ruby for All Possible Values
Rails: Violates Foreign Key Constraint
Heroku: How to Push to Specific App If You Have Multiple Apps in Heroku
Call Before Methods in Model on Ruby
Rails: Undefined Method 'Truncate' in Model
Semifixed: Missing 'Secret_Key_Base' for 'Production' Environment
Ransack, Postgres - Sort on Column from Associated Table with Distinct: True