PHP not running scripts, downloading them instead

apache-2.2debianPHP

I know, a very typical problem, but I run out of ideas. Yes, the module is installed:

# aptitude search libapache2-mod-php5
i   libapache2-mod-php5                                                         - server-side, HTML-embedded scripting language (Apache 2 module)                       
p   libapache2-mod-php5filter                                                   - server-side, HTML-embedded scripting language (apache 2 filter module)

and enabled:

# ls -l /etc/apache2/mods-enabled/php*
lrwxrwxrwx 1 root root 27 2011-08-31 13:49 /etc/apache2/mods-enabled/php5.conf -> ../mods-available/php5.conf
lrwxrwxrwx 1 root root 27 2011-08-31 13:49 /etc/apache2/mods-enabled/php5.load -> ../mods-available/php5.load

# cat /etc/apache2/mods-enabled/php5.conf
<IfModule mod_php5.c>
  AddType application/x-httpd-php .php .phtml .php3 .php5
  AddType application/x-httpd-php-source .phps
</IfModule>

# cat /etc/apache2/mods-enabled/php5.load
LoadModule php5_module /usr/lib/apache2/modules/libphp5.so

Apache claims PHP is lodade:

# apache2ctl -t -D DUMP_MODULES
Loaded Modules:
 core_module (static)
 log_config_module (static)
 logio_module (static)
 mpm_prefork_module (static)
 http_module (static)
 so_module (static)
 alias_module (shared)
 auth_basic_module (shared)
 authn_file_module (shared)
 authz_default_module (shared)
 authz_groupfile_module (shared)
 authz_host_module (shared)
 authz_user_module (shared)
 autoindex_module (shared)
 cgi_module (shared)
 deflate_module (shared)
 dir_module (shared)
 env_module (shared)
 mime_module (shared)
 negotiation_module (shared)
 php5_module (shared)
 proxy_module (shared)
 proxy_html_module (shared)
 proxy_http_module (shared)
 rewrite_module (shared)
 setenvif_module (shared)
 status_module (shared)
Syntax OK

There's no .htaccess in the document root and the 404 shows PHP as present:

Apache/2.2.9 (Debian) PHP/5.2.6-1+lenny13 with Suhosin-Patch proxy_html/3.0.0 Server at wiki.example.com Port 80

The logs shows no errors.

Any ideas what else to check?

Best Answer

First, make sure your apache config is loading it, eg:

LoadModule php5_module modules/libphp5.so

Then, make sure Apache knows to interpret .php files, eg

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

EDIT

You mention the error logs contain no errors. What is the status code of the requests to the .php scripts? (200, 500,etc)

In your php.ini file, check the settings for log_errors, display_errors, and error_log. If errors are logging, they will be in the location specified by error_log. I think this the default behavior (logging, not displaying to screen).

If your app needs MySQL, make sure you installed the php5-mysql package too. Same for any other needed module.