PHP不在apache2上执行

我运行apache(Apache / 2.2.14 Ubuntu)。 PHP不执行。 我注意到了这一行

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

从/etc/apache2/apache.conf丢失我试图在.conf文件中的几个地方添加行。 没有工作。

我试过chown www-data /var/www/chmod 777 /var/www (我是linux新手)

我读过,你可能不得不补充

 AddType application/x-httpd-php .php 

到httpd.conf。 这也没有结果

我也尝试执行这个简单的代码(放在/ var / www /)

 <?php phpinfo(); ?> 

Firefox提示我保存文件而不是执行它。

是的,每次我做了改变,我都重新启动了Apache。

我被困住了。

编辑:

ls - l /var/ given,

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

由于apache运行在这个组中,所有者应该是www-data,对吧?

访问日志给我:

 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" 

和错误日志:

 [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 

你真的安装PHP? 包libapache2-mod-php5 ? 通常情况下,安装这个软件包时不需要编辑任何configuration文件来激活PHP。

检查apache的错误日志。 检查在Apacheconfiguration中是否有LoadModule php5_module modules/libphp5.so或类似的。 检查libphp5.so文件是否存在。 检查libphp5.so是由apache用pmap <apache_worker_PID>|grep php加载的。 例如运行:

 ps -edf |grep apache|grep -v root|head -1|awk '{print $2}'|xargs pmap|grep php 

你可以在Ubuntu的apache上启用php:

 sudo a2enmod php5 sudo /etc/init.d/apache2 force-reload 

另见: https : //help.ubuntu.com/community/ApacheMySQLPHP#Installing_PHP_5