Passenger is a system for preparing and launching instances of Ruby for use with Rack-based applications such as Ruby on Rails. Apache and nginx, the two supported web server platforms, cannot run Ruby like they can PHP, Perl, or Python because there's no built-in Ruby module that works as well as those do. This means Ruby tends to run as an independent group of processes that the web server will have to direct traffic through.
Rails tends to run as a persistent process because the start-up time for the whole stack is significant. Passenger launches new instances as they are required, and will kill off those that are no longer required. You can see this in the process list as they are clearly identified with "Passenger" and "Rails" prefixes.
One feature of Passenger is it will re-use a portion of the Rails stack so that creating additional processes is faster, cloning one instance instead of spinning up a new one from scratch. The loader is written in C++ and handles properly configuring and kicking off each Ruby process as efficiently as possible and also helps save memory by sharing it amongst different processes.
The reason you host things out of the public/
directory is to avoid exposing your application code-base. PHP needs to be configured properly to prevent people from simply browsing directories and downloading the source because there's no specific distinction between static content and executable scripts. A mis-configured server will gladly serve up raw .php files instead of running them, for instance.
Passenger isn't exactly revolutionary, but it does incorporate a number of essential features in a very convenient package. What makes it such a great thing is that it works very well and doesn't demand a lot of attention. Out of the box it's pretty much ready to go.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…