如何在 Ruby on Rails 的 Ubuntu 服务器上以生产模式重新启动 Phusion Passenger + Apache?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/15368492/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-02 21:37:29  来源:igfitidea点击:

How to restart Phusion Passenger + Apache in Production mode on Ubuntu server for Ruby on Rails?

ruby-on-railsruby-on-rails-3apachepassenger

提问by iCyborg

I am having Apache + phusion passenger, I have put

我有 Apache + phusion 乘客,我已经把

RailsEnv production

in /etc/apache2/sites-available/default file and have restarted apache but when I am running

在 /etc/apache2/sites-available/default 文件中并重新启动了 apache 但是当我运行时

rails c
> Rails.env.production?

it gives fales where as for

它给出了错误的地方至于

> Rails.env.development?

it gives true. Is there any other way to restart passenger as I do think putting "RailsEnv production" in default is the right way ? btw I am using

它给出了真实的。有没有其他方法可以重新启动乘客,因为我认为默认设置“RailsEnv 生产”是正确的方法?顺便说一句我正在使用

sudo service apache2 restart

How to start my ruby on rails app in Production mode with passenger + apache ?

如何使用乘客 + apache 在生产模式下启动我的 ruby​​ on rails 应用程序?

采纳答案by Intrepidd

Your app is probably in production mode already.

您的应用可能已经处于生产模式。

By default, rails cloads the app in dvelopment mode.

默认情况下,rails c以开发模式加载应用程序。

If you want your console to be launched in production mode, do the following :

如果您希望以生产模式启动控制台,请执行以下操作:

RAILS_ENV=production rails c

RAILS_ENV=production rails c

The console and the web app are two different rails proccess and run independently.

控制台和 Web 应用程序是两个不同的 Rails 进程并独立运行。

You should check your production.log file to be sure that your app runs in production.

您应该检查您的 production.log 文件以确保您的应用程序在生产中运行。

回答by Pavel S

just create a restart.txt in tmp dir of your app

只需在您的应用程序的 tmp 目录中创建一个 restart.txt

e.g.

例如

  touch %RAILS_ROOT%/tmp/restart.txt

look here http://www.modrails.com/documentation/Users%20guide%20Apache.htmlsection 3.3

看这里 http://www.modrails.com/documentation/Users%20guide%20Apache.html第 3.3 节

回答by Sumit Munot

Just for starting app with particular port use below command:

仅用于使用以下命令启动具有特定端口的应用程序:

passenger start -a 0.0.0.0 -p 3000 -d -e production

乘客开始 -a 0.0.0.0 -p 3000 -d -e 生产

回答by Jignesh Gohel

I followed the commands listed in PhusionPassenger docs hereand they worked straight-away.

我按照此处PhusionPassenger 文档中列出的命令进行操作,它们立即生效。

deployer@staging:~$ passenger-config restart-app
Please select the application to restart.
Tip: re-run this command with --help to learn how to automate it.
If the menu doesn't display correctly, press '!'

 ?   /home/deployer/myapp/current (staging)
     /home/deployer/myapp_2/current (staging)
     Cancel

Restarting /home/deployer/myapp/current (staging)

deployer@staging:~$ passenger-config restart-app
Please select the application to restart.
Tip: re-run this command with --help to learn how to automate it.
If the menu doesn't display correctly, press '!'

     /home/deployer/myapp/current (staging)
 ?   /home/deployer/myapp_2/current (staging)
     Cancel

Restarting /home/deployer/myapp_2/current (staging)