0

运行后

sudo service apache2 restart

我有

[Thu Dec 04 15:30:37 2014] [warn] module passenger_module is already loaded, skipping
Syntax error on line 274 of /etc/apache2/apache2.conf:
Invalid command 'PassengerDefaultRuby', perhaps misspelled or defined by a module not included in          the server configuration
Action 'configtest' failed.
The Apache error log may have more information.
 failed!

在 apache.conf 的末尾我有:(这行是我在乘客安装 apache2 模块之后得到的)

LoadModule passenger_module /home/ruslan/.rvm/gems/r$
<IfModule mod_passenger.c>
 PassengerRoot /home/ruslan/.rvm/gems/ruby-2.1.5/gem$
 PassengerDefaultRuby /home/ruslan/.rvm/gems/ruby-2.$
</IfModule>

在 /etc/apache2/mods-available/passenger.conf :

<VirtualHost *:80>
    ServerName www.rackexample.com
    DocumentRoot /home/ruslan/blog/public
    <Directory /home/ruslan/blog/public>
        Allow from all
        Options -MultiViews
        # Uncomment this if you're on Apache >= 2.4:
        #Require all granted
    </Directory>
</VirtualHost>

在 /etc/apache2/sites-enabled/mysite 我有相同的:

<VirtualHost *:80>
    ServerName www.rackexample.com
    DocumentRoot /home/ruslan/blog/public
    <Directory /home/ruslan/blog/public>
        Allow from all
        Options -MultiViews
        # Uncomment this if you're on Apache >= 2.4:
        #Require all granted
    </Directory>
</VirtualHost>

另外,如果我打开 uri 我有:

内部服务器错误

服务器遇到内部错误或配置错误,无法完成您的请求。

请联系服务器管理员,[未提供地址] 并告知他们错误发生的时间,以及您可能所做的任何可能导致错误的事情。

服务器错误日志中可能提供有关此错误的更多信息。

Apache/2.2.22 (Debian) 服务器在 146.148.7.236 端口 80

有什么问题?(如果重要的话,我在 Google Developers Console 上使用 Debian)

我在这里也注意到了同样的问题,但我找不到区别。

UPD: 我删除了 apache.conf 末尾的行,其中包含

LoadModule passenger_module

现在我有这个错误:

ruslan@olga-blog:~$ sudo service apache2 restart
Syntax error on line 273 of /etc/apache2/apache2.conf:
Invalid command 'PassengerDefaultRuby', perhaps misspelled or defined by a module not included in the server configuration
Action 'configtest' failed.
The Apache error log may have more information.
 failed!

所以我在 apache 日志的末尾看到 tail -f -n 100 /var/log/apache2/error.log ( Fir 05 - 今天是最新的日志):

[Fri Dec 05 03:00:07 2014] [error] [client 180.153.195.33] Premature end of script headers:
[Fri Dec 05 03:20:20 2014] [error] [client 76.14.162.37] client sent HTTP/1.1 request without hostname (see RFC2616 section 14.23): /tmUnblock.cgi
App 10140 stderr: [ 2014-12-05 03:46:21.5488 10221/0x00000000e1d2f0(Worker 1) utils.rb:84 ]: *** Exception RuntimeError in Rack application object (Missing `secret_key_base` for 'production' environment, set this value in `config/secrets.yml`) (process 10221, thread 0x00000000e1d2f0(Worker 1)):
App 10140 stderr: from /home/ruslan/.rvm/gems/ruby-2.1.5/gems/railties-4.1.8/lib/rails/application.rb:462:in `validate_secret_key_config!'
App 10140 stderr: from /home/ruslan/.rvm/gems/ruby-2.1.5/gems/railties-4.1.8/lib/rails/application.rb:195:in `env_config'
App 10140 stderr: from /home/ruslan/.rvm/gems/ruby-2.1.5/gems/railties-4.1.8/lib/rails/engine.rb:510:in `call'
App 10140 stderr: from /home/ruslan/.rvm/gems/ruby-2.1.5/gems/railties-4.1.8/lib/rails/application.rb:144:in `call'
App 10140 stderr: from /home/ruslan/.rvm/gems/ruby-2.1.5/gems/passenger-4.0.53/lib/phusion_passenger/rack/thread_handler_extension.rb:74:in `process_request'
App 10140 stderr: from /home/ruslan/.rvm/gems/ruby-2.1.5/gems/passenger-4.0.53/lib/phusion_passenger/request_handler/thread_handler.rb:141:in `accept_and_process_next_request'
App 10140 stderr: from /home/ruslan/.rvm/gems/ruby-2.1.5/gems/passenger-4.0.53/lib/phusion_passenger/request_handler/thread_handler.rb:109:in `main_loop'
App 10140 stderr: from /home/ruslan/.rvm/gems/ruby-2.1.5/gems/passenger-4.0.53/lib/phusion_passenger/request_handler.rb:455:in `block (3 levels) in start_threads'
[Fri Dec 05 03:46:21 2014] [error] [client 180.153.196.169] Premature end of script headers:
App 10140 stderr: [ 2014-12-05 04:26:21.9010 10221/0x00000000e1d2f0(Worker 1) utils.rb:84 ]: *** Exception RuntimeError in Rack application object (Missing `secret_key_base` for 'production' environment, set this value in `config/secrets.yml`) (process 10221, thread 0x00000000e1d2f0(Worker 1)):
App 10140 stderr: from /home/ruslan/.rvm/gems/ruby-2.1.5/gems/railties-4.1.8/lib/rails/application.rb:462:in `validate_secret_key_config!'
App 10140 stderr: from /home/ruslan/.rvm/gems/ruby-2.1.5/gems/railties-4.1.8/lib/rails/application.rb:195:in `env_config'
App 10140 stderr: from /home/ruslan/.rvm/gems/ruby-2.1.5/gems/railties-4.1.8/lib/rails/engine.rb:510:in `call'
App 10140 stderr: from /home/ruslan/.rvm/gems/ruby-2.1.5/gems/railties-4.1.8/lib/rails/application.rb:144:in `call'
App 10140 stderr: from /home/ruslan/.rvm/gems/ruby-2.1.5/gems/passenger-4.0.53/lib/phusion_passenger/rack/thread_handler_extension.rb:74:in `process_request'
App 10140 stderr: from /home/ruslan/.rvm/gems/ruby-2.1.5/gems/passenger-4.0.53/lib/phusion_passenger/request_handler/thread_handler.rb:141:in `accept_and_process_next_request'
App 10140 stderr: from /home/ruslan/.rvm/gems/ruby-2.1.5/gems/passenger-4.0.53/lib/phusion_passenger/request_handler/thread_handler.rb:109:in `main_loop'
App 10140 stderr: from /home/ruslan/.rvm/gems/ruby-2.1.5/gems/passenger-4.0.53/lib/phusion_passenger/request_handler.rb:455:in `block (3 levels) in start_threads'
[Fri Dec 05 04:26:21 2014] [error] [client 171.13.14.23] Premature end of script headers:

UPD2: 我将密钥添加到 my_app/config/secrets.yml

删除日志文件并创建它

sudo rm -rf /var/log/apache2/error.log
sudo touch /var/log/apache2/error.log

重新启动 Apache 并再次出现此错误:

ruslan@olga-blog:~/blog$ sudo service apache2 restart
Syntax error on line 273 of /etc/apache2/apache2.conf:
Invalid command 'PassengerDefaultRuby', perhaps misspelled or defined by a module not included in the server configuration
Action 'configtest' failed.
The Apache error log may have more information.
 failed!

并且日志是空的

tail -f -n 100 /var/log/apache2/error.log

UPD3:尝试 :sudo aptitude purge libapache2-mod-passenger
sudo apt-get install ruby​​gems build-essential apache2-prefork-dev libapr1-dev libssl-dev zlib1g-dev
sudo gem install Passenger Passenger
-install-apache2-module
将输出粘贴到apache2.conf 的结尾(上面关于乘客的前几行已删除)

LoadModule passenger_module /home/ruslan/.rvm/gems/ruby-2.1.5/gems/passenger-4.0.53/buildout/apache2/mod$
   <IfModule mod_passenger.c>
     PassengerRoot /home/ruslan/.rvm/gems/ruby-2.1.5/gems/passenger-4.0.53
     PassengerDefaultRuby /home/ruslan/.rvm/gems/ruby-2.1.5/wrappers/ruby
   </IfModule>

再次重新启动apache,并有apache消息

It works!

This is the default web page for this server.

The web server software is running but no content has been added, yet.

为什么?

UPD4

sudo nano /etc/apache2/mods-available/passenger.conf

看空,为什么呢?

UPD5:

apt-get install libapache2-mod-passenger

从 apache.conf 中删除 LoadModule 行重新启动 apache 并且仍然有

ruslan@olga-blog:~/blog$ sudo service apache2 restart

Syntax error on line 273 of /etc/apache2/apache2.conf:
Invalid command 'PassengerDefaultRuby', perhaps misspelled or defined by a module not included in the server configuration
Action 'configtest' failed.
The Apache error log may have more information.
 failed!

UPD6:命令 sudo Passenger-status 显示:

Version : 4.0.53
Date    : Fri Dec 05 10:34:32 +0000 2014
Instance: 1021
----------- General information -----------
Max pool size : 6
Processes     : 0
Requests in top-level queue : 0

----------- Application groups -----------
ruslan@olga-blog:~$ apachectl -t -D DUMP_MODULES|grep -i passenger
-bash: apachectl: command not found
ruslan@olga-blog:~$ apachectl configtest
-bash: apachectl: command not found
4

2 回答 2

3

我再次重新安装(仅通过 ruby​​gems 乘客),它工作正常。所以,这是我的“如何安装乘客 + apache + ruby​​”:

  1. 安装阿帕奇:

    sudo apt-get 安装 apache2

  2. 安装 rvm

    \curl -sSL https://get.rvm.io | bash -s 稳定

  3. 通过 ruby​​gems 安装乘客:

    宝石安装乘客

  4. 运行 Phusion 乘客安装程序

    乘客安装 apache2 模块

  5. 像这样创建你的机架应用程序

    在乘客文档示例中

  6. 将 VirtualHost 块添加到 /etc/apache2/sites-enabled/rack_app

  7. 使用PassengerRoot、PassengerDefaultRuby 创建/etc/apache2/mods-enabled/passenger.conf

  8. 使用 LoadModule 块创建 /etc/apache2/mods-enabled/passenger.load

    sudo a2ensite rack_app sudo a2enmod 乘客 sudo service apache2 restart

玩得开心!

有关更多详细信息,请参阅 /etc/apache2/apache2.conf 中的注释和Passenger Apache Docs

于 2014-12-05T15:22:34.217 回答
1

我将对此进行猜测,我认为问题可能在这里:

LoadModule passenger_module /home/ruslan/.rvm/gems/r$
<IfModule mod_passenger.c>
    PassengerRoot /home/ruslan/.rvm/gems/ruby-2.1.5/gem$
    PassengerDefaultRuby /home/ruslan/.rvm/gems/ruby-2.$
</IfModule>

在我的/etc/apache2/httpd.conf我有:

LoadModule passenger_module /Users/martin/.rbenv/versions/1.8.7-p374/lib/ruby/gems/1.8/gems/passenger-4.0.21/buildout/apache2/mod_passenger.so
PassengerRoot /Users/martin/.rbenv/versions/1.8.7-p374/lib/ruby/gems/1.8/gems/passenger-4.0.21
PassengerDefaultRuby /Users/martin/.rbenv/versions/1.8.7-p374/bin/ruby

你的$行可能是因为你的终端窗口不够宽,所以它让你知道文本已被截断(所以你可能有正确的设置但没有正确复制它们 - 调整终端窗口大小或向右滚动以检查) 或者当您运行 apache 乘客安装程序并复制截断的文本而不是整行时就是这样,我建议重新运行 apache mod 安装程序并确保正确捕获输出并尝试。

希望是这样,然后这是一个简单的修复。

更新

DocumentRoot "/Users/martin/Desktop/app_name/public"
<Directory "/Users/martin/Desktop/app_name/public">
    RailsEnv development
    Options -MultiViews
    AllowOverride all
    Allow from all
</Directory>

如果是这种情况,您可能需要使用production而不是开发,但是我在您发布的配置中的任何地方都看不到该RailsEnv选项,但我认为您的问题将是一些愚蠢的事情,就像您只缺少一两件事一样.

一些可能有助于调试的命令:

apachectl configtest
cat /var/log/apache2/error_log

sudo passenger-status
apachectl -t -D DUMP_MODULES|grep -i passenger
于 2014-12-05T09:45:15.967 回答