
Tengo un servidor con suPHP, Apache2 y PHP5.4.
Noté que un documento index.html ejecutará código PHP, mientras que test.html no ejecutará código PHP. Por supuesto, no quiero que el código PHP se ejecute dentro de un archivo index.html.
No sé dónde debería buscar para encontrar el problema. No encontré un lugar en mi configuración donde asigne el controlador php a algunos archivos que no sean *.php.
Aquí está mi 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>
Aquí está mi 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>
Respuesta1
Verifique sus archivos .htaccess para ver lo siguiente, ya que podría tener activada la interpretación de php allí:
AddType application/x-httpd-php .html .htm
Si eso no funciona, haga una búsqueda de cadenas. Lo más probable es que esté encendido en alguna parte.
grep -rnw 'web_directory_here' -e "x-httpd-php"
Si encuentra AddType en algún lugar, elimínelo.
==
ACTUALIZACIÓN: Otro lugar para verificar son los tipos MIME de Apache para asegurarse de que html no esté configurado en php. Asegúrese de que html no esté en ninguna de las líneas siguientes.
check in httpd/conf
application/x-httpd-php phtml php php3 php4 php5 php6
application/x-httpd-php-source phps
Respuesta2
Citas tus mods-available/php5.conf. ¿Está habilitado su mod_php5, es decir, tiene un /etc/apache2/mods-enabled/php5.load? Si es así, inténtalo a2dismod php5
, ya que no se recomienda tener habilitados tanto suphp como mod_php al mismo tiempo, al menos no globalmente. Pruebe también un phpinfo() en su index.html para determinar qué módulo está manejando la solicitud.