LoginSignup
7
3

More than 5 years have passed since last update.

nginxとphp-fpmでphpがAccess deniedで表示されない

Last updated at Posted at 2015-10-28

Apacheからコンテンツを順次nginxサイトへ移植中に発生した出来事の対処メモ
検索で引っかかって誰かの役に立てば何より。

環境は前と一緒

概要

myserver.com/othersite/ は表示されているところに
同じドキュメントルートにフラットにコンテンツをコピーした
myserver.com/mysite/ 以下が表示されずAccess deniedのつれない表示

nginxのエラーログ

yyyy/mm/dd hh:mm:ss [error] xxxxx#xxxxx: *1 FastCGI sent in stderr: "PHP message: PHP Warning:  Unknown: failed to open stream: Permission denied in Unknown on line 0
Unable to open primary script: /usr/share/nginx/html/mysite/index.html (Permission denied)" while reading response header from upstream, client: 192.168.xx.xxx, server: localhost, request: "GET /mysite/ HTTP/1.1", upstream: "fastcgi://unix:/var/run/php-fpm/php-fpm.sock:", host: "myserver.com"

いろいろ調べましたが犯人はSELinuxでした

対処

sudo setenforce o

再起動時にまた悪さしないように設定ファイルも編集しておく

/etc/selinux/config

SELINUX=disabled
7
3
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
7
3