
그렇군요. 좀 이상하네요.
따라서 Apache에 대한 나의 경험의 대부분은 Ubuntu 서버 설치에 관한 것입니다. 그러나 내 서버의 하드 드라이브에 치명적인 오류가 발생한 후(고맙게도 모든 데이터를 복구했습니다) 최신 Fedora 서버로 전환할 기회를 얻었습니다. 여기에는 몇 가지 이유가 있었지만 가장 큰 이유는 Ubuntu Server 설치 프로그램의 문제였습니다. 특히 무선 키보드를 인식할 수 없고 마지막 유선 키보드가 파손되었습니다.
어쨌든 httpd(apache), php, postgresql, php-pgsql을 설치했습니다. 그런 다음 이전 사이트 페이지를 모두 새 웹 디렉토리(/var/www/html/)로 옮겼습니다. 그랬더니 500에러가 떴습니다.
나는 처음부터 시작하기로 종달새를 결정했습니다. 내 웹페이지를 옆으로(/var/www/html2/) 이동하고 테스트할 작은 페이지를 만들었습니다. 기본 HTML만 있고, 화려함도 없고, PHP도 없고, 기본만 있습니다.
<html>
<head>
<title>HOME!!!</title>
</head>
<body>
<h1>THIS WORKS!!!</h1>
</body>
</html>
문제없이 로드되었습니다.
그런 다음 모든 페이지를 기본 폴더로 다시 옮겼습니다(현재 .htaccess 제외). 방금 만든 페이지는 여전히 잘 작동했습니다. 문제가 PHP에 있다고 의심되어 맨 아래에 약간의 PHP 코드를 추가했습니다.
echo 'hello';
잘 작동했습니다.
여기가 이상해집니다. 나는 내 사이트의 이전 footer.php를 이 작은 테스트 페이지에 포함시키려고 시도했는데, 여기서 문제가 시작되었습니다. 바닥글이 로드되지 않습니다.
<?php include 'footer.php'; ?>
페이지의 나머지 부분은 로드되지만 바닥글은 로드되지 않습니다. 그런 다음 종달새에 바닥글 파일의 모든 내용을 footer2.php라는 새 파일에 복사하고 대신 footer2.php를 참조하도록 테스트 페이지를 변경했는데 전혀 문제 없이 로드되었습니다.
그래서 마침내 뭔가 문제가 있다고 생각하여 footer2.php와 일치하도록 footer.php의 권한을 변경했습니다. 그리고 여전히 로드되지 않습니다.
어떤 이유로 footer.php는 로드되지 않지만 footer2.php는 로드됩니다.
그렇다면 차이점은 무엇입니까!?
이 파일들은 정확히 동일합니다! 증거는 다음과 같습니다.
[blackwidower@Twilight html]$ md5sum footer*
257cbd773ed765deb5ad0015852cdf20 footer2.php
257cbd773ed765deb5ad0015852cdf20 footer.php
[blackwidower@Twilight html]$ ls -l footer*
-rw-rw-r--. 1 blackwidower blackwidower 1271 Feb 1 00:08 footer2.php
-rw-rw-r--. 1 blackwidower blackwidower 1271 Feb 1 00:08 footer.php
그러나 하나는 로드되고 다른 하나는 로드되지 않습니다.
이러한 파일을 분리할 수 있는 추가 데이터를 찾기 위해 제가 할 수 있는 일이 있습니까?
참고로 Apache error_log는 다음과 같습니다.
[Mon Feb 01 00:14:15.160242 2016] [core:notice] [pid 1800] SELinux policy enabled; httpd running as context system_u:system_r:httpd_t:s0
[Mon Feb 01 00:14:15.161310 2016] [suexec:notice] [pid 1800] AH01232: suEXEC mechanism enabled (wrapper: /usr/sbin/suexec)
AH00558: httpd: Could not reliably determine the server's fully qualified domain name, using 192.168.7.2. Set the 'ServerName' directive globally to suppress this message
[Mon Feb 01 00:14:15.192180 2016] [auth_digest:notice] [pid 1800] AH01757: generating secret for digest authentication ...
[Mon Feb 01 00:14:15.192361 2016] [http2:warn] [pid 1800] AH02951: mod_ssl does not seem to be enabled
[Mon Feb 01 00:14:15.193015 2016] [lbmethod_heartbeat:notice] [pid 1800] AH02282: No slotmem from mod_heartmonitor
[Mon Feb 01 00:14:15.218713 2016] [mpm_prefork:notice] [pid 1800] AH00163: Apache/2.4.18 (Fedora) PHP/5.6.17 configured -- resuming normal operations
[Mon Feb 01 00:14:15.218762 2016] [core:notice] [pid 1800] AH00094: Command line: '/usr/sbin/httpd -D FOREGROUND'
[Mon Feb 01 00:14:43.969957 2016] [:error] [pid 1801] [client 192.168.7.7:49878] PHP Fatal error: Call to undefined function displayCopyrightInfo() in /var/www/html/footer2.php on line 13
[Mon Feb 01 00:14:44.086110 2016] [core:error] [pid 1802] (13)Permission denied: [client 192.168.7.7:49880] AH00035: access to /images/cc-by-nc-nd-88x31.png denied (filesystem path '/var/www/html/images/cc-by-nc-nd-88x31.png') because search permissions are missing on a component of the path, referer: http://192.168.7.2/index2.php
[Mon Feb 01 00:14:44.087064 2016] [core:error] [pid 1804] (13)Permission denied: [client 192.168.7.7:49882] AH00035: access to /images/valid-xhtml10-blue.png denied (filesystem path '/var/www/html/images/valid-xhtml10-blue.png') because search permissions are missing on a component of the path, referer: http://192.168.7.2/index2.php
[Mon Feb 01 00:14:44.087737 2016] [core:error] [pid 1806] (13)Permission denied: [client 192.168.7.7:49884] AH00035: access to /images/vcss-blue.png denied (filesystem path '/var/www/html/images/vcss-blue.png') because search permissions are missing on a component of the path, referer: http://192.168.7.2/index2.php
[Mon Feb 01 00:15:47.538488 2016] [:error] [pid 1808] [client 192.168.7.7:49890] PHP Warning: include(footer.php): failed to open stream: Permission denied in /var/www/html/index2.php on line 7
[Mon Feb 01 00:15:47.538534 2016] [:error] [pid 1808] [client 192.168.7.7:49890] PHP Warning: include(): Failed opening 'footer.php' for inclusion (include_path='.:/usr/share/pear:/usr/share/php') in /var/www/html/index2.php on line 7
편집하다:
한 사람의 조언에 따라. ls -Z를 실행했습니다. 내가 찾은 내용은 다음과 같습니다.
unconfined_u:object_r:httpd_sys_content_t:s0 /var/www/html/footer2.php
system_u:object_r:fusefs_t:s0 /var/www/html/footer.php
그래서 차별점을 찾았습니다. 질문은 다음과 같습니다. 이는 무엇을 의미하며 어떻게 수정합니까?
답변1
그래서 차별점을 찾았습니다. 질문은 다음과 같습니다. 이는 무엇을 의미하며 어떻게 수정합니까?
@Dirk 사용자가 지적한 내용을 확장하면 SELinux는 시스템 보안을 강화하기 위해 "컨텍스트"에 의존하는 시스템입니다. 컨텍스트는 특정 파일이나 디렉토리에서 수행할 수 있는 작업 종류 또는 파일의 용도를 설명합니다. . 이 경우 에는 footer2.php
의 컨텍스트가 있으므로 httpd_sys_content_t
파일을 "에 사용할 수 있음을 의미합니다.http 목적", 당신이 해야 할 일은 footer.php
SELinux 보안 시스템을 통해 액세스할 수 있도록 동일한 컨텍스트 레이블을 추가하거나 상위 디렉토리에서 컨텍스트를 복원하는 것입니다(대부분의 시스템에서 기본적으로 해당 /var/www
위치 의 파일은 '에 대한 라벨http 목적"). 이에 대한 대안은 SELinux를 완전히 비활성화하는 것이지만 이는 좋은 방법이 아닙니다.
그래서,
파일 에 컨텍스트 레이블을 (영구적으로) 설정하려면 다음을 수행하십시오 footer.php
.
semanage fcontext -a -t httpd_sys_content_t /var/www/html/footer.php
restorecon /var/www/html/footer.php
상위 디렉터리(및 모든 콘텐츠)에서도 동일한 작업을 수행할 수 있습니다.
semanage fcontext -a -t httpd_sys_content_t "/var/www/html(/.*)?"
restorecon -R "/var/www/html(/.*)?"
자세한 내용은 다음에서 확인할 수 있습니다.보안이 강화된 Linux를 위한 Red Hat 고객 포털.