Ubuntu – PHP is not executed on apache2

apache-2.2PHPphp5Ubuntu

I run apache (Apache/2.2.14 Ubuntu). PHP is not executed. I noticed that the line

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

was missing from /etc/apache2/apache.conf
I tried adding the line on several places in the .conf file. Nothing worked.

I tried chown www-data /var/www/ and chmod 777 /var/www (i am new to linux)

I read that you might have to add

AddType application/x-httpd-php .php

to httpd.conf. This also yields no result

I also tried executing this simple code (placed in /var/www/)

<?php
  phpinfo();
?>

Firefox prompts me to save the file instead of executing it.

And yes, I did restart apache every time I made changes.

I am stuck.

edit:

ls - l /var/ gives,

.....
.....
drwxrwxrwx  3 www-data www-data 4096 2011-12-05 14:39 www

Since apache runs in this group, the owner should be www-data, right?

the access log gives me:

127.0.0.1 - - [05/Dec/2011:14:39:58 -0500] "GET /info.php HTTP/1.1" 200 327 "-" "Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.2.18) Gecko/20110628 Ubuntu/10.04 (lucid) Firefox/3.6.18"
127.0.0.1 - - [05/Dec/2011:14:45:35 -0500] "GET /info.php HTTP/1.1" 304 187 "-" "Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.2.18) Gecko/20110628 Ubuntu/10.04 (lucid) Firefox/3.6.18"
127.0.0.1 - - [05/Dec/2011:14:46:44 -0500] "GET /info.php HTTP/1.1" 304 187 "-" "Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.2.18) Gecko/20110628 Ubuntu/10.04 (lucid) Firefox/3.6.18"
127.0.0.1 - - [05/Dec/2011:14:53:26 -0500] "GET /info.php HTTP/1.1" 304 187 "-" "Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.2.18) Gecko/20110628 Ubuntu/10.04 (lucid) Firefox/3.6.18"

AND THE ERROR LOG:

[Mon Dec 05 14:25:08 2011] [notice] caught SIGTERM, shutting down
[Mon Dec 05 14:25:09 2011] [notice] Apache/2.2.14 (Ubuntu) configured -- resuming normal operations
[Mon Dec 05 14:27:08 2011] [notice] caught SIGTERM, shutting down
[Mon Dec 05 14:27:09 2011] [notice] Apache/2.2.14 (Ubuntu) configured -- resuming normal operations
[Mon Dec 05 14:35:33 2011] [notice] caught SIGTERM, shutting down
[Mon Dec 05 14:35:34 2011] [notice] Apache/2.2.14 (Ubuntu) configured -- resuming normal operations
[Mon Dec 05 14:35:52 2011] [notice] caught SIGTERM, shutting down
[Mon Dec 05 14:35:53 2011] [notice] Apache/2.2.14 (Ubuntu) configured -- resuming normal operations
[Mon Dec 05 14:45:29 2011] [notice] caught SIGTERM, shutting down
[Mon Dec 05 14:45:30 2011] [notice] Apache/2.2.14 (Ubuntu) configured -- resuming normal operations
[Mon Dec 05 14:46:38 2011] [notice] caught SIGTERM, shutting down
[Mon Dec 05 14:46:39 2011] [notice] Apache/2.2.14 (Ubuntu) configured -- resuming normal operations
[Mon Dec 05 14:54:16 2011] [notice] caught SIGTERM, shutting down
[Mon Dec 05 14:54:17 2011] [notice] Apache/2.2.14 (Ubuntu) configured -- resuming normal operations

Best Answer

Did you actually install PHP? Package libapache2-mod-php5? Normally, you should't need to edit any config files to activate PHP when installing this package.