简体   繁体   English

Rails应用程序不适用于Apache + Passenger

[英]Rails app not working with Apache + Passenger

I am trying to host a rails2 application on a new Virtual Machine which is CentOS 6 with Parallels Plesk Panel 11 (64-bit). 我试图在新的虚拟机上托管rails2应用程序,该虚拟机是带有Parallels Plesk Panel 11(64位)的CentOS 6。 I have installed RVM,ruby,rails, and passanger Succefully using the steps given here 我已经使用此处给出的步骤成功安装了RVM,红宝石,铁路和passanger

I have followed all the steps correctly. 我正确地遵循了所有步骤。 I have installed ruby 1.8.7 and rails 2.0.2 我已经安装了ruby 1.8.7rails 2.0.2

Now the thing is that, I am able to run the application using the Webrick server at 3000 port on the new server. 现在的事情是,我能够使用Webrick服务器在新服务器的3000端口上运行该应用程序。 Everything works fine there. 那里一切正常。 But when I want to run it with apache, it doesn't run. 但是,当我想用​​apache运行它时,它不会运行。 when I hit the url it returns the page 当我点击网址时,它返回页面

Not Found 未找到

The requested URL /account/login was not found on this server. 在此服务器上找不到请求的URL / account / login。 Apache Server at www.mem.com Port 80 www.mem.com端口80上的Apache服务器

Here is my passanger.conf file : 这是我的passanger.conf文件:

/etc/httpd/conf.d/passenger.conf /etc/httpd/conf.d/passenger.conf

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

Here is my virtual Host code : 这是我的虚拟主机代码:

/etc/httpd/sites-available/mem.conf /etc/httpd/sites-available/mem.conf

    <VirtualHost *:80>
 ServerAdmin youremail@example.com
 DocumentRoot /var/www/mem/public
 ServerName www.mem.com
 ErrorLog /var/log/httpd/mem/error.log
 CustomLog /var/log/httpd/mem/access.log common
</VirtualHost>

Any suggestions will be greatly appreciated. 任何建议将不胜感激。

The issue has been resolved. 该问题已解决。 There already a Virtual Host had been created with different Document Root by the web hosting company. 网络托管公司已经使用不同的文档根目录创建了虚拟主机。 I moved my app directory to that path and application started. 我将我的应用程序目录移至该路径,然后启动了应用程序。 Thanks everyone for the suggestions. 谢谢大家的建议。

You may also see this if you manage to set DocumentRoot to the wrong or non-existing directory. 如果您设法将DocumentRoot设置为错误或不存在的目录,也可能会看到此信息。 If you can't figure this out, double check that it exists. 如果您无法弄清楚,请再次检查它是否存在。

Try adding a this directory block inside your VirtualHost 尝试在您的VirtualHost中添加此目录块

<Directory /var/www/mem/public>
    Allow from all
    Options -MultiViews
</Directory>

I'm running a CentOS 6 box with Apache & the Passenger module. 我正在使用Apache和Passenger模块运行一个CentOS 6盒子。 My site configuration lives within the /etc/httpd/sites-enabled/ folder. 我的站点配置位于/etc/httpd/sites-enabled/文件夹中。 Here's my conf: 这是我的conf:

# /etc/httpd/sites-enabled/hello-world.conf
<VirtualHost *:80>
    ServerName hello-world.localhost
    DocumentRoot /var/www/hello/public
    <Directory /var/www/hello/public>
        Allow from all
        Options -MultiViews
    </Directory>
</VirtualHost>

Always remember to restart apache: 始终记得重新启动apache:

$ sudo apachectl restart

Hopefully this might help you. 希望这可以对您有所帮助。 Good luck. 祝好运。

I had the same problem myself, though with a rails3 app on rhel 6.2 (64bit) and ruby-1.8.7 with https. 我自己遇到了同样的问题,尽管在rhel 6.2(64位)和ruby-1.8.7(带有https)上使用了rails3应用程序。 I fixed my problem by adding following line at the end (after "VirtualHost" section) in /etc/httpd/conf.d/myapp.conf: 我通过在/etc/httpd/conf.d/myapp.conf中的末尾(“ VirtualHost”部分之后)添加以下行来解决我的问题:

    PassengerPreStart https://<url-to-my-rails-app>

Once apache is restarted, my app shows up properly. apache重新启动后,我的应用程序会正确显示。

You can find more information from passenger user guide for apache: http://www.modrails.com/documentation/Users%20guide%20Apache.html#User_switching 您可以从针对apache的旅客用户指南中找到更多信息: http : //www.modrails.com/documentation/Users%20guide%20Apache.html#User_switching

Disable selinux. 禁用selinux。

Answer must be at least 30 characters. 答案必须至少30个字符。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM