-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 sagr wrote:
root@wildebeest:/var/www# cat hello.php <?php echo "Hello World"; ?>
If I type the URL http://localhost/ into firefox I see the default apache index.html holding page as expected (so I know apache is running). If however I type the URL http://localhost/hello.php a box pops up in Firefox saying:
"You have chosen to open: hello.php Which is a: PHP script From: http://localhost What should Firefox do with this file? 1. Open with gedit (default) 2. Save to disc."
Why doesn't Firefox simply display hello.php as a webpage? What am I doing wrong? Do I need to configure something in apache and/or Firefox to display php files as webpages?
It may be because you appear to be trying to run the script from your server's document root directory. By default, this will not be set up to run executable scripts, and so instead it serves it based on the information it otherwise knows about PHP, i.e. application/x-httpd-php4 (which your browser detects and thus offers you the "what do you want to do with this file that I can't handle"? message. This can also occur because the file itself does not have execution privileges ('ls -al hello.php' should show -rwxr--r-- or maybe rwxrwxr--), although this more often results in a 500 error. Ordinarily (for security) you would create a separate directory that /isn't/ in the normal document tree, e.g. /var/cgi-bin[1]. Then, in Apache's config you specify ScriptAlias /var/cgi-bin/ /cgi-bin/ - - this makes everything in this directory automatically a script. You then may *possibly* need to add some other handlers, e.g. AddHandler cgi-script .php[34] and/or AddType application/x-httpd-php[34] .php[34] Then, after a restart of Apache, you should be able to try http://localhost/cgi-bin/hello.php and it should work :-) Cheers, Simon [1] note that it would probably be better to create /var/www/docs for the document tree and /var/www/cgi-bin for scripts - -- ====================================================================== Simon Ransome http://nosher.net Photo RSS Feed: http://nosher.net/images/images.rss -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.5 (Darwin) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org iD8DBQFGrv6o8tdcY+OcZZwRAt2CAKDSlBJDDpgZfVorRxgM8pczfRoX/wCdFq4K r3zbyT9HDtjU73ETsQnMlGY= =jXM+ -----END PGP SIGNATURE-----