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

When i type

http://localhost/phpinfo.php 

into the browser the php is not executed. Instead a file download box opens and asks, "Do you want to open or save this file?" This is happening on all .php files on the localhost.

I believe the php.ini file is to blame but I do not have the understanding necessary to repair.

Please advise.

Thank you.

Tony

share|improve this question
    
What HTTP server s/w and platform? You're likely not setting up PHP properly. –  medina Aug 1 '10 at 4:04

3 Answers 3

Chances are, your PHP module isn't enabled, or you don't have the correct configuration lines enabled in your web server configuration. As you've missed out any useful information that might be able to guide you directly to the solution as documented by the PHP manual.

If you're using a packaged driven linux system, such as Debian, or RedHat, then you might find it is as simple as enabling an option, or creating a symlink.

share|improve this answer

Have you got mod_php enabled?

share|improve this answer

If you are getting the source file downloaded instead of the rendered output, php.ini hasn't come into play yet. As sybreon mentioned, you need to make sure first that you have the php module loaded. There should be a line like LoadModule php5_module modules/libphp5.so in your httpd.conf, or an included config file.

Once the module is loaded, it still won't do anything until you define the MIME type with AddType text/html .php and associate the php extension with the module with AddHandler php5-script .php

Additionally you will probably want to add a DirectoryIndex for index.php files.

If you are installing php from a package (like rpms via yum on RedHat/Fedora) the configuration to make that happen will already be installed. If you have just installed a package and are not getting the expected result, you need to restart (or reload) apache for it to pick up the new config.

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.