0

我是linux和rails的新手,我試圖讓開發服務器啓動並運行。我已經安裝了ruby/rails,並在localhost:3000下運行。我可以創建一個rails應用程序並讓它運行。Rails啓動時的web應用程序錯誤

然後我安裝了apache 2/passenger。當我試着打我收到以下錯誤的機器的IP地址:

It looks like Bundler could not find a gem. Maybe you didn't install all the gems that this application needs. To install your gems, please run: 

bundle install 

If that didn't work, then the problem is probably caused by your application being run under a different environment than it's supposed to. Please check the following: 

Is this app supposed to be run as the a-cjstewar user? 
Is this app being run on the correct Ruby interpreter? Below you will see which Ruby interpreter Phusion Passenger attempted to use. 

-------- The exception is as follows: ------- 

Could not find rake-12.0.0 in any of the sources (Bundler::GemNotFound) 
    /var/lib/gems/2.3.0/gems/bundler-1.15.3/lib/bundler/spec_set.rb:87:in `block in materialize' 
    /var/lib/gems/2.3.0/gems/bundler-1.15.3/lib/bundler/spec_set.rb:81:in `map!' 
    /var/lib/gems/2.3.0/gems/bundler-1.15.3/lib/bundler/spec_set.rb:81:in `materialize' 
    /var/lib/gems/2.3.0/gems/bundler-1.15.3/lib/bundler/definition.rb:159:in `specs' 
    /var/lib/gems/2.3.0/gems/bundler-1.15.3/lib/bundler/definition.rb:218:in `specs_for' 
    /var/lib/gems/2.3.0/gems/bundler-1.15.3/lib/bundler/definition.rb:207:in `requested_specs' 
    /var/lib/gems/2.3.0/gems/bundler-1.15.3/lib/bundler/runtime.rb:109:in `block in definition_method' 
    /var/lib/gems/2.3.0/gems/bundler-1.15.3/lib/bundler/runtime.rb:21:in `setup' 
    /var/lib/gems/2.3.0/gems/bundler-1.15.3/lib/bundler.rb:101:in `setup' 
    /var/lib/gems/2.3.0/gems/bundler-1.15.3/lib/bundler/setup.rb:19:in `<top (required)>' 
    /usr/lib/ruby/2.3.0/rubygems/core_ext/kernel_require.rb:55:in `require' 
    /usr/lib/ruby/2.3.0/rubygems/core_ext/kernel_require.rb:55:in `require' 
    /usr/lib/ruby/vendor_ruby/phusion_passenger/loader_shared_helpers.rb:430:in `activate_gem' 
    /usr/lib/ruby/vendor_ruby/phusion_passenger/loader_shared_helpers.rb:297:in `block in run_load_path_setup_code' 
    /usr/lib/ruby/vendor_ruby/phusion_passenger/loader_shared_helpers.rb:435:in `running_bundler' 
    /usr/lib/ruby/vendor_ruby/phusion_passenger/loader_shared_helpers.rb:296:in `run_load_path_setup_code' 
    /usr/share/passenger/helper-scripts/rack-preloader.rb:100:in `preload_app' 
    /usr/share/passenger/helper-scripts/rack-preloader.rb:156:in `<module:App>' 
    /usr/share/passenger/helper-scripts/rack-preloader.rb:30:in `<module:PhusionPassenger>' 
    /usr/share/passenger/helper-scripts/rack-preloader.rb:29:in `<main>' 

這裏是我的app1.conf文件:

<VirtualHost *:80> 
    ServerName 122.112.8.102 
    ServerAdmin [email protected] 
    DocumentRoot /home/username/app1/public 
    RailsEnv development 
    ErrorLog ${APACHE_LOG_DIR}/error.log 
    CustomLog ${APACHE_LOG_DIR}/access.log combined 
    <Directory "/home/username/app1/public"> 
     Require all granted 
     Options FollowSymLinks 
     # This relaxes Apache security settings. 
     AllowOverride None 
     # MultiViews must be turned off. 
     Order allow,deny 
     Allow from all 
    </Directory> 
</VirtualHost> 

紅寶石-v

ruby 2.4.0p0 (2016-12-24 revision 57164) [x86_64-linux] 

rails -v

Rails 5.1.2 

apache2 -v

Server version: Apache/2.4.18 (Ubuntu) 

乘客-v

Phusion Passenger 5.1.6 

我不知道在哪裏可以從這裏走。任何幫助表示讚賞!

+0

你在項目中運行'bundle install'嗎? – philnash

+0

是的,我有。一切都安裝沒有任何問題。 – spacerobot

+0

我的意思是,這不是沒有問題,是它! 「bundle install」是否由運行服務器的同一個用戶運行,「a-cjstewar」? – philnash

回答

1

看起來,您正在運行的應用程序所用的Ruby與您認爲的不同。

爲了得到你說你的應用程序應該在運行的Ruby 2.4.0p0,你應該找出那紅寶石位於與

which ruby 

然後,您可以設置可執行文件作爲紅寶石你想在你的<VirtualHost>使用PassengerRuby指令的使用方法:

<VirtualHost *:80> 
    PassengerRuby: /path/to/ruby 
    # other stuff 
</VirtualHost> 

退房the documentation for the PassengerRuby directive瞭解更多信息。

+0

耶!就是這樣。一旦我添加了現在正在工作的路徑。我很感激幫助。 – spacerobot