In php, you only need apache or nginx. Why does ruby rails also need something like puma or unicorn when nginx is already installed?
This is not entirely correct, to run PHP with apache you will need either the apache mod_php or run it as a FastCGI module. For Nginx the latter seems to be the norm.
For Ruby there's Phusion Passenger that fills this role, and supports both apache and nginx. On apache it runs as a plugin module just the way mod_php does. For Nginx I'm not sure.
You may want to run your ruby applications using a dedicated application server, however. This is where Unicorn, Puma etc comes in. There's nothing preventing you from doing a similar setup for php, but it's less common.
Another thing which makes php easier to deploy in many cases is that most distros and server installs come with apache and nginx already set up to handle php, while you need to set this up on your own for ruby.
Once set up Passenger makes deploying ruby apps almost (but not quite) as simple as deploying php apps.
Since you have worked with php backend, I assume you are familiar with modphp or fcgi modules. They are actual engines that compile and run php code. Ruby on rails cannot run on its own just like php. So there is need of something like puma, or phusion passenger to run it. They are called application server. You can use application server to serve website directly, but it is recommended approach. There are more suitable alternatives like nginx which have evolved just for this purpose.
I found a great article on this here https://www.rubyguides.com/2019/08/puma-app-server/
I also made this diagram with a very dumbed down list of the responsibilities of Web Servers, Application Servers, and Web Frameworks
© 2022 - 2024 — McMap. All rights reserved.