php5 scripts start the open dialog box instead of running in the browser in ubuntu 7.04

Asked by cybard

When I run a php file containing just <?php phpinfo(); ?> in the browser address bar pointng to localhost, I get a dialog box asking me how I want ot open up the file. This happens with files containing php scripts and not with just the '.php' extension and html.

I can run the file containing php script from the command line and get the phpinfo(); result.

Question information

Language:
English Edit question
Status:
Answered
For:
Ubuntu Edit question
Assignee:
No assignee Edit question
Last query:
Last reply:
Revision history for this message
Mariano Mara (marplatense) said :
#1

Your apache's doesn't recognize php as a valid mime type to execute.
To fix it:
1- you should have a file called apache2.conf @ /etc/apache2/. In it, you should have a part that looks exactly like this:

# Include module configuration:
Include /etc/apache2/mods-enabled/*.load
Include /etc/apache2/mods-enabled/*.conf

2- find the apache2.conf file. Typically it's @ /etc/apache2

3- create a file called php.conf and fill it with this data:

AddType application/x-httpd-php .php .phtml
DirectoryIndex index.php

Save it @ /etc/apache2/mods-enabled/

4- create a file called php.load and fill it with this data:

LoadModule php5_module modules/libphp5.so

Save it @ /etc/apache2/mods-enabled/
IMPORTANT: I'm using my libphp5.so as example but yours might be in other place. Search for it in your machine and use the path to your file.

5- Restart your apache with
sudo /etc/init.d/apache2 restart

You should see your phpinfo file working ok now.

Hope this helps

Can you help with this problem?

Provide an answer of your own, or ask cybard for more information if necessary.

To post a message you must log in.