为什么红宝石铁轨需要美洲狮或独角兽?

时间:2021-09-09 12:23:35

In php, you only need apache or nginx. Why does ruby rails also need something like puma or unicorn when nginx is already installed?

在php中,你只需要apache或nginx。为什么在已安装nginx时,ruby rails还需要像puma或unicorn这样的东西?

2 个解决方案

#1


10  

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.

这不完全正确,要使用apache运行PHP,您将需要apache mod_php或将其作为FastCGI模块运行。对于Nginx来说,后者似乎是常态。

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.

对于Ruby来说,Phusion Passenger可以填充这个角色,同时支持apache和nginx。在apache上,它以mod_php的方式作为插件模块运行。对于Nginx,我不确定。

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.

但是,您可能希望使用专用的应用程序服务器运行ruby应用程序。这就是Unicorn,Puma等的用武之地。没有什么能阻止你为php做类似的设置,但它并不常见。

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.

在许多情况下使PHP更容易部署的另一件事是,大多数发行版和服务器安装都带有apache和nginx已经设置来处理php,而你需要自己设置为ruby。

Once set up Passenger makes deploying ruby apps almost (but not quite) as simple as deploying php apps.

一旦设置,Passenger几乎(但不完全)部署ruby应用程序就像部署php应用程序一样简单。

#2


2  

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.

由于您使用过php后端,我假设您熟悉modphp或fcgi模块。它们是编译和运行php代码的实际引擎。 Ruby on rails不能像php一样自行运行。所以需要像puma或phusion乘客这样的东西来运行它。它们被称为应用服务器。您可以使用应用程序服务器直接为网站服务,但建议采用这种方法。还有更合适的替代品,比如nginx,它们就是为了这个目的而发展起来的。

#1


10  

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.

这不完全正确,要使用apache运行PHP,您将需要apache mod_php或将其作为FastCGI模块运行。对于Nginx来说,后者似乎是常态。

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.

对于Ruby来说,Phusion Passenger可以填充这个角色,同时支持apache和nginx。在apache上,它以mod_php的方式作为插件模块运行。对于Nginx,我不确定。

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.

但是,您可能希望使用专用的应用程序服务器运行ruby应用程序。这就是Unicorn,Puma等的用武之地。没有什么能阻止你为php做类似的设置,但它并不常见。

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.

在许多情况下使PHP更容易部署的另一件事是,大多数发行版和服务器安装都带有apache和nginx已经设置来处理php,而你需要自己设置为ruby。

Once set up Passenger makes deploying ruby apps almost (but not quite) as simple as deploying php apps.

一旦设置,Passenger几乎(但不完全)部署ruby应用程序就像部署php应用程序一样简单。

#2


2  

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.

由于您使用过php后端,我假设您熟悉modphp或fcgi模块。它们是编译和运行php代码的实际引擎。 Ruby on rails不能像php一样自行运行。所以需要像puma或phusion乘客这样的东西来运行它。它们被称为应用服务器。您可以使用应用程序服务器直接为网站服务,但建议采用这种方法。还有更合适的替代品,比如nginx,它们就是为了这个目的而发展起来的。