0

I tried:

sudo apt-get --purge remove php5-common
sudo apt-get install php5 phpmyadmin
sudo a2enmod php5
adding Servername localhost to /etc/apache2/conf.d/fqdn

Apache isn't recognizing php (instead prompting for download). How to make it correctly execute php?

6
  • 1
    How do you know it is not recognizing PHP? What is the error message?
    – Khaled
    Nov 13, 2010 at 12:53
  • The php info is intended to print / echo things, not prompt for download. Nov 13, 2010 at 12:59
  • You need to isolate the problem further. What's in /etc/apache2/mods-available? The sudo a2enmod command requires as argument. Can you run PHP from the command line? php -r 'echo "hello";'.
    – James L
    Nov 13, 2010 at 13:01
  • There are lots of things in mod-available. I had run sudo a2enmod php5, but wrote it wrong in the question. I can run php from command-line. Nov 13, 2010 at 13:05
  • In mods-available, there are php5.conf, php5.load, php5filter.conf, php5filter.load. Is that what you wanted? Nov 13, 2010 at 13:09

3 Answers 3

1

Missing AddHandler for .php?

0

Make sure you have the following in your configuration somewhere (it can be in the vhost definition or prior to it):
AddHandler php5-script .php

8
  • Either in the main configuration file or an include. Given that you're using Ubuntu, it's likely to be either /etc/apache2/apache2.conf or /etc/apache2/sites-available/somefile.conf
    – James L
    Nov 13, 2010 at 13:33
  • I added AddHandler php5-script .php to httpd.conf, but it still didn't work. Nov 13, 2010 at 13:35
  • I don't think httpd.conf is used by Ubuntu.
    – James L
    Nov 13, 2010 at 13:35
  • I tried the bottom of apache2.conf too, but it didn't work. Nov 13, 2010 at 13:43
  • The bottom of apache2.conf is unlikely to help you. Basically you need to put it before the vhost definition, bearing in mind that the file is read from top to bottom and, as far as I know, Include files are entirely read before the next line. Paste your apache2.conf somewhere (eg. pastie.org) and we can take a look for you.
    – James L
    Nov 13, 2010 at 13:48
0

install LAMP in Kubuntu with:

sudo apt-get install tasksel
sudo tasksel install lamp-server

restart Apache:

sudo /etc/init.d/apache2 restart

create phpinfo.php with:

<?php echo phpinfo(); ?>

place phpinfo.php in /var/www

clear browser cache

visit http://localhost/phpinfo.php

that should show the phpinfo

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .