I have a server with suPHP, Apache2 and PHP5.4.

I noticed that a document index.html will execute PHP code, while test.html will not execute PHP code. Of course I do not want that PHP code is executed inside a index.html file.

I do not know where I should look to find the problem. I didn't find a spot in my configuration where I assign the php-handler to some non-*.php-files.

Here is my mods-available/suphp.conf

<IfModule mod_suphp.c>
        <FilesMatch "\.ph(p3?|tml)$">
                SetHandler application/x-httpd-suphp
        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
        AddType application/x-httpd-php-source .phps
        suPHP_AddHandler application/x-httpd-php-source
#       AddHandler application/x-httpd-php-source

        <Directory />
                suPHP_Engine on

    # 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>

Here is my mods-available/php5.conf

<IfModule mod_php5.c>
    <FilesMatch "\.ph(p3?|tml)$">
        SetHandler application/x-httpd-php
    <FilesMatch "\.phps$">
        SetHandler application/x-httpd-php-source
    # 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>

Check your .htaccess files for the following, as you could have php interpretation turned on there:

AddType application/x-httpd-php .html .htm

If that doesn't work, do a string search. It more than likely is turned on somewhere.

grep -rnw 'web_directory_here' -e "x-httpd-php"

If you find the AddType anywhere, remove it.


UPDATE: Another place to check is your apache MIME types to make sure that html isn't being set to php. Make sure html isn't on either of the lines below.

check in httpd/conf 
application/x-httpd-php phtml php php3 php4 php5 php6
application/x-httpd-php-source  phps
  • Hello. This was the first I did. There is no .htaccess with AddType in the directory-chain. – Daniel Marschall Feb 21 '15 at 18:26
  • @rinntech - See update, check apache mime types. – Brandon Smith Feb 21 '15 at 18:31
  • Also check for DefaultType and ForceType. – sam_pan_mariusz Feb 21 '15 at 18:32
  • And SetHandler and AddHandler. – Cedric Knight Feb 21 '15 at 18:57

You quote your mods-available/php5.conf. Is your mod_php5 enabled, that is do you have a /etc/apache2/mods-enabled/php5.load? If so, try a2dismod php5, as it isn't recommended to have both suphp and mod_php enabled at the same time, at least not globally. Also try a phpinfo() in your index.html to work out which module is handling the request..

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.