I'm trying to deploy a rails project for the first time with Passenger. I've followed the guide on Passenger's site with the passenger gem and used 'passenger-install-apache2-module' and pasted the three lines into my httpd.conf. However, I noticed that when I tried to run passenger start in my project directory, it tried install passenger for nginx again, and when that finished, I was able to do 'passenger start'. The issue that I've noticed is that when I removed the three lines from my httpd.conf I was still able to run 'passenger start and seemingly to have started the server. My question hence becomes how would I determine if my passenger gem was installed for apache or nginx?
Thanks!
'passenger start' does not use your apache or nginx installation. It uses it's own in built webserver which is based on nginx. It starts on port 3000 by default.
Related
I am deploying a Rails application on an ubuntu server that has Apache2 installed, Rails installed, and I am trying to get the application deployed using Passenger.
Apache is installed just fine - I can view static files, reload it, start it, stop it, etc..
Rails is installed just fine - I can run the WeBrick server from the application root.
Now I want to use passenger to deploy.
When I run the following command:
passenger-install-apache2-module
It goes through some stuff then the following error comes up:
WARNING: Apache doesn't seem to be compiled with the 'prefork', 'worker' or 'event' MPM - Rails - Apache2 - Passenger
Basically, the Passenger installer tells me to recompile Apache with one of those MPM's or continue the installation process. I tried continue but it fails.
So, how do I got about fixing this issue?
You have two choices:
Fix Apache. How to fix this depends on how you installed Apache in the first place. If you installed Apache by installing it from source, then reinstall Apache by compiling it from source, but this time using the worker MPM. Refer to the Apache documentation to learn how to do that.
Don't use Apache. Instead, use Phusion Passenger + Nginx, or use Phusion Passenger Standalone.
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)?
#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
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.
I have a server running with nginx serving two php websites, right now I want to make it serving a rails app, I've googled, but there no notes about add passenger support to a existed nginx, all of them are telling me run passenger-install-nginx-module to build a nginx.
Can I add passenger support to my nginx instead of rebuild it?
Thanks for any helps.
You still need to rebuild nginx. If you run passenger-install-nginx-module you will see this output:
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.
See Installing Passenger as a normal Nginx module for steps.
cd /path-to-nginx-source-dir
./configure --prefix=/opt/nginx \
--add-module=$(passenger-config --nginx-addon-dir) \
--add-module=/path-to-some-nginx-module
make
sudo make install
The value for /path-to-passenger-module can be obtained with the command:
passenger-config --nginx-addon-dir
There is no need to rebuild nginx if you use Phusion Passenger Standalone.
From Passenger's wiki:
"But I don't want to recompile Nginx. Are there alternatives?"
Yes. Use Phusion Passenger's Standalone mode. Phusion Passenger
Standalone is a standalone server. It does not extend Nginx so it does
not need to recompile Nginx. It will therefore work perfectly with
your existing Nginx installation.
When using Passenger Standalone, you are supposed to:
Start Passenger Standalone on a certain port or socket file.
Add reverse proxy rules to your Nginx configuration file, to forward requests to Passenger Standalone.
If you've ever used Unicorn and Puma, then using Passenger Standalone
will be very familiar: usage is almost the same.
I tried it by installing Phusion passenger..Phusion passenger was succeessfully installed but while configuring it to Apache i'm facing a problem ....
So can anybody tell me what is the best websever for ruby on rails applications to host them on Ubuntu ...
The combination of Apache and Passenger is a very good web server for Ruby on Rails applications on Ubuntu.
There is very good support, on the web, from Apache, from Phusion and here on Stackoverflow.
Many sites are running Rails on Passenger. The technology is robust and well understood.
Same for Ubuntu.
Same for Apache, only more so.
Basically I'd say that if you are just starting out that you should go with Passenger/Apache unless you have a compelling need for some other stack. Given that you are asking the question without any other details, I'm assuming that you don't have such a compelling need.
The other thing that is true today is that there are lots of choices. You can combine Passenger, or Thin, or Mongrel, or Unicorn with Apache, or Nginx or alone, and you can mix them with Varnish or other cache. Once you have your site configured on one stack, you can move it to another without too much difficulty.
First though, you have to configure it once, and for that Passenger and Apache are a good combination on Ubuntu.
Apache and passenger is reliable and configurable way to go. But if you just want to run single application, the zero configuration way is passenger standalone
gem "passenger"
in your Gemfile and
$ passenger start -e production -p 80
in console should start nginx server in port 80 with production environment. It would automatically install nginx server for you.
If port 80 is not blocked by the firewall, you can access your application from the internet by
http://your-server-ip-address/
I'm trying to get started writing some Ruby on Rails apps and have been successful with Mongrel but, I'd like to deploy my apps to my Apache 2.2 instance on Windows? All the tutorials I've found seem out of date and are for older versions of Apache/Rails.
Does anyone know of a good, current tutorial for configuring Apache 2.2 for Ruby on Rails apps?
EDIT: At least until there's a Phusion Passenger for Win, Apache + Mongrel is the way to go. You can use Apache + FastCGI without Mongrel, but under real loads you will get (more) zombie processes and (more) memory leaks.
You could also look at proxying to Thin in the same way as detailed below. However, I've had some instabilities with Thin on Win, even though it's appreciably quicker. AB (Apache Benchmark) is your friend here!
Configuring Apache + Mongrel on Windows is not significantly different from *nix.
Essentially, you need to proxy requests coming into Apache to Mongrel. What this boils down to is something like this:
LoadModule proxy_module modules/mod_proxy.so
LoadModule proxy_http_module modules/mod_proxy_http.so
<VirtualHost localhost:80>
ServerName www.myapp.comm
DocumentRoot "C:/web/myapp/public"
ProxyPass / http://www.myapp.com:3000/
ProxyPassReverse / http://www.myapp.com:3000/
ProxyPreserveHost On
</VirtualHost>
Stick this in your httpd.conf (or httpd-vhost.conf if you're including it).
It assumes you're going to run mongrel on port 3000, your Rails root is in C:\web\myapp, and you'll access the app at www.myapp.com.
To run the rails app in production mode:
mongrel_rails start -p 3000 -e production
And away you go (actually mongrel defaults to port 3000 so you could skip -p 3000 if you want).
The main difference is that you cannot daemonize mongrel on Windows (i.e. make it run in the background). Instead you can install it as a service using the mongrel_service gem.
Also, running a cluster is more complicated and you won't be able to use Capistrano. Let me know if you want more info.
I'm new to RoR and have been attempting the same thing on Windows Server 2008, here are some additional notes on getting mongrel going as a service:
if you get compilation errors when installing mongrel_service:
gem install mongrel_service
try using a binary instead by specifying your platform:
gem install mongrel_service --platform x86-mswin32
Additionally, to actually install the service you need to run this command in your RoR's app directory:
mongrel_rails service::install --name MyApp -e production -p 3001 -a 0.0.0.0
(or to remove:
mongrel_rails service::remove --name MyApp
)
Then you should be able to start/stop the app "MyApp" in your windows services control panel.
Hope that helps someone.
At the moment Mongrel does not work properly with Ruby 1.9 and will throw a "msvcrt-ruby18.dll not found" error when executing the command mongrel_rails.
Thin in this case seems to be the only option for now.
I just wanted to add this article to the list. It explains how to have Apache serve ruby files without the need to install any other applications.
http://editrocket.com/articles/ruby_apache_windows.html
You might want to try Bitnami RubyStack