gpt4 book ai didi

ruby-on-rails - Apache with Passenger 不加载 Rails 应用程序

转载 作者:数据小太阳 更新时间:2023-10-29 08:05:12 24 4
gpt4 key购买 nike

我正在开发 Rails 应用程序并尝试配置部署它的 Web 服务器。我的问题是页面无法加载。

在 Apache 的 error.log没有错误,在我的应用程序的 log/production.log 中只有行 Connecting to database specified by database.yml出现。

我在应用程序的公用文件夹中没有 index.html,应用程序在开发环境中运行良好。

我正在使用 Amazon 实例和 Ubuntu 12.04,并且我已经通过 RVM 安装了 ruby​​。在我的 httpd.conf 中我有:

LoadModule passenger_module /home/ubuntu/.rvm/gems/ruby-1.9.3-p194/gems/passenger-3.0.17/ext/apache2/mod_passenger.so
PassengerRoot /home/ubuntu/.rvm/gems/ruby-1.9.3-p194/gems/passenger-3.0.17
PassengerRuby /home/ubuntu/.rvm/wrappers/ruby-1.9.3-p194/ruby

Apache 启动时没有错误。

下面是我的sites-available/default:

# other virtualhosts
#

<VirtualHost *:80>
ServerName my_app.mydomain.com
ServerAdmin mail@mail.com

DocumentRoot /home/ubuntu/public_html/my_app/current/public

<Directory /home/ubuntu/public_html/my_app/current/public>
Allow from all
Options -MultiViews
</Directory>

ErrorLog ${APACHE_LOG_DIR}/error.log
</VirtualHost>

我现在应该怎么做才能让乘客工作?

最佳答案

我决定重新安装 Ruby 和所有其他东西并迁移到 nginx。终于 现在我可以正常工作了(在 ngnix 和 apache 中)。如果有人关心,这就是我所做的:

Ruby + Rails

通过 RVM 安装 ruby​​ + rails

curl -L https://get.rvm.io | bash -s stable --rails

在所有打开的 shell 中加载 rvm

source ~/.rvm/scripts/rvm

安装 gem

gem install passenger

Apache

安装apache和passenger模块

rvmsudo passenger-install-apache2-module

将这些行复制到 /etc/apache2/httpd.conf

LoadModule passenger_module /home/ubuntu/.rvm/gems/ruby-1.9.3-p194/gems/passenger-3.0.17/ext/apache2/mod_passenger.so
PassengerRoot /home/ubuntu/.rvm/gems/ruby-1.9.3-p194/gems/passenger-3.0.17
PassengerRuby /home/ubuntu/.rvm/wrappers/ruby-1.9.3-p194/ruby

nginx

安装nginx和passenger模块

rvmsudo passenger-install-nginx-module

将这些行复制到/opt/nginx/conf/nginx.conf

passenger_root /home/ubuntu/.rvm/gems/ruby-1.9.3-p194/gems/passenger-3.0.17;
passenger_ruby /home/ubuntu/.rvm/wrappers/ruby-1.9.3-p194/ruby;

设置脚本以允许您控制 Nginx

wget -O init-deb.sh http://library.linode.com/assets/660-init-deb.sh
sudo mv init-deb.sh /etc/init.d/nginx
sudo chmod +x /etc/init.d/nginx
sudo /usr/sbin/update-rc.d -f nginx defaults

您现在可以使用此脚本控制 Nginx

sudo /etc/init.d/nginx stop
sudo /etc/init.d/nginx start

nodejs 的最终设置

您需要的其他东西之一是 Node.js。这将帮助您在部署时编译 Assets

sudo apt-add-repository ppa:chris-lea/node.js
sudo apt-get -y update
sudo apt-get -y install nodejs

关于ruby-on-rails - Apache with Passenger 不加载 Rails 应用程序,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12329488/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com