8
4

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

Apache設定 ファイル権限問題がないのに 403 Permission denied file permissions deny server access の対策

Last updated at Posted at 2019-05-12

SELinux有効かを確認する(Enforcing=有効)

# getenforce
Enforcing

有効の場合は下記のコマンドでhttpdプロセスがファイルにアクセスできるようにする

chcon -R -h -t httpd_sys_content_t /var/www/html

This recursively sets your content directory to the proper context for Apache.

chcon コマンドは、ファイルの SELinux コンテキストを変更します。ただし、chcon コマンドによる変更は、ファイルシステムの再ラベル付けや restorecon コマンドが実行されると維持されません。SELinux ポリシーは、特定のファイルの SELinux コンテキストをユーザーが修正できるかどうかを制御します。chcon を使うと、ユーザーは変更する SELinux コンテキストの一部または全部を提供します。SELinux がアクセスを拒否する一般的な原因は、ファイルタイプが間違っているためです。

httpd_sys_content_t ラベルが、httpdプロセスがこのファイルにアクセスできることを表す.

ちなみに

SELinuxって?

  • Linuxのセキュリティを強化する仕組みで、カーネルに追加される
  • 米国国家安全保障局 (National Security Agency) が開発した

SELinuxのセキュリティの仕組み

  • プロセスとファイルの全てに、タイプでラベル付けを行う。
  • タイプはプロセスのドメインを定義しており、プロセスはドメイン毎に互いに分離している。
  • SELinuxポリシールールは、タイプに基づきプロセスがファイルと対話する方法とプロセス同士が対話する方法を定義する。
  • プロセスは、アクセスを許可するポリシールールが定義されている場合のみ、当該ファイル又はプロセスへアクセスできる。
8
4
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
8
4

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?