0

I have php, apache, mysql etc...

I am trying to view a page named "index.php", which has <php echo "hello world"; ?> in it, but instead I see a dialog box prompting me to open or save the file which is a PHP (application/x-httpd-php) file..

How can I make it render correctly?

I a CentOS 5.5
I'm on rackspace cloud servers BTW

2 Answers2

1

If you installed PHP via package (like yum -y install php), then you should have an /etc/httpd/conf.d/php.conf that specifies the needed entries. If apache was running when you installed php, then you have to restart apache for it to pick up the configuration changes.

If you installed from source, you need to make sure the following directives are included in your httpd.conf (or an include)

LoadModule php5_module modules/libphp5.so
AddHandler php5-script .php
AddType text/html .php
DirectoryIndex index.php

The AddType and AddHandler directives are specifically needed to tell apache how to send files that end w/ .php. Otherwise, it will send with a default MimeType, which your browser will then prompt you to download as you are seeing.

Alex
  • 6,477
  • 1
  • 23
  • 32
  • I already have all of those lines in the httpd.conf and php.conf is setup correctly for php to show and render. If I tell it to render ".php" as text/html using .htaccess it works but, I only get the dialog box when I try to change the AddType to application/x-httpd-php –  Oct 25 '10 at 06:02
0

I found the problem, I didn't select php as a language in the Plesk panel. I did that and it simply solved the problem. Thanks Alex for your suggestions.