
Windows 2012 서버에서 Centos7 웹 서버로 NFS 공유를 마운트했습니다.
내 웹 서버가 NFS 공유에서 파일을 생성하고 읽을 수 있도록 하려고 합니다. 이전에 Windows 2008 및 Centos6에서 비슷한 솔루션이 있었지만 서버를 업그레이드한 후 어려움을 겪고 있습니다.
UID 및 GID는 W2012 NFS 옵션에 설정되어 있으며 정확합니다.
[root@centos external]# ll
drwxrwxrwx 2 apache www-data 4096 Sep 17 16:15 NFSShare
[root@centos external]# df -h
windowsserver:/NFSShare 50G 19G 31G 38% /var/www/external/NFSShare
[root@centos external]# getfacl NFSShare/
# file: NFSShare/
# owner: apache
# group: www-data
user::rwx
group::rwx
other::rwx
NFS 공유 및 해당 권한은 루트 사용자와 함께 작동합니다.
[root@centos NFSShare]# touch test.txt
[root@centos NFSShare]# ll
total 1
-rwxrwxrwx 1 apache www-data 8 Sep 17 16:15 test2.txt
-rw-r--r-- 1 apache www-data 0 Sep 24 11:10 test.txt
하지만 PHP를 사용하여 웹사이트에서 읽기 또는 쓰기를 시도하면 권한이 거부됩니다.
PHP 코드(폴더 생성 및 파일 읽기 시도):
// Try create a folder
mkdir('/var/www/external/NFSShare/123');
// Try to read from file
$file = '/var/www/external/NFSShare/test2.txt';
$homepage = file_get_contents($file);
echo $homepage;
PHP 오류 로그:
[root@centos external]# tail /var/log/httpd/website-error_log
[Thu Sep 24 10:21:03.632156 2015] [:error] [pid 15286] [client 172.27.xxx.xxx:56198] PHP Warning: mkdir(): Permission denied in /var/www/website/modules/users/view/admin/test.php on line 6
[Thu Sep 24 10:21:03.645438 2015] [:error] [pid 15286] [client 172.27.xxx.xxx:56198] PHP Warning: file_get_contents(/var/www/external/NFSShare/test2.txt): failed to open stream: Permission denied in /var/www/website/modules/users/view/admin/test.php on line 15
SSH에서 Apache 사용자로 실행하려고 해도 같은 문제가 발생합니다.
[root@centos NFSShare]# su -s /bin/sh apache -c "touch /var/www/external/NFSShare/test.txt"
touch: cannot touch ‘/var/www/external/NFSShare/test.txt’: Permission denied
현재 저는 Windows 측에서 "모든 사람"에게 NTFS 권한을 부여하려고 시도했으며 Centos 서버에서는 CHMOD 0777을 최대한 많이 부여하고 SELinux를 꺼서 이와 관련된 문제를 배제했습니다.
Apache 사용자가 NFS 공유를 읽거나 쓸 수 없는 이유를 아는 사람이 있습니까?
업데이트 #1:
Apache 사용자로 파일을 생성할 때 "tail -f /var/log/audit/audit.log"를 확인했습니다. ex에서 파일을 생성할 때 로그에서 어떤 차이도 볼 수 없습니다. /external 또는 /external/NFSShare에서 NFSShare에 대한 권한이 거부되었습니다.
루트 사용자로 파일을 생성할 때 NFS 요청을 받지만 Apache 사용자로 시도할 때는 아무 것도 받지 않는 "tcpdump -i any dst windowsserver"를 선택했습니다. 따라서 내 Centos 서버가 Windows 서버로 전송되기 전에 요청을 거부하는 것 같습니다.