何らかの理由でnginxのルートを変更できない

何らかの理由でnginxのルートを変更できない

何らかの理由でルートを変更できません。 のデフォルトルートと同じ権限があり/usr/share/nginx/html755他のフォルダ内のすべてのファイルとフォルダに対して再帰権限も持っています。ユーザーとグループをルートとnginxに変更して違いがあるかどうかを確認してみましたが、違いはありませんでした。403禁止します

基本的にこのフォルダを作りました

$ mkdir -p /srv/www/test.com/public_html

$ vi /srv/www/test.com/public_html/index.html

$ vi /srv/www/test.com/public_html/test.php

$ chmod -R 755 /srv/www/test.com/public_html

ユーザーとグループをnginxに変更しようとしました

$ chown -R nginx:nginx /srv/www

メインの設定ファイルを設定しました

$ vi /etc/nginx/nginx.conf

私の設定はこのようになっています。includesはコメントアウトされています

user  nginx;
worker_processes  1;
error_log  /var/log/nginx/error.log;   
pid        /run/nginx.pid;

events {
    worker_connections  1024;
}

http {
    include       /etc/nginx/mime.types;
    default_type  application/octet-stream;

    log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
                      '$status $body_bytes_sent "$http_referer" '
                      '"$http_user_agent" "$http_x_forwarded_for"';

    access_log  /var/log/nginx/access.log  main;
    sendfile        on;
    keepalive_timeout  65;
    index index.php index.html index.htm;

    server {

        listen       80;
        server_name  _;
        root /srv/www/test.com/public_html;
        # root  /usr/share/nginx/html;

        location / {
                autoindex on;
        }

        error_page  404 /404.html;

        location = /40x.html { }


        error_page   500 502 503 504  /50x.html;

        location = /50x.html { }

        location ~ \.php$ {
                try_files $uri =404;
                fastcgi_pass   unix:/var/run/php-fpm/www.sock;
                fastcgi_index  index.php;
                fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
                include        fastcgi_params;
        }

    }

}       

コメント アウトされているデフォルトのルート フォルダーではすべて動作しますが、ルートを変更すると 403 禁止になります。ユーザーやファイルの権限を変更するなど、できることはすべて試したと思います。php-fpm には、ユーザーとグループとして nginx があります。また、main.conf ファイルでは、ユーザーが nginx に設定されています。nginx の構成にはこの 1 つのファイルのみを使用し、include をコメント アウトしています。

何をすればいいのか全く分かりません。もう何時間も困っています。どなたか助けていただけると嬉しいです

答え1

明確にするために、私はコメントを回答として投稿します。これはSELinuxによって引き起こされ、ポリシーモードをpermissiveに設定することがsemanage permissive -a httpd_t1つです。素早く汚い" 解決。

クリーンな解決策は、SELinux コンテキストを設定しchcon -Rt httpd_sys_content_t /srv/www/test.com、潜在的な新しい SELinux 苦情があるかどうかを確認することです (構成ファイルで次に何を設定するかによって異なります)。

関連情報