Sunday, April 28, 2024
 Popular · Latest · Hot · Upcoming
17
rated 0 times [  17] [ 0]  / answers: 1 / hits: 58361  / 3 Years ago, fri, september 24, 2021, 1:25:19

Recently upgraded my system from Karmic to Lucid. This involved Apache and PHP being updated I believe.



Now my server is unable to handle PHP files, any navigation to them is triggering downloading rather than parsing.



The PHP module is still loaded in Apache mods-enabled and I have
AddType application/x-httpd-php .php in my httpd.conf.



There are no meaningful messages in Apache access or error logs so I am stumped.



Any help would be appreciated. Thanks.


More From » 10.04

 Answers
6

/var/log/apache2/error.log should show a line like the below if PHP was succesfully loaded:




[Tue Aug 30 12:53:36 2011] [notice] Apache/2.2.14 (Ubuntu) PHP/5.3.2-1ubuntu4.9 with Suhosin-Patch configured -- resuming normal operations




Pay attention to the date, if it's something from 2009, you've misconfigured something.



AddType is useless, you need to use:



<FilesMatch ".php$">
SetHandler application/x-httpd-php
</FilesMatch>


See also the installation instructions on php.net for Apache 2.x.



You should not have a need to add that manually, the package libapache2-mod-php5 installs /etc/apache2/mods-available/php5.conf containing:



<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>


Since it's a conffile, it's possible that it's not installed with the upgrade. To fix that purge it and then install it again:



sudo apt-get purge libapache2-mod-php5
sudo apt-get install libapache2-mod-php5


To enable PHP, you have to run:



sudo a2enmod php5


Restart the webserver after:



sudo /etc/init.d/apache2 restart


Other things to do:




  • check for conflicting settings in /etc/apache2.

  • have you built Apache from source?

  • Run sudo apache2ctl configtest to check your configuration for syntax errors

  • Open http://localhost/server-info to check the loaded configuration and modules. The status module must be loaded for that. If you're running a remote server, you need to add yourself to the Allow from list in /etc/apache2/mods-enabled/status.conf and restart the server afterwards


[#43680] Saturday, September 25, 2021, 3 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
ampust

Total Points: 133
Total Questions: 109
Total Answers: 111

Location: Reunion
Member since Fri, Jul 22, 2022
2 Years ago
;