On 04/01/2012 09:58, Balint Szigeti wrote:
> On 04/01/2012 09:54, Michael Tsang wrote:
>>
>> On Wednesday, January 04, 2012 05:28 PM, Kristian Lampen wrote:
>>>
>>> Hello,
>>>
>>> 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:
>>>
>>> apache2.2-bin
>>> apache2-mpm-prefork
>>> apache2.2-common
>>> apache2-utils
>>> libapache2-mod-php5
>>> php5-cli
>>> php5-common
>>> php5-suhosin
>>>
>>> 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
>>>
>>> 127.0.0.1 - - [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?
>>>
>>> Thanks
>>>
>> 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...
root@server:~# cat /etc/apache2/mods-available/php5.conf
<IfModule mod_php5.c>
<FilesMatch "\.ph(p3?|tml)$">
SetHandler application/x-httpd-php
</FilesMatch>
<FilesMatch "\.phps$">
SetHandler application/x-httpd-php-source
</FilesMatch>
# To re-enable php in user directories comment the following lines
# (from <IfModule ...> to </IfModule>.) Do NOT set it to On as it
# prevents .htaccess files from disabling it.
<IfModule mod_userdir.c>
<Directory /home/*/public_html>
php_admin_value engine Off
</Directory>
</IfModule>
</IfModule>
root@server:~# cat /etc/apache2/mods-available/php5.load
LoadModule php5_module /usr/lib/apache2/modules/libphp5.so
I can see nothing strange in them?