0

因此,过去几周我一直在开发我的第一个(真正的)rails 应用程序,昨天我尝试使用 Rubber gem 将它部署到 Amazon EC2。在我部署我的实际项目之前,我对自己说:让我们在一个全新且简单的项目上尝试一下橡胶,看看它是否有效。在执行了这个 [railscast][1] 中的步骤之后,一切都与这个简单的项目一起工作了。所以我尝试部署我的真实项目,执行与以前相同的步骤。Rubber 执行了所有 Capistrano 脚本,一切似乎都很顺利。但是当我尝试访问该网站时,我收到了这个错误:503 Service Unavailable

我使用了橡胶模板“complete_passenger_postgresql”。我部署成功的简单项目和真实项目的橡胶设置基本一致。区别在于应用程序的实际内容。

查看日志文件后,我遇到了这些错误:

阿帕奇错误日志:

    [Thu Dec 13 14:24:02 2012] [notice] Apache/2.2.22 (Ubuntu) configured -- resuming normal operations
[Thu Dec 13 14:24:10 2012] [notice] Graceful restart requested, doing restart
[Thu Dec 13 14:24:10 2012] [notice] Apache/2.2.22 (Ubuntu) proxy_html/3.0.1 configured -- resuming normal operations
[Thu Dec 13 14:24:10 2012] [notice] caught SIGTERM, shutting down
[Thu Dec 13 14:24:12 2012] [warn] mod_wsgi: Compiled for Python/2.7.2+.
[Thu Dec 13 14:24:12 2012] [warn] mod_wsgi: Runtime using Python/2.7.3.
[Thu Dec 13 14:24:12 2012] [notice] Apache/2.2.22 (Ubuntu) proxy_html/3.0.1 mod_wsgi/3.3 Python/2.7.3 configured -- resuming normal operations
[Thu Dec 13 14:24:51 2012] [notice] caught SIGTERM, shutting down
[Thu Dec 13 14:26:26 2012] [warn] mod_wsgi: Compiled for Python/2.7.2+.
[Thu Dec 13 14:26:26 2012] [warn] mod_wsgi: Runtime using Python/2.7.3.
[Thu Dec 13 14:26:26 2012] [notice] Apache/2.2.22 (Ubuntu) proxy_html/3.0.1 mod_wsgi/3.3 Python/2.7.3 configured -- resuming normal operations
[Thu Dec 13 14:50:55 2012] [notice] caught SIGTERM, shutting down
[Thu Dec 13 14:51:50 2012] [warn] mod_wsgi: Compiled for Python/2.7.2+.
[Thu Dec 13 14:51:50 2012] [warn] mod_wsgi: Runtime using Python/2.7.3.
[Thu Dec 13 14:51:51 2012] [notice] Apache/2.2.22 (Ubuntu) proxy_html/3.0.1 mod_wsgi/3.3 Python/2.7.3 configured -- resuming normal operations
[Thu Dec 13 14:54:49 2012] [notice] caught SIGTERM, shutting down
[Thu Dec 13 14:57:48 2012] [warn] RSA server certificate CommonName (CN) `production.test.com' does NOT match server name!?
[Thu Dec 13 14:57:48 2012] [warn] RSA server certificate CommonName (CN) `production.test.com' does NOT match server name!?
[Thu Dec 13 14:57:48 2012] [warn] RSA server certificate CommonName (CN) `production.test.com' does NOT match server name!?
[Thu Dec 13 14:57:48 2012] [warn] RSA server certificate CommonName (CN) `production.test.com' does NOT match server name!?
[Thu Dec 13 14:57:48 2012] [warn] Init: Name-based SSL virtual hosts only work for clients with TLS server name indication support (RFC 4366)
[Thu Dec 13 14:57:48 2012] [warn] RSA server certificate CommonName (CN) `production.test.com' does NOT match server name!?
[Thu Dec 13 14:57:48 2012] [warn] RSA server certificate CommonName (CN) `production.test.com' does NOT match server name!?
[Thu Dec 13 14:57:48 2012] [warn] RSA server certificate CommonName (CN) `production.test.com' does NOT match server name!?
[Thu Dec 13 14:57:48 2012] [warn] RSA server certificate CommonName (CN) `production.test.com' does NOT match server name!?
[Thu Dec 13 14:57:48 2012] [warn] Init: Name-based SSL virtual hosts only work for clients with TLS server name indication support (RFC 4366)
[Thu Dec 13 14:57:48 2012] [warn] mod_wsgi: Compiled for Python/2.7.2+.
[Thu Dec 13 14:57:48 2012] [warn] mod_wsgi: Runtime using Python/2.7.3.
[Thu Dec 13 14:57:48 2012] [notice] Apache/2.2.22 (Ubuntu) proxy_html/3.0.1 mod_ssl/2.2.22 OpenSSL/1.0.1 mod_wsgi/3.3 Python/2.7.3 Phusion_Passenger/3.0.17 configured -- resuming normal operations
[Thu Dec 13 14:57:53 2012] [crit] [client XX.XXX.XXX.XX] (13)Permission denied: /mnt/test_core-production/releases/20121213133228/.htaccess pcfg_openfile: unable to check htaccess file, ensure it is readable
[Thu Dec 13 14:57:55 2012] [crit] [client XX.XXX.XXX.XX] (13)Permission denied: /mnt/test_core-production/releases/20121213133228/.htaccess pcfg_openfile: unable to check htaccess file, ensure it is readable
[Thu Dec 13 14:57:57 2012] [crit] [client XX.XXX.XXX.XX] (13)Permission denied: /mnt/test_core-production/releases/20121213133228/.htaccess pcfg_openfile: unable to check htaccess file, ensure it is readable
Last Line repeats like a 1000 times.

Cron-SH-Bundle 日志:

rubber:cron running ["bundle", "exec", "rake", "subscriptions:send"] at 2012-12-13 20:15:06 +0100
rake aborted!
uninitialized constant ActiveRecord
/mnt/test_core-production/shared/bundle/ruby/1.9.1/gems/ancestry-1.3.0/lib/ancestry/has_ancestry.rb:1:in `<top (required)>'
/mnt/test_core-production/shared/bundle/ruby/1.9.1/gems/ancestry-1.3.0/lib/ancestry.rb:4:in `require'
/mnt/test_core-production/shared/bundle/ruby/1.9.1/gems/ancestry-1.3.0/lib/ancestry.rb:4:in `<top (required)>'
/usr/local/rvm/gems/ruby-1.9.3-p327@global/gems/bundler-1.2.3/lib/bundler/runtime.rb:68:in `require'
/usr/local/rvm/gems/ruby-1.9.3-p327@global/gems/bundler-1.2.3/lib/bundler/runtime.rb:68:in `block (2 levels) in require'
/usr/local/rvm/gems/ruby-1.9.3-p327@global/gems/bundler-1.2.3/lib/bundler/runtime.rb:66:in `each'
/usr/local/rvm/gems/ruby-1.9.3-p327@global/gems/bundler-1.2.3/lib/bundler/runtime.rb:66:in `block in require'
/usr/local/rvm/gems/ruby-1.9.3-p327@global/gems/bundler-1.2.3/lib/bundler/runtime.rb:55:in `each'
/usr/local/rvm/gems/ruby-1.9.3-p327@global/gems/bundler-1.2.3/lib/bundler/runtime.rb:55:in `require'
/usr/local/rvm/gems/ruby-1.9.3-p327@global/gems/bundler-1.2.3/lib/bundler.rb:128:in `require'
/usr/local/graylog2-web-interface-0.9.6p1/config/application.rb:16:in `<top (required)>'
/usr/local/graylog2-web-interface-0.9.6p1/Rakefile:4:in `require'
/usr/local/graylog2-web-interface-0.9.6p1/Rakefile:4:in `<top (required)>'
(See full trace by running task with --trace)

Rails 生产日志

Connecting to database specified by database.yml
Compiled jquery.js  (2ms)  (pid 23834)
Compiled jquery-ui.js  (7ms)  (pid 23834)
...
Connecting to database specified by database.yml
Migrating to CreateUsers (20120903114829)
...
Connecting to database specified by database.yml
Connecting to database specified by database.yml
PG::Error: connection not open // <-- I think this happens while seeding data
: UPDATE "delayed_jobs" SET locked_by = null, locked_at = null WHERE (locked_by = 'delayed_job host:production.test.com pid:24702')

难道是宝石“祖先”可能会导致这个问题?那么“权限被拒绝”错误呢?

非常感谢你的帮助!

4

1 回答 1

0

我设法通过以下方式解决了上述问题:

首先,我通过应用为 rails 项目的目录和文件赋予了适当的权限

sudo chmod -R 777 ProjectDirectory

这解决了 Apache 权限错误。出现这个问题的原因是我在另一台windows和linux机器上创建了项目,并试图将它部署在mac上。简单的测试项目之所以有效,是因为我在部署它的同一台机器上创建了它。

接下来,我将以下代码行添加到我的 see.rb 文件中,以消除“未初始化的常量 ActiveRecord”错误:

require 'active_record'

在这些调整之后,我再次使用橡胶部署了所有东西并且它正在工作:-)

于 2012-12-14T10:42:09.597 回答