0

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

trhoades
  • 1
  • 1
  • 1

3 Answers3

2

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.

Jon Angliss
  • 1,782
  • 10
  • 8
1

Have you got mod_php enabled?

sybreon
  • 7,357
  • 1
  • 19
  • 19
1

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.

Alex
  • 6,477
  • 1
  • 23
  • 32