I have a test.php file in the web server directory with php phpinfo(); content. When I try to execute php test.php at a shell then it executes correctly. But when I try to open the web page in a browser, it shows php phpinfo();. How can I troubleshoot Apache 2 and PHP 5 on my UNIX machine?
|
|
|||||||
|
|
I think you need to wrap your code in
By default, the contents of a PHP file are HTML that is sent untouched out to the browser. The markers |
|||
|
|
|
As penguin359 pointed out, php won't interpret anything in a html page that isn't bracketed with If it still doesn't work after you've tried that, the first thing you should probably do is check your server's access and error logs (by default in If the page was accessed and no error reported, it means that the server for some reason didn't find it necessary to fire up the php parser, most likely because of a config error. There are several different ways for the php parser to be called by apache; the two most common ones are via the dynamically loaded php module, or via CGI. If it's (supposed to be) loaded via
with slight variances possible depending on how your distribution handles apache2 configuration. If it's called via cgi instead -- generally a better option because it allows for a threaded server as well as nifty stuff like SuEXEC -- then you should again check your apache config files and look for lines saying something like which tell the server how to handle files ending with Again, though, exactly what is wrong with your server -- assuming that it's more than just the original failure to bracket your .php file with |
|||||
|
