更新时间:2023-12-04 10:56:52
他们会以更安全、更系统的方式以及现在或多或少成为标准的方式来处理使用服务器启动您的应用程序.
They will take care of starting your App with the server in a safer and more systematic way and what is now more or less a standard.
我在 CentOS 6 上使用 Rails 4、Ruby 2.1 时遇到了同样的问题.如果您不熟悉 bash 脚本和 rc、profiles 系统 - 设置 passenger
会更快更容易.
I had the same issue with Rails 4, Ruby 2.1 on CentOS 6. If you're not familiar with bash scripts and the rc, profiles system - it's much faster and easier to setup passenger
.
此外,您选择乘客还有其他原因,包括安全和性能 (www.phusionpassenger.com)
Also, there are other reasons why you would go for passenger, including security and performance ( www.phusionpassenger.com )
这里是我介绍宝石的快速方法.
Here is a quick how-to of what it took me to introduce the gem.
安装 Apache(html 守护进程)和依赖包(如果你还没有的话):
Install Apache (html daemon) and dependency packages (if you don't have them already):
yum 安装 httpd curl-devel httpd-devel
yum install httpd curl-devel httpd-devel
让 Apache 在开机时启动:
Get Apache to start on boot:
chkconfig httpd on
chkconfig httpd on
安装 Phusion Passenger 和依赖包:
Install Phusion Passenger and dependency packages:
宝石安装乘客
yum install curl-devel httpd-devel
gem install passenger
yum install curl-devel httpd-devel
编译环境:
Compile the environment:
passenger-install-apache2-module
passenger-install-apache2-module
在 etc/httpd/conf/httpd.conf 中编辑 Apache 配置文件
Edit the Apache config file in etc/httpd/conf/httpd.conf
取消注释最后包含 NameVirtualHost *:80
的行
将第 4) 点的输出粘贴到文件末尾的任意位置,例如:
Paste the output from point 4) anywhere at the end of the file, eg:
LoadModulepassenger_module/usr/local/rvm/gems/ruby-2.1.1/gems/passenger-4.0.41/buildout/apache2/mod_passenger.so
LoadModule passenger_module /usr/local/rvm/gems/ruby-2.1.1/gems/passenger-4.0.41/buildout/apache2/mod_passenger.so
PassengerRoot/usr/local/rvm/gems/ruby-2.1.1/gems/passenger-4.0.41
PassengerRoot /usr/local/rvm/gems/ruby-2.1.1/gems/passenger-4.0.41
PassengerDefaultRuby/usr/local/rvm/gems/ruby-2.1.1/wrappers/ruby
PassengerDefaultRuby /usr/local/rvm/gems/ruby-2.1.1/wrappers/ruby
<VirtualHost *:80>
ServerName 1.2.3.4 # www.whatever.com
DocumentRoot /var/www/rails/public # the path to your rails app
<Directory /var/www/rails/public>
AllowOverride all
Options -MultiViews
</Directory>
</VirtualHost>
我总共花了 30 分钟,其中包括几次使用 httpd.conf 的试错,以确保一切正常.
Took me 30 minutes in total, including several trial-errors with the httpd.conf to get everything right.
请注意,安装需要您的机器上至少有 1 GB RAM.
Note that installation requires at least 1 GB RAM on your machine.