在 Cent os 5.8 上为我的 Rails 应用程序设置 Apache+passenger

问题描述 投票:0回答:1

我正在努力为我的 Cent OS 服务器 5.8 上的 Rails 应用程序设置虚拟主机。 我已经安装了 apache 即 httpd。

然后使用

gem install passenger
安装 Passenger。

安装正常。

然后使用

passenger-install-apache2-module
命令为乘客安装 apache 模块。

然后编辑

/etc/httpd/conf/httpd.conf
并添加以下行来设置我的虚拟主机

LoadModule passenger_module /usr/local/rvm/gems/ruby-1.8.7-p160/gems/passenger-3.0.17/ext/apache2/mod_passenger.so
PassengerRoot /usr/local/rvm/gems/ruby-1.8.7-p160/gems/passenger-3.0.17
PassengerRuby /usr/local/rvm/wrappers/ruby-1.8.7-p160/ruby

<VirtualHost *:80>
  ServerAdmin [email protected]
  RailsEnv development
  DocumentRoot /var/www/college/public
  ServerName dummy-host.example.com
  ErrorLog logs/dummy-host.example.com-error_log
  CustomLog logs/dummy-host.example.com-access_log common

 <directory /var/www/college/public>
   AllowOverride all
   Options -MultiViews
 </directory>

</VirtualHost>

使用

# chown -R apache.apache *
命令将项目所有者更改为 apache

现在我在我的应用程序“学院”中为“学生”创建了一个脚手架。 但显示

public/index
rails environment details
页面和
student
模型的索引页面都不起作用。请指导我到底出了什么问题,因为我对这些服务器配置是新手。谢谢!

更新: 我从公共目录中删除了索引页面并使用 home 方法创建了控制器页面。然后我设置了 root :to => 'pages#home'

现在,当我检查

dummy-host.example.com-error_log
的日志时,它显示了

Directory index forbidden by Options directive: /var/www/college/public/

当我从

/var/log/httpd/error_log
追踪日志时,它显示了

[notice] caught SIGTERM, shutting down
 [notice] SELinux policy enabled; httpd running as context root:system_r:httpd_t:s0
 [notice] suEXEC mechanism enabled (wrapper: /usr/sbin/suexec)
 [error] *** Passenger could not be initialized because of this error: Cannot create FIFO file /tmp/passenger.3469/.guard: Permission denied (13)
 [warn] module passenger_module is already loaded, skipping
 [notice] Digest: generating secret for digest authentication ...
 [notice] Digest: done
[error] *** Passenger could not be initialized because of this error: Cannot create FIFO file /tmp/passenger.3471/.guard: Permission denied (13)
 [notice] Apache/2.2.3 (CentOS) configured -- resuming normal operations

现在有人请告诉我出了什么问题吗?

更新2 现在我按照下面提到的答案进行操作。现在出现以下错误

[notice] SELinux policy enabled; httpd running as context root:system_r:httpd_t:s0
[notice] suEXEC mechanism enabled (wrapper: /usr/sbin/suexec)
[error] *** Passenger could not be initialized because of this error: The Passenger spawn server script, '/usr/local/lib/ruby/gems/1.8/gems/passenger-3.0.15/lib/phusion_passenger/passenger-spawn-server', does not exist. Please check whether the 'PassengerRoot' option is specified correctly.
[warn] module passenger_module is already loaded, skipping
[notice] Digest: generating secret for digest authentication ...
[notice] Digest: done
[error] *** Passenger could not be initialized because of this error: The Passenger spawn server script, '/usr/local/lib/ruby/gems/1.8/gems/passenger-3.0.15/lib/phusion_passenger/passenger-spawn-server', does not exist. Please check whether the 'PassengerRoot' option is specified correctly.
[notice] Apache/2.2.3 (CentOS) configured -- resuming normal operations

现在我的乘客安装成功了,那么问题出在哪里呢?

ruby-on-rails-3 centos virtualhost passenger httpd.conf
1个回答
1
投票

你看到这篇文章了吗https://stackoverflow.com/a/2429590/621354

我是 ubuntu 用户,但你的“apache”用户不是“www-data”?

© www.soinside.com 2019 - 2024. All rights reserved.