
어떤 이유로 루트를 변경할 수 없습니다. 나는 의 기본 루트와 동일한 권한을 갖고 있으며 다른 폴더의 모든 파일과 폴더에 대해서도 재귀적 권한을 /usr/share/nginx/html
갖고 있습니다 . 755
나는 사용자와 그룹을 루트로 변경하고 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
기본 conf 파일을 구성했습니다
$ vi /etc/nginx/nginx.conf
이것이 내 구성의 모습입니다. 포함 항목은 주석 처리되어 있습니다.
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
명확성을 위해 내 의견을 답변으로 게시하고 있습니다. 이는 SELinux로 인해 발생했으며 정책 모드를 허용으로 설정하는 semanage permissive -a httpd_t
것은 "빠르고 더러운" 해결책.
깔끔한 해결책은 SELinux 컨텍스트를 설정 chcon -Rt httpd_sys_content_t /srv/www/test.com
하고 잠재적인 새로운 SELinux 불만 사항이 있는 경우 찾는 것입니다(구성 파일에서 다음에 설정하는 내용에 따라 다름).