出于某种原因,Apache似乎不喜欢我的Rails应用程序,使用Phusion Passenger运行在Google Compute Engine上(现在使用WEBrick)。我是在谷歌"点击部署" ruby实例,在Debian上运行。我还将Ruby更新为2.2.2并设置rvm use global 2.2.2
。
我去rails s
并启动服务器,转到IP地址,从Apache获得一个可爱的500 Internal Error
,说我的服务器配置是各种各样搞砸了。如果我尝试前往<ip_address>:3000
我没有得到服务器的响应。
配置文件(在/ etc / apache2 / sites-available /
中<VirtualHost *:80>
ServerAdmin webmaster@localhost
DocumentRoot /home/nick/qwestera
RailsEnv production
<Directory />
Options FollowSymLinks
AllowOverride None
</Directory>
<Directory "/home/nick/qwestera">
Options FollowSymLinks
Require all granted
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
# Possible values include: debug, info, notice, warn, error, crit,
# alert, emerg.
LogLevel warn
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
日志(错误重复):
[ 2015-07-31 18:46:36.9094 8146/7f0809eaa720 agents/Watchdog/Main.cpp:728 ]: All Phusion Passenger agents started!
[Fri Jul 31 18:46:36 2015] [notice] Apache/2.2.22 (Debian) Phusion_Passenger/4.0.58 configured -- resuming normal operations
[Fri Jul 31 18:46:48 2015] [crit] [client 98.117.13.138] configuration error: couldn't perform authentication. AuthType not set!: /
[Fri Jul 31 18:46:49 2015] [crit] [client 98.117.13.138] configuration error: couldn't perform authentication. AuthType not set!: /favicon.ico, referer: http://130.211.115.98/
[Fri Jul 31 18:46:58 2015] [crit] [client 98.117.13.138] configuration error: couldn't perform authentication. AuthType not set!: /
[Fri Jul 31 18:46:59 2015] [crit] [client 98.117.13.138] configuration error: couldn't perform authentication. AuthType not set!: /favicon.ico, referer: http://130.211.115.98/
[Fri Jul 31 18:47:02 2015] [crit] [client 98.117.13.138] configuration error: couldn't perform authentication. AuthType not set!: /
[Fri Jul 31 18:47:02 2015] [crit] [client 98.117.13.138] configuration error: couldn't perform authentication. AuthType not set!: /favicon.ico, referer: http://130.211.115.98/
[Fri Jul 31 18:47:17 2015] [crit] [client 98.117.13.138] configuration error: couldn't perform authentication. AuthType not set!: /
[Fri Jul 31 18:47:17 2015] [crit] [client 98.117.13.138] configuration error: couldn't perform authentication. AuthType not set!: /favicon.ico, referer: http://130.211.115.98/
[Fri Jul 31 18:47:17 2015] [crit] [client 98.117.13.138] configuration error: couldn't perform authentication. AuthType not set!: /favicon.ico, referer: http://130.211.115.98/
[Fri Jul 31 18:47:19 2015] [crit] [client 98.117.13.138] configuration error: couldn't perform authentication. AuthType not set!: /
[Fri Jul 31 18:47:19 2015] [crit] [client 98.117.13.138] configuration error: couldn't perform authentication. AuthType not set!: /favicon.ico, referer: http://130.211.115.98/
[Fri Jul 31 18:48:08 2015] [crit] [client 98.117.13.138] configuration error: couldn't perform authentication. AuthType not set!: /
[Fri Jul 31 18:48:08 2015] [crit] [client 98.117.13.138] configuration error: couldn't perform authentication. AuthType not set!: /favicon.ico, referer: http://130.211.115.98/
[Fri Jul 31 18:55:23 2015] [notice] caught SIGTERM, shutting down
[ 2015-07-31 18:55:24.5305 3807/7f317e333720 agents/Watchdog/Main.cpp:538 ]: Options: { 'analytics_log_user' => 'nobody', 'default_group' => 'nogroup', 'default_python' => 'python', 'default_ruby' => '/usr/local/rvm/gems/ruby-2.1.1/wrappers/ruby', 'default_user' => 'nobody', 'log_level' => '0', 'max_pool_size' => '6', 'passenger_root' => '/usr/local/rvm/gems/ruby-2.1.1/gems/passenger-4.0.58', 'passenger_version' => '4.0.58', 'pool_idle_time' => '300', 'temp_dir' => '/tmp', 'union_station_gateway_address' => 'gateway.unionstationapp.com', 'union_station_gateway_port' => '443', 'user_switching' => 'true', 'web_server_passenger_version' => '4.0.58', 'web_server_pid' => '5755', 'web_server_type' => 'apache', 'web_server_worker_gid' => '33', 'web_server_worker_uid' => '33' }
[ 2015-07-31 18:55:24.5352 3810/7fb4d8c13720 agents/HelperAgent/Main.cpp:650 ]: PassengerHelperAgent online, listening at unix:/tmp/passenger.1.0.3806/generation-0/request
[ 2015-07-31 18:55:24.5413 3816/7f854bdf8740 agents/LoggingAgent/Main.cpp:321 ]: PassengerLoggingAgent online, listening at unix:/tmp/passenger.1.0.3806/generation-0/logging
[ 2015-07-31 18:55:24.5416 3807/7f317e333720 agents/Watchdog/Main.cpp:728 ]: All Phusion Passenger agents started!
[ 2015-07-31 18:55:24.5609 3832/7f94e6c6b720 agents/Watchdog/Main.cpp:538 ]: Options: { 'analytics_log_user' => 'nobody', 'default_group' => 'nogroup', 'default_python' => 'python', 'default_ruby' => '$
[ 2015-07-31 18:55:24.5669 3840/7f6a6a654720 agents/HelperAgent/Main.cpp:650 ]: PassengerHelperAgent online, listening at unix:/tmp/passenger.1.0.3827/generation-0/request
[ 2015-07-31 18:55:24.5730 3853/7f5623e51740 agents/LoggingAgent/Main.cpp:321 ]: PassengerLoggingAgent online, listening at unix:/tmp/passenger.1.0.3827/generation-0/logging
[ 2015-07-31 18:55:24.5733 3832/7f94e6c6b720 agents/Watchdog/Main.cpp:728 ]: All Phusion Passenger agents started!
[Fri Jul 31 18:55:24 2015] [notice] Apache/2.2.22 (Debian) Phusion_Passenger/4.0.58 configured -- resuming normal operations
[Fri Jul 31 18:55:54 2015] [crit] [client 98.117.13.138] configuration error: couldn't perform authentication. AuthType not set!: /
[Fri Jul 31 18:55:54 2015] [crit] [client 98.117.13.138] configuration error: couldn't perform authentication. AuthType not set!: /favicon.ico, referer: http://130.211.115.98/
[Fri Jul 31 18:55:59 2015] [crit] [client 98.117.13.138] configuration error: couldn't perform authentication. AuthType not set!: /
[Fri Jul 31 18:55:59 2015] [crit] [client 98.117.13.138] configuration error: couldn't perform authentication. AuthType not set!: /favicon.ico, referer: http://130.211.115.98/
[Fri Jul 31 18:56:01 2015] [crit] [client 98.117.13.138] configuration error: couldn't perform authentication. AuthType not set!: /
[Fri Jul 31 18:56:01 2015] [crit] [client 98.117.13.138] configuration error: couldn't perform authentication. AuthType not set!: /favicon.ico, referer: http://130.211.115.98/
[Fri Jul 31 18:56:46 2015] [crit] [client 98.117.13.138] configuration error: couldn't perform authentication. AuthType not set!: /
[Fri Jul 31 18:56:46 2015] [crit] [client 98.117.13.138] configuration error: couldn't perform authentication. AuthType not set!: /favicon.ico, referer: http://130.211.115.98/
[Fri Jul 31 18:56:49 2015] [crit] [client 98.117.13.138] configuration error: couldn't perform authentication. AuthType not set!: /
[Fri Jul 31 18:56:49 2015] [crit] [client 98.117.13.138] configuration error: couldn't perform authentication. AuthType not set!: /favicon.ico, referer: http://130.211.115.98/
[Fri Jul 31 18:58:37 2015] [notice] caught SIGTERM, shutting down
[ 2015-07-31 18:58:38.3388 4200/7f8f1041b720 agents/Watchdog/Main.cpp:538 ]: Options: { 'analytics_log_user' => 'nobody', 'default_group' => 'nogroup', 'default_python' => 'python', 'default_ruby' => '$
[ 2015-07-31 18:58:38.3434 4203/7fe96b315720 agents/HelperAgent/Main.cpp:650 ]: PassengerHelperAgent online, listening at unix:/tmp/passenger.1.0.4199/generation-0/request
[ 2015-07-31 18:58:38.3489 4209/7fe051b12740 agents/LoggingAgent/Main.cpp:321 ]: PassengerLoggingAgent online, listening at unix:/tmp/passenger.1.0.4199/generation-0/logging
[ 2015-07-31 18:58:38.3491 4200/7f8f1041b720 agents/Watchdog/Main.cpp:728 ]: All Phusion Passenger agents started!
[ 2015-07-31 18:58:38.3672 4225/7fcc75d26720 agents/Watchdog/Main.cpp:538 ]: Options: { 'analytics_log_user' => 'nobody', 'default_group' => 'nogroup', 'default_python' => 'python', 'default_ruby' => '$
[ 2015-07-31 18:58:38.3725 4233/7f79a2e4c720 agents/HelperAgent/Main.cpp:650 ]: PassengerHelperAgent online, listening at unix:/tmp/passenger.1.0.4220/generation-0/request
[ 2015-07-31 18:58:38.3790 4244/7f0bef1b9740 agents/LoggingAgent/Main.cpp:321 ]: PassengerLoggingAgent online, listening at unix:/tmp/passenger.1.0.4220/generation-0/logging
[ 2015-07-31 18:58:38.3792 4225/7fcc75d26720 agents/Watchdog/Main.cpp:728 ]: All Phusion Passenger agents started!
[Fri Jul 31 18:58:38 2015] [notice] Apache/2.2.22 (Debian) Phusion_Passenger/4.0.58 configured -- resuming normal operations
[Fri Jul 31 18:58:50 2015] [crit] [client 98.117.13.138] configuration error: couldn't perform authentication. AuthType not set!: /
[Fri Jul 31 18:58:50 2015] [crit] [client 98.117.13.138] configuration error: couldn't perform authentication. AuthType not set!: /favicon.ico, referer: http://130.211.115.98/
[Fri Jul 31 18:58:53 2015] [crit] [client 98.117.13.138] configuration error: couldn't perform authentication. AuthType not set!: /
[Fri Jul 31 18:58:53 2015] [crit] [client 98.117.13.138] configuration error: couldn't perform authentication. AuthType not set!: /favicon.ico, referer: http://130.211.115.98/
我认为的日志条目可能会给我一些见解:
[Fri Jul 31 18:55:23 2015] [notice] caught SIGTERM, shutting down
[ 2015-07-31 18:55:24.5305 3807/7f317e333720 agents/Watchdog/Main.cpp:538 ]: Options: { 'analytics_log_user' => 'nobody', 'default_group' => 'nogroup', 'default_python' => 'python', 'default_ruby' => '/usr/local/rvm/gems/ruby-2.1.1/wrappers/ruby', 'default_user' => 'nobody', 'log_level' => '0', 'max_pool_size' => '6', 'passenger_root' => '/usr/local/rvm/gems/ruby-2.1.1/gems/passenger-4.0.58', 'passenger_version' => '4.0.58', 'pool_idle_time' => '300', 'temp_dir' => '/tmp', 'union_station_gateway_address' => 'gateway.unionstationapp.com', 'union_station_gateway_port' => '443', 'user_switching' => 'true', 'web_server_passenger_version' => '4.0.58', 'web_server_pid' => '5755', 'web_server_type' => 'apache', 'web_server_worker_gid' => '33', 'web_server_worker_uid' => '33' }
具体地:
&#39; default_ruby&#39; =&GT; &#39; /usr/local/rvm/gems/ruby-2.1.1/wrappers/ruby',
&#39; passenger_root&#39; =&GT; &#39; /usr/local/rvm/gems/ruby-2.1.1/gems/passenger-4.0.58'
如果您注意到,我说我将ruby更新为2.2.2
,因为我尝试运行的项目使用的是什么。但是,Apache有default_ruby
和passenger_root
目录,包括ruby 2.1.1
。这会是问题吗?如果是这样,我该怎么改变呢?
更新
删除Require all granted
让我更近了一步(这条线只对于大于2.4的Apache版本是必需的,我的版本是2.2)。
现在我正在获取一个乘客页面(我的rails应用程序&favicon.ico出现了,是的!),让我知道Web application could not be started
。
它向我显示了以下错误:
Your Ruby version is 2.1.1, but your Gemfile specified 2.2.2 (Bundler::RubyVersionMismatch)
/usr/local/rvm/gems/ruby-2.1.1@global/gems/bundler-1.5.3/lib/bundler/definition.rb:390:in `validate_ruby!'
/usr/local/rvm/gems/ruby-2.1.1@global/gems/bundler-1.5.3/lib/bundler.rb:115:in `setup'
/usr/local/rvm/gems/ruby-2.1.1@global/gems/bundler-1.5.3/lib/bundler/setup.rb:17:in `<top (required)>'
/usr/local/rvm/rubies/ruby-2.1.1/lib/ruby/2.1.0/rubygems/core_ext/kernel_require.rb:135:in `require'
/usr/local/rvm/rubies/ruby-2.1.1/lib/ruby/2.1.0/rubygems/core_ext/kernel_require.rb:135:in `rescue in require'
/usr/local/rvm/rubies/ruby-2.1.1/lib/ruby/2.1.0/rubygems/core_ext/kernel_require.rb:144:in `require'
/usr/local/rvm/gems/ruby-2.1.1/gems/passenger-4.0.58/lib/phusion_passenger/loader_shared_helpers.rb:263:in `block in run_load_path_setup_code'
/usr/local/rvm/gems/ruby-2.1.1/gems/passenger-4.0.58/lib/phusion_passenger/loader_shared_helpers.rb:366:in `running_bundler'
/usr/local/rvm/gems/ruby-2.1.1/gems/passenger-4.0.58/lib/phusion_passenger/loader_shared_helpers.rb:261:in `run_load_path_setup_code'
/usr/local/rvm/gems/ruby-2.1.1/gems/passenger-4.0.58/helper-scripts/rack-preloader.rb:100:in `preload_app'
/usr/local/rvm/gems/ruby-2.1.1/gems/passenger-4.0.58/helper-scripts/rack-preloader.rb:158:in `<module:App>'
/usr/local/rvm/gems/ruby-2.1.1/gems/passenger-4.0.58/helper-scripts/rack-preloader.rb:29:in `<module:PhusionPassenger>'
/usr/local/rvm/gems/ruby-2.1.1/gems/passenger-4.0.58/helper-scripts/rack-preloader.rb:28:in `<main>'
故障: 我完全称这是一个Ruby版本问题!现在,我如何让乘客知道在2.2.2的新Ruby目录中查找内容?
有趣且可能富有洞察力:
$ ruby --version
ruby 2.2.2p95 (2015-04-13 revision 50295) [x86_64-linux]
$ ruby -version
ruby 2.2.2p95 (2015-04-13 revision 50295) [x86_64-linux]
-e:1:in `<main>': undefined local variable or method `rsion' for main:Object (NameError)
ruby -version
会返回NameError
,但ruby --version
则不会。跆拳道?
更新2:
好吧,我已经将/etc/apache2/apache2.conf更新为指向新目录。但是,我的rails应用程序实际上并没有运行。我只看到我的应用程序中的所有文件和文件夹的索引。我如何告诉它开始?
答案 0 :(得分:2)
通过使用rvm uninstall 2.1.1
卸载旧版本的Ruby,使用rvm install 2.2.2
重新安装新版本,然后使用passenger-install-apache2-module
重新安装乘客解决此问题。