EDIT: I decided to just wipe out my apache and php installs and start from scratch. Things are working now, no idea why they weren't before. I've probably set up 30 different LAMP-type servers and never run into this before, I guess I'll just chalk this one up to insanity.
Original question is as follows:
PHP files are not being properly executed on my webserver. I have a test file as follows:
<html> <head> <title>Testing PHP</title> </head> <body> <?php phpinfo( ); ?> </body> </html>
Here are my installed PHP and apache packages:
$ dpkg -l | grep php ii libapache2-mod-php5 5.2.6.dfsg.1-3ubuntu4.2 ii php-config 1.10.11-1 ii php-pear 5.2.6.dfsg.1-3ubuntu4.2 ii php5 5.2.6.dfsg.1-3ubuntu4.2 ii php5-cgi 5.2.6.dfsg.1-3ubuntu4.2 ii php5-cli 5.2.6.dfsg.1-3ubuntu4.2 ii php5-common 5.2.6.dfsg.1-3ubuntu4.2 ii php5-mysql 5.2.6.dfsg.1-3ubuntu4.2 $ dpkg -l | grep apache ii apache2-mpm-prefork 2.2.11-2ubuntu2.3 ii apache2-utils 2.2.11-2ubuntu2.3 ii apache2.2-common 2.2.11-2ubuntu2.3 ii libapache2-mod-auth-mysql 4.3.9-11 ii libapache2-mod-php5 5.2.6.dfsg.1-3ubuntu4.2
Here are my php-related config lines:
$ grep -n php /etc/apache2/apache2.conf /etc/apache2/mods-enabled/php5.* /etc/apache2/httpd.conf /etc/apache2/mods-enabled/php5.conf:1: <IfModule mod_php5.c> /etc/apache2/mods-enabled/php5.conf:2: AddType application/x-httpd-php .php .phtml .php3 /etc/apache2/mods-enabled/php5.conf:3: AddType application/x-httpd-php-source .phps /etc/apache2/mods-enabled/php5.load:1: LoadModule php5_module /usr/lib/apache2/modules/libphp5.so
As you can see, the php5 module is loaded. I can confirm this as a2enmod indicates it is already loaded.
Currently, attempting to load a PHP file in a browser simply displays it as raw text.
Curiously, while trying to fix it, I found that if I add a line like "AddType application/x-httpd-php .php .phtml .php3" to the bottom of httpd.conf, then it suddenly starts asking me to download those php files instead. That's weird, considering that such a line is the same as in the php5.conf module file.
Obviously, neither is desired behavior.
Also, yes, apache2 and now even the server itself have been restarted numerous times. Apache has no trouble serving regular HTML pages.