10

Passengerを使用して、Fedora12でRubyonRailsアプリケーションを実行するサーバーをセットアップ中です。

Passengerをインストールし、規定どおりにセットアップした段階ですが、Apacheを再起動すると次のエラーが発生します。

[Wed Jan 13 15:41:38 2010] [notice] caught SIGTERM, shutting down
[Wed Jan 13 15:41:40 2010] [notice] SELinux policy enabled; httpd running as context unconfined_u:system_r:httpd_t:s0
[Wed Jan 13 15:41:40 2010] [notice] suEXEC mechanism enabled (wrapper: /usr/sbin/suexec)
[Wed Jan 13 15:41:40 2010] [error] *** Passenger could not be initialized because of this error: Cannot create FIFO file /tmp/passenger.25235/.guard: Permission denied (13)
[Wed Jan 13 15:41:40 2010] [notice] Digest: generating secret for digest authentication ...
[Wed Jan 13 15:41:40 2010] [notice] Digest: done
[Wed Jan 13 15:41:40 2010] [error] *** Passenger could not be initialized because of this error: Cannot create FIFO file /tmp/passenger.25235/.guard: Permission denied (13)
[Wed Jan 13 15:41:40 2010] [error] python_init: Python version mismatch, expected '2.6', found '2.6.2'.
[Wed Jan 13 15:41:40 2010] [error] python_init: Python executable found '/usr/bin/python'.
[Wed Jan 13 15:41:40 2010] [error] python_init: Python path being used '/usr/lib/python26.zip:/usr/lib/python2.6/:/usr/lib/python2.6/plat-linux2:/usr/lib/python2.6/lib-tk:/usr/lib/python2.6/lib-old:/usr/lib/python2.6/lib-dynload'.
[Wed Jan 13 15:41:40 2010] [notice] mod_python: Creating 4 session mutexes based on 256 max processes and 0 max threads.
[Wed Jan 13 15:41:40 2010] [notice] mod_python: using mutex_directory /tmp 
[Wed Jan 13 15:41:40 2010] [notice] Apache/2.2.14 (Unix) DAV/2 Phusion_Passenger/2.2.9 PHP/5.3.0 mod_python/3.3.1 Python/2.6.2 mod_ssl/2.2.14 OpenSSL/1.0.0-fips-beta3 mod_perl/2.0.4 Perl/v5.10.0 configured -- resuming normal operations

ご覧のとおり、Passengerが初期化しようとしているときに権限の問題があります。

[Wed Jan 13 15:41:40 2010] [error] *** Passenger could not be initialized because of this error: Cannot create FIFO file /tmp/passenger.25235/.guard: Permission denied (13)

Apacheが起動すると、/tmpにファイルが作成されます。

d-ws--x--x. 2 root  root  4096 2010-01-13 16:04 passenger.26117

代わりに、で直接mongrelmongrel_rails start -e productionを起動してアプリを実行すると、次のように表示されます。

ActiveRecord::StatementInvalid (Mysql::Error: Can't create/write to file '/tmp/#sql_5d3_0.MYI' (Errcode: 13): SHOW FIELDS FROM `users`):

この場合も、エラーは/tmpディレクトリのアクセス許可の問題を示しています。

私は解決策が何であるかについて途方に暮れています。それが単にディレクトリ権限に関連しているのか、FedoraのSELinuxセキュリティに関連しているのかはわかりません。

どんな助けでもいただければ幸いです。ありがとう。

4

5 に答える 5

13

私はフレッドと同じことをしましたが、一度に1つのエラーを実行する代わりに次のことを行いました。

  1. 実行して許容モードに入るsetenforce 0
  2. apacheを再起動し、サイトにアクセスして、通常どおりしばらく使用します
  3. 走るgrep httpd /var/log/audit/audit.log | audit2allow -M passenger
  4. semodule -i passenger.pp
  5. 実行して強制モードに戻りますsetenforce 1
  6. apacheを再起動して、サイトをテストします。うまくいけば、すべてが以前と同じように機能するはずです。

これは基本的にCentosSELinuxヘルプの手順の特定の例であることに注意してください-それをチェックしてください。

于 2010-03-12T00:05:25.923 に答える
3

CentOS 5.4でも同じ問題が発生し、SELinuxがPassengerの邪魔になります。

PassengerTempDirを/var/ run / passengerに設定すると、/tmpの代わりに新しいディレクトリで同じアクセス許可エラーが発生します。

[Mon Feb 22 11:42:40 2010] [error] *** Passenger could not be initialized because of this error: Cannot create directory '/var/run/passenger/passenger.3686'

次に、/ var / run/passengerのセキュリティコンテキストを変更してこのエラーを回避できます。

chcon -R -h -t httpd_sys_content_t /var/run/passenger/

...これにより、Passengerは一時ディレクトリを作成できますが、そのディレクトリ内のファイルは作成できません。

[Mon Feb 22 12:07:06 2010] [error] *** Passenger could not be initialized because of this error: Cannot create FIFO file /var/run/passenger/passenger.3686/.guard: Permission denied (13)

奇妙なことに、再帰的なchconを再度実行しても、このエラーは発生せず、この時点で死に絶えず、SELinuxの知識が曖昧になります。

Phusion Passengerガイドセクション6.3.5および6.3.7にはいくつかの有用な考えがありますが、問題を完全に解決しているようには見えません。

于 2010-02-22T17:20:20.993 に答える
3

httpd_sys_content_t権限以上のものが必要です。私は物事を始めるために次のテクニックを使います:

  • 監査ログのテールを開始します。tail -f /var/log/audit/audit.log
  • apacheをリロードします:apachectl restart
  • / tmp/directoryに移動します。cd /tmp
  • 1行だけ追加する場合は、次のコマンドを使用します。tail -1 /var/log/audit/audit.log | audit2allow -M httpdfifo
  • 「httpdfifo」という名前は、観察されたエラーの種類を反映するために選択された名前にすぎないことに注意してください。
  • これにより、「httpdfifo.pp」という名前のファイルが作成されます。コマンドを発行する必要があった後、apacheがFIFOを作成できるようにするには:semodule -i httpdfifo.pp
  • すべての監査エラーが解決されるまでこれを続けます(Centos 5.4を実行している私のシステムでは4種類の権限が必要でした)
于 2010-03-10T14:33:19.020 に答える
2

開始する前に実行setenforce 0すると、SELinuxかどうかをテストできます。setenforce 1後で実行することを忘れないでください。

于 2010-01-13T05:20:16.147 に答える
0

DanSketcherとFredApplemanが提案したことを試しました。つまり、次のことを繰り返します。

yum install setroubleshoot
echo > /var/log/audit/audit.log # clear irrelevant errors
cd ~
service httpd restart # try booting passenger -- audit.log now shows the relevant permission errors
tail -f /var/log/httpd/error_log # check that passenger is still failing due to permission errors
sealert -a /var/log/audit/audit.log > selinux-diag.txt # translate the permission errors
# read and check that you are happy with selinux-diag.txt 
# and either follow its specific advice, or if it just wants you to grep into audit2allow, then:
cat /var/log/audit/audit.log | audit2allow -M mypol  # grant everything just denied
semodule -i mypol.p # commit new permissions

しかし、これを5〜6回行った後も、新しいエラーが発生し続け、「audit2allow」で許可しようとした後も同じエラーが発生しました

結局、私はSELinuxをオフにしました。

echo 0 >/selinux/enforce
于 2012-09-20T17:40:36.240 に答える