Jump to content

Recommended Posts

I installed the PHPDev5 package with PHP, Apache, MySQL and what not.

I put a "Hello world!" in the www directory like this:
[code]<html>
<head>
  <title>PHP Test</title>
</head>
<body>
<?php echo '<p>Hello World</p>'; ?>
</body>
</html>
[/code]
Now, when I go to this file, "hello.php", it doesn't get parsed. In Firefox, I get the whole source like above, displayed back on the page. In IE, I just get an empty page, though the page title does get changed to "PHP Test."

I can't figure oput what the problem is. Can anyone help?
Link to comment
https://forums.phpfreaks.com/topic/14258-apache-works-but-doesnt-parse-php/
Share on other sites

Apache needs to be instructed to parse php. Below are common additions to Apache's configuration file:

[code]LoadModule php5_module modules/libphp5.so # Windows uses a dll.
AddType application/x-httpd-php .php
AddType application/x-httpd-php-source .phps
DirectoryIndex index.php index.html[/code]
I can't speak for packages--I don't use them. You may want to try reading its documentation or contacting someone associated with it. The manual way, if everything was installed properly, is to edit httpd.conf in the conf directory of Apache. You can use notepad to add these directives to it, then restart the server.
Every httpd.conf I've worked with has been ASCII, and this is how they are delivered with Apache. A basic setup is fairly easy; you can find a slew of tutorials on the web. I assume you're on Windows? I've never used Java with Apache--I think this is called Apache Tomcat.
How are you invoking the script? Are you double clicking the file or typing URL http://localhost/hello.php

If you're double clicking, that is your problem. PHP needs to be processed by the web server, when you double click, the script is interpreted by the browser directly and the server is not invoked.

Ken
  • 2 weeks later...
Thanks, guys.

I figured out what the problem was. It has nothing to do with php or apache, and it's embarassing :-[

My Windows, by default, didn't show the extentions for known file types. When I saved my hello.php in Notepad, Windows saved it as hello.php.txt, without letting me know. That's how Apache didn't get to parse it -- because it didn't see it as a PHP file.
This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.