[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: PHP5 scripts not served by apache2 on Squeeze

On 04/01/2012 09:54, Michael Tsang wrote:
On Wednesday, January 04, 2012 05:28 PM, Kristian Lampen wrote:

I have a fresh install of apache2 and php on my server and I can not get php to work, php-scripts are not executed by apache, just the plain script is served to the browser.

The problem looks similar to this one: Can't execute PHP script. But it is unsolved and from 2007 on Lenny, so I opened a new one in hope of help.

I have the following packages installed:


Apache is up and running:

root@server:~# ps ax | grep apache2
12306 pts/0    S+     0:00 grep apache2
24913 ?        Ss     0:01 /usr/sbin/apache2 -k start
25047 ?        S      0:00 /usr/sbin/apache2 -k start
25048 ?        S      0:00 /usr/sbin/apache2 -k start
25049 ?        S      0:00 /usr/sbin/apache2 -k start
25050 ?        S      0:00 /usr/sbin/apache2 -k start
25051 ?        S      0:00 /usr/sbin/apache2 -k start
25183 ?        S      0:00 /usr/sbin/apache2 -k start

The PHP Module is loaded and linked in /etc/apache2/mods-enabled/:

root@server:~# a2enmod php5
Module php5 already enabled

root@server:~# ls -l /etc/apache2/mods-enabled/php*
lrwxrwxrwx 1 root root 27 Jan  3 21:45 /etc/apache2/mods-enabled/php5.conf -> ../mods-available/php5.conf
lrwxrwxrwx 1 root root 27 Jan  3 21:45 /etc/apache2/mods-enabled/php5.load -> ../mods-available/php5.load

root@server:~# apache2ctl -M
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)
 reqtimeout_module (shared)
 setenvif_module (shared)
 status_module (shared)
Syntax OK

Seems to be all correct:

Now I have a PHP Test file:

root@server:~# echo "<?php phpinfo(); ?>" > /var/www/test.php
root@server:~# chmod 755 /var/www/test.php

Now when I try to open it with any web-browser from the network I get the plain PHP-script shown on the screen. The local lynx on the server gives me the option to download the php-file.

root@server:~# lynx --dump http://localhost/test.php
<?php phpinfo(); ?>

Here the logs:

access.log - - [04/Jan/2012:10:18:27 +0100] "GET /test.php HTTP/1.0" 200 284 "-" "Lynx/2.8.8dev.5 libwww-FM/2.14 SSL-MM/1.4.1 GNUTLS/2.8.6"

root@server:~# cat /var/log/apache2/error.log 
[Tue Jan 03 21:44:59 2012] [notice] Apache/2.2.16 (Debian) configured -- resuming normal operations
[Tue Jan 03 21:45:01 2012] [notice] Graceful restart requested, doing restart
[Tue Jan 03 21:45:01 2012] [notice] Apache/2.2.16 (Debian) configured -- resuming normal operations

A simple purge of all related packages and reinstalling changes nothing.

I hope this problem is solved already, but I have not found any solution yet.

What have I or the server done wrong?


What's your content of /etc/apache2/mods-available/php5.{conf,load} ?
Maybe, you have to change php.conf.
I had an same case and I had to uncomment  that the php recognize the php tag.
I mean --->   <?php or <? etc...

Reply to: