首页 文章

关于apache的Rails app,乘客列出目录而不是显示登录页面?

提问于
浏览
0

我正在部署ruby-on-rails应用程序 .

我已经配置了apache和passenger,并且http服务器正在侦听端口80.当我尝试使用浏览器访问主页时,我只获取文件和目录列表而不是主页 .

以下是apache配置的片段 .

/etc/apache2/apache2.conf中

<Directory />
    #Options FollowSymLinks
    Options Indexes FollowSymLinks Includes ExecCGI
    AllowOverride All
    Order deny,allow
    Allow from all
</Directory>

/etc/apache2/httpd.conf

LoadModule passenger_module /home/user1/.rvm/gems/ruby-2.3.0/gems/passenger-5.0.27/buildout/apache2/mod_passenger.so
   <IfModule mod_passenger.c>
     PassengerRoot /home/user1/.rvm/gems/ruby-2.3.0/gems/passenger-5.0.27
     PassengerDefaultRuby /home/user1/.rvm/gems/ruby-2.3.0/wrappers/ruby
   </IfModule>

/etc/apache2/sites-available/ubuntuvm-4.conf

<VirtualHost *:80>
    ServerAdmin admin@ubuntuvm-4.com
    ServerName ubuntuvm-4
    ServerAlias www.ubuntuvm-4.com
    DocumentRoot /home/user1/www/myapp/public
    ErrorLog ${APACHE_LOG_DIR}/error.log
    CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>

出了什么问题?可能是我试图通过IP地址http://192.168.0.12访问该页面?如果你想让我放任何其他配置,请大喊 .

2 回答

  • 0

    尝试使用Ruby 2.3.2(RVM,因为.deb打包版本太旧了)在Ubuntu 12.04上部署4.2.1 Rails应用程序时遇到了同样的问题!Apache 2.2和Passenger 5.0.4(.deb) . 好吧,在浪费了几天试图找出为什么乘客不会启动(我做了一千次,它总是有效)之后,我意识到这只是因为乘客无法在任何地方打印其日志 . 因此,如果您已经尝试过在论坛上阅读的所有内容,只需尝试在apache配置中添加日志文件的路径:

    PassengerLogFile /var/log/passenger.log
    

    它像魔术一样工作 . 希望这可以帮助 .

  • 0

    尝试将文件 /etc/apache2/sites-available/ubuntuvm-4.conf 的内容复制到 /etc/apache2/sites-enabled/ubuntuvm-4.conf

    cp /etc/apache2/sites-available/ubuntuvm-4.conf /etc/apache2/sites-enabled/ubuntuvm-4.conf
    

    您需要像这样创建配置

    <VirtualHost *:80>
          ServerName ubuntuvm-4
            <Location /home/user1/www/myapp/public>
                PassengerBaseURI /
                PassengerAppRoot /home/user1/www/myapp
            </Location>
              DocumentRoot /home/user1/www/myapp/public
              <Directory /home/user1/www/myapp/public>
                 AllowOverride all
                 RailsEnv production
                 # MultiViews must be turned off.
                 Options -MultiViews
                 # Uncomment this if you're on Apache >= 2.4:
                 Require all granted
              </Directory>
    
    </VirtualHost>
    

相关问题