3

背景私は最近、rootアクセス権を持つホスト上にphpベースのサイトをセットアップしました。linode.comのガイドに基づいてランプのセットアップをインストールしましたが、phpファイルのアクセス許可、ディレクトリのアクセス許可、およびどのユーザーがどのグループのどのプロセスを実行する必要があるのか​​疑問に思っています。

特に、「ACL、所有権、および製品IDに関して標準のphp Webサイトをどのように構成する必要があるか」という質問に対する回答が欲しいのですが、

現在、ディレクトリリストは次を返します。

-rw-r--r--  1 root    root   70 Nov  8 17:17 index.php

つまりroot、所有者、rootグループ、モード644/ uw & ar。([編集]ファイルはrootを使用して作成するべきではないため、これは本来あるべき姿ではありません-この質問の理由の一部です)

実行ps -auxww中ApacheWebサーバーはと呼ばれるユーザーとしてwww-data実行されているので、phpは同じユーザーとして実行されると推測できます(おそらく、同じユーザーを継承する子プロセスです)。

chmod 640すべてのファイルを設定し、自分自身(user bob)を所有者として設定し、ユーザーproductionIDsを含むというグループを作成www-dataし、ファイルのグループをに設定するのは間違っているproductionIDsでしょうか?

私には、これは最小特権の観点からより安全であるように思われます。私とWebサーバー以外に誰がいますか?ファイルを書き込む必要があるのは私だけであり、Webサーバーは読み取るだけです。他の誰も何もする必要はありません。

私のセットアップでは、複数の開発者がいる場合は処理されませんが、この場合がどのようになるかはわかりません。

640それで、所有者私、グループWebサーバーグループにリスクはありますか?もしそうなら、対応するディレクトリ750も安全ですか?

そうでない場合は、なぜもっと多くの人がこの構成を使用しないのですか?

[更新]試して理論を見て、それは動作します。そのため、質問には「この構成では何が許可されないのか/この構成の欠点は何ですか」という側面が含まれます。

4

1 に答える 1

2

First, your files should definitely not be owned by root:root. Start with a username and generic group for all ownership.

While it is initially true that the web server user will only need read/execute access to your files there are certainly cases where that user might need write access to a specific folder for uploads or application logs, etc.

So our typical setup for a PHP application is 644 on the files (640 is fine, too) and 755 for the folders (750 will also work). Note we leave the files readable by everyone for a couple of reasons. First, it allows other users to audit code on a server without having the ability to modify it. Second, we only have developer users on the production hosting server so anyone with an account already has the trust level to see all the code. That situation might vary in another setting.

Regarding your question of using the web server group as the group owner, we usually do not do that. While you could certainly use that group, we like to leave all the system-installed groups alone and create a specific group for the application files. Then we just add the web server user to the new group.

于 2012-11-10T09:56:54.097 に答える