Passenger
Passenger is an open source web application server for ruby. It handles handling HTTP requests, managing processes and resources. It also allows us to view and analyze problems. Passenger is easy to use and deploy to production.
Passenger is an app server like (puma, unicorn, torquebox). Nginx, Apache is a web server.
The passenger then helps you automatically connect between web apps and the web server
If you used to use unicorn to connect rails apps to web server and capistrano to automatically compile assets, package code … then you can use the passerger because it is modern and easier to deploy. Below is a comparison of the speed. It can be said that passenger runs 4 times faster than other ruby web servers.
We all know Unicorn, Puma, Torquebox are all different so fast to be 2 -> 4 times faster is very difficult. However, there are many reasons to help Phusion Passenger faster.
You can refer to the link above.
Deploy with phusion passenger and nginx
- Install nginx and start nginx1234sudo apt-get updatesudo apt-get install nginxsudo service nginx start
Nginx as mentioned above will be a web server, which will send requests from user to app server. If the request does not change frequently as css, js, the web server can resolve it without interacting with the app. Thus processing speed will be fast. - Passenger installation
You can install it via gem passenger
12gem install passenger
Connect the module to nginx12rvmsudo passenger-install-nginx-module
Or install via apt12sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 561F9B9CAC40B2F7
Next, create an APT file:12sudo nano /etc/apt/sources.list.d/passenger.list
Authorize the file and save it123sudo chown ubuntu: /etc/apt/sources.list.d/passenger.listsudo chmod 600 /etc/apt/sources.list.d/passenger.list
Update and install passenger with nginx123sudo apt-get updatesudo apt-get install nginx-extras passenger
OK so successfully installed the passenger - Config nginx
Open the file /etc/nginx/nginx.conf and leave the comment in two lines
123# passenger_root /usr/lib/ruby/vendor_ruby/phusion_passenger/locations.ini;# passenger_ruby /usr/bin/ruby;
If not, we can add it in the http block12345http {passenger_root /usr/lib/ruby/vendor_ruby/phusion_passenger/locations.ini;passenger_ruby /usr/bin/ruby;} - Restart nginx12sudo service nginx restart
- Verify validate installation1234rvmsudo passenger-config validate-install* Checking whether this Phusion Passenger install is in PATH... ✓* Checking whether there are no other Phusion Passenger installations... ✓
- Check out the progress123456789101112131415161718192021rvmsudo passenger-memory-statsVersion: 5.0.8Date : 2015-05-28 08:46:20 +0200...---------- Nginx processes ----------PID PPID VMSize Private Name-------------------------------------12443 4814 60.8 MB 0.2 MB nginx: master process /usr/sbin/nginx12538 12443 64.9 MB 5.0 MB nginx: worker process### Processes: 3### Total private dirty RSS: 5.56 MB----- Passenger processes ------PID VMSize Private Name--------------------------------12517 83.2 MB 0.6 MB PassengerAgent watchdog12520 266.0 MB 3.4 MB PassengerAgent server12531 149.5 MB 1.4 MB PassengerAgent logger...
- Create rails app, database, bundle, gem environments
For example, app
/var/www/html/passenger-app/public
contains the source code of the app - Config web server Create a config file to connect to your
passenger-app
railspassenger-app
12sudo vi /etc/nginx/sites-available/passenger-app
Add config1234567server {listen 80 default_server;server_name www.xxx.com;passenger_enabled on;root /var/www/html/passenger-app/public;}
Save and create symlinks12sudo ln -s /etc/nginx/sites-available/passenger-app /etc/nginx/sites-enabled/passenger-app - Reset nginx and see results12sudo service nginx restart