
suPHP, Apache2 및 PHP5.4가 설치된 서버가 있습니다.
index.html 문서는 PHP 코드를 실행하지만 test.html은 PHP 코드를 실행하지 않는 것으로 나타났습니다. 물론 나는 PHP 코드가 index.html 파일 내에서 실행되는 것을 원하지 않습니다.
문제를 찾으려면 어디를 봐야 할지 모르겠습니다. 내 구성에서 *.php 파일이 아닌 일부 파일에 php-handler를 할당하는 지점을 찾지 못했습니다.
여기 내 mods-available/suphp.conf가 있습니다.
<IfModule mod_suphp.c>
<FilesMatch "\.ph(p3?|tml)$">
SetHandler application/x-httpd-suphp
</FilesMatch>
suPHP_AddHandler application/x-httpd-suphp
# suPHP_PHPPath /usr/bin/php
<FilesMatch "\.phps$">
SetHandler application/x-httpd-php-source
# Order allow,deny
# Allow from all
</FilesMatch>
AddType application/x-httpd-php-source .phps
suPHP_AddHandler application/x-httpd-php-source
# AddHandler application/x-httpd-php-source
<Directory />
suPHP_Engine on
</Directory>
# By default, disable suPHP for debian packaged web applications as files
# are owned by root and cannot be executed by suPHP because of min_uid.
# Benötigen wir für Nagios3
# <Directory /usr/share>
# suPHP_Engine off
# </Directory>
# # Use a specific php config file (a dir which contains a php.ini file)
# suPHP_ConfigPath /etc/php5/cgi/suphp/
# # Tells mod_suphp NOT to handle requests with the type <mime-type>.
# suPHP_RemoveHandler <mime-type>
</IfModule>
여기 내 mods-available/php5.conf가 있습니다.
<IfModule mod_php5.c>
<FilesMatch "\.ph(p3?|tml)$">
SetHandler application/x-httpd-php
</FilesMatch>
<FilesMatch "\.phps$">
SetHandler application/x-httpd-php-source
</FilesMatch>
# To re-enable php in user directories comment the following lines
# (from <IfModule ...> to </IfModule>.) Do NOT set it to On as it
# prevents .htaccess files from disabling it.
# <IfModule mod_userdir.c>
# <Directory /home/*/public_html>
# php_admin_value engine Off
# </Directory>
# </IfModule>
</IfModule>
답변1
.htaccess 파일에서 PHP 해석을 켤 수 있으므로 다음 사항을 확인하세요.
AddType application/x-httpd-php .html .htm
그래도 작동하지 않으면 문자열 검색을 수행하십시오. 어딘가에 켜져 있을 가능성이 높습니다.
grep -rnw 'web_directory_here' -e "x-httpd-php"
AddType을 어디서나 찾으면 제거하세요.
==
업데이트: 확인해야 할 또 다른 장소는 html이 php로 설정되지 않았는지 확인하기 위해 Apache MIME 유형입니다. html이 아래 줄 중 하나에 있지 않은지 확인하세요.
check in httpd/conf
application/x-httpd-php phtml php php3 php4 php5 php6
application/x-httpd-php-source phps
답변2
mods-available/php5.conf를 인용했습니다. mod_php5가 활성화되어 있습니까? 즉, /etc/apache2/mods-enabled/php5.load가 있습니까? 그렇다면 시도해 보십시오 a2dismod php5
. suphp와 mod_php를 동시에 활성화하는 것은 권장되지 않습니다. 적어도 전역적으로 활성화하는 것은 아닙니다. 또한 index.html에서 phpinfo()를 시도하여 어떤 모듈이 요청을 처리하는지 알아보세요.