Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

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?

share|improve this question
1  
How do you know it is not recognizing PHP? What is the error message? –  Khaled Nov 13 '10 at 12:53
    
The php info is intended to print / echo things, not prompt for download. –  Delirium tremens Nov 13 '10 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 Lawrie Nov 13 '10 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. –  Delirium tremens Nov 13 '10 at 13:05
    
In mods-available, there are php5.conf, php5.load, php5filter.conf, php5filter.load. Is that what you wanted? –  Delirium tremens Nov 13 '10 at 13:09

3 Answers 3

Missing AddHandler for .php?

share|improve this answer

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

share|improve this answer
    
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 Lawrie Nov 13 '10 at 13:33
    
I added AddHandler php5-script .php to httpd.conf, but it still didn't work. –  Delirium tremens Nov 13 '10 at 13:35
    
I don't think httpd.conf is used by Ubuntu. –  James Lawrie Nov 13 '10 at 13:35
    
I tried the bottom of apache2.conf too, but it didn't work. –  Delirium tremens Nov 13 '10 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 Lawrie Nov 13 '10 at 13:48

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

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.