Page 1 of 1

test.php not displayed correctly- just the text is displayed

Posted: Tue Oct 17, 2006 12:37 am
by ssquare
I am a new user of php/apache and was trying to set it up on my box. Despite my repeated attempt, I can't get apache to recognize the php code correctly; apache treats it as a text. When I do view source, I see the php text. I have added these three files in my httpd.conf

LoadModule php5_module "D:/Apps/PHP/php5apache2.dll"
AddType application/x-httpd-php .php
PHPIniDir "D:/Apps/PHP"

I have verified to make sure that the path are abolutely correct. Also php.ini files does exist in d:/apps/PHP directory.

I am using 2.0.59 version of apache and PHP 5.1.6 version. Any help would be highly appreciated. (I have also tried to set the doc_path in php.ini to to the ../htdocs directory but that does not do any good.

I know the apache is working fine since I can pull up the index.html just fine. The problem is making apache recognize the php file

Thanks
SS

Posted: Tue Oct 17, 2006 8:23 am
by feyd
Did you forget to restart Apache after making the changes to it's .conf file?

Posted: Tue Oct 17, 2006 8:34 am
by ssquare
I have done that multiple times. Is there any log files I can look at on the php side? I have checked apache logs and everything seems fine.

Posted: Tue Oct 17, 2006 9:47 am
by feyd
Startup errors are sent to Apache's error log.

Where in the httpd.conf did you add those lines?

Posted: Tue Oct 17, 2006 10:01 am
by ssquare
Right after loadmodule section
LoadModule userdir_module modules/mod_userdir.so
#LoadModule usertrack_module modules/mod_usertrack.so
#LoadModule vhost_alias_module modules/mod_vhost_alias.so
#LoadModule ssl_module modules/mod_ssl.so

#Added by me
LoadModule php5_module "D:/Apps/PHP/php5apache2.dll"
AddType application/x-httpd-php .php
PHPIniDir "D:/Apps/PHP"


I have tried to add addtype at the bottom (with two other add types), and when that did not work, I tried this approach.

BTW, FYI - I had a virus infecting my computer a month back. I have cleaned that up using avast. But I wonder could it be some kind of lingering effect of that virus.

Another note, I do see php configured correctly from the error.log file (in apache directory)
[Tue Oct 17 08:57:33 2006] [notice] Apache/2.0.59 (Win32) PHP/5.1.6 configured -- resuming normal operations
[Tue Oct 17 08:57:33 2006] [notice] Server built: Jul 27 2006 15:55:03
[Tue Oct 17 08:57:33 2006] [notice] Parent: Created child process 520
[Tue Oct 17 08:57:33 2006] [notice] Child 520: Child process is running
[Tue Oct 17 08:57:33 2006] [notice] Child 520: Acquired the start mutex.
[Tue Oct 17 08:57:33 2006] [notice] Child 520: Starting 250 worker threads.
[Tue Oct 17 09:07:23 2006] [notice] Parent: Received restart signal -- Restarting the server.
[Tue Oct 17 09:07:23 2006] [notice] Child 520: Exit event signaled. Child process is ending.

Not sure what is it that apache is reporting as an error in these messages.

Posted: Tue Oct 17, 2006 10:18 am
by feyd
Your snips would suggest PHP is loaded correctly. Hmm. How are you accessing the test php script? Is the "engine" directive 1/true/on in php.ini? Is there an .htaccess file in the parentage of the location where your .php file is that has an engine 0/false/off directive in it?

Posted: Tue Oct 17, 2006 10:30 am
by RobertGonzalez
This is what my Apache configration looks like. I am on WinXP, Apache 2.0 and PHP5.1.6. Note: This is at the end of the conf file.

Code: Select all

# Added by me to allow for PHP5 use
# For PHP 5 do something like this:
LoadModule php5_module "c:/php/php5apache2.dll"
AddType application/x-httpd-php .php

# configure the path to php.ini
PHPIniDir "C:/php"

Posted: Tue Oct 17, 2006 10:34 am
by ssquare
The way I am accessing the php script is 1. Create a test.php file in htdocs directory. 2. put the text string <?phpinfo();?> in the test.php 3. Go to browser and type in localhost/test.php

The engine directive is on (I basically took the php.ini.recommended, and copied it as php.ini)

The apache directory does not have any .htaccess in it. Is there a way to see if the php is installed correctly (all I did to install php was unzip the downloaded file. are there other steps, like updating the path to get this install correctly)

Posted: Tue Oct 17, 2006 10:36 am
by feyd
Short tags is off by default I believe in 5.1.6. <?php phpinfo(); ?> may produce the desired results.

Posted: Tue Oct 17, 2006 10:44 am
by RobertGonzalez
Just another notch on the bedpost of 'Short PHP tags are evil'.

Posted: Tue Oct 17, 2006 10:48 am
by ssquare
That did the trick. Thanks a bunch for your responses.

One final questions - Though I don't quite understand yet what is short tags, but is it advisable to stay away from it, and if I have to turn it on (to make third party software to work), what is the best way to do it?

Posted: Tue Oct 17, 2006 10:57 am
by RobertGonzalez
Short tag:
<?

Good tag:
<?php

Always use regular opening PHP tags (<?php) when coding. It makes it compatible with future versions of PHP.

Posted: Tue Oct 17, 2006 12:10 pm
by Chris Corbyn
ssquare wrote:and if I have to turn it on (to make third party software to work), what is the best way to do it?
There's a short_tags directive in php.ini... it can't be done inside the PHP script.