Forum

newbie blues

Mike Roberts
20 November 2010, 01:55
Aloha Hugo,

My background is C/C++/SQL, but with no prior client-server experience. I have never used PHP before, and I have rarely been on a Unix system. Unfortunately, this makes much of the content of your Howto and Forum obscure to me.

I'm presently running on a Windows PC. My immediate intention is to achieve proper processing of a simple PHP file, foo.php, which I have placed in C:\wwwroot
<html>
<body>
<?php echo '<p>Hello World</p>'; ?>
</body>
</html>


When Firefox is directed to this file, it renders:

Hello World

'; ?>

which (because of the dangling characters) looks like failure to me. Apparently, I have been unsuccessful in getting Hiawatha to process the PHP script.

From my reading of the Install.txt file that comes with PHP, and your Installation.txt for Hiawatha, it appears that CGI or FastCGI is required for Hiawatha to process PHP script. While I will ultimately want the speed of FastCGI, at this point it does not matter to me how I get PHP script interpretation running in Hiawatha. The "faster" (as in "the least hassle") the better right now.

Apparently C:\Program Files\Hiawatha\config\hiawatha.conf is critical for getting Hiawatha to process CGI and hence PHP. My best guess (after many failed attempts) is that some magic combination of deletions of the # symbols at the start of certain lines in hiawatha.conf might do the trick.

The log files yield no clue as to what I'm doing wrong. Here's my hiawatha.conf file:
# Hiawatha httpd.conf 
#

Binding {
Port = 80
MaxKeepAlive = 30
TimeForRequest = 3,20
}

ConnectionsTotal = 150
ConnectionsPerIP = 10
SystemLogfile = C:\Program Files\Hiawatha\log\system.log

CGIextension = com,exe
CGIhandler = C:\Program Files\Hiawatha\bin\ssi-cgi.exe:shtml, shtm, stm
#
# Download the PHP zip package from http://www.php.net/downloads.php
# and unzip to C:\Program Files\PHP5\
CGIhandler = C:\Program Files\PHP5\php-cgi.exe:php
# or
#FastCGIserver {
# FastCGIid = PHP5
# Extension = php
# ConnectTo = 127.0.0.1:2005
#}

Hostname = 127.0.0.1
WebsiteRoot = C:\wwwroot
StartFile = index.html
AccessLogfile = C:\Program Files\Hiawatha\log\access.log
ErrorLogfile = C:\Program Files\Hiawatha\log\error.log
ExecuteCGI = yes
#UseFastCGI = PHP5
TimeForCGI = 10


Thanks for reading through this. I know your target audience is folks that already understand all this stuff, so I appreciate any help you can give me to get me started.

Mike



Hiawatha version: 7.4
Operating System: Windows XP SP3
Hugo Leisink
20 November 2010, 09:29
Hi Mike,

If Firefox is not showing HTML tags, it's likely that the PHP script is executed correctly. Otherwise a .php file would be seen as a plain text file and shown as such.

I have no idea where those last characters are coming from. Are you sure there ain't a second "'; ?>" in your code?

Your Hiawatha configuration looks oke for using PHP as CGI. If you want to use FastCGI, uncomment the FastCGIserver block and the UseFastCGI line. Start PHP as a FastCGI daemon by starting the PHP symlink in the Hiawatha directory in Program Files. Don't forget to restart Hiawatha after changing the configuration file.
Mike Roberts
20 November 2010, 20:48
Hugh,

Thanks for getting back to me so quickly. I'm actually quite excited about getting Hiawatha to work for me.

This morning I booted up my machine, pointed Firefox at C:\wwwroot\foo.php, and got the same result with dangling characters. Note that I have NOT yet touched Hiawatha. Hiawatha is not running. I just tried Google Chrome... same result. IE8... oh, this is different. IE8 just spits the whole content back at me, like you expected:

<html>
<body>
<?php echo '<p>Hello World</p>'; ?>
</body>
</html>

As you can see... no repetition of the dangled characters.

So... Firefox and Chrome have some vestigial PHP capability ??? That's a little spooky.

Since apparently I need to use IE8 to do my testing with Hiawatha and PHP, I fire up Hiawatha and... the results are unchanged on all 3 browser platforms.

(One weirdness: in IE8 it is NOT SUFFICIENT to hit the refresh button; you have to place the cursor in the URL field and hit Enter. Otherwise the rendered page becomes blank.)

My conclusion. unfortunately, is that Hiawatha is not processing the PHP on my PC, with the present version of hiawatha.conf.

Are there any other config files I need to attend to? Is my assumption correct that I need CGI activated to get PHP processing? Should Hiawatha have handled the PHP script without my editing of hiawatha.conf for CGI?

Mahalo,
Mike
Hugo Leisink
20 November 2010, 21:01
You pointed the browser to a file... no wonder why you see strange results. Try starting Hiawatha and point you browser to http://localhost/

FYI: No, Firefox and other browsers do NOT have PHP capabilities. What happend is that the <?php tags were ignored. So, what remained was the Hello world text, which looked like the print command was actually being processed.
Mike Roberts
21 November 2010, 07:15
Hugo,
Thank you. It works! I greatly appreciate your help.
Mahalo nui loa,
Mike
Mike Roberts
21 November 2010, 10:43
Got FastCGI working. All Hiawatha responses are nominal. I'm on my way...
Mike
Mike Roberts
21 November 2010, 11:04
Got it working over my LAN. This is actually fun! Yea, there's hard work ahead for me, but it's cool to have it just working. Thanks again, Hugo.
Mike
Hugo Leisink
21 November 2010, 11:53
That's good to hear. If you have any questions, just let me know.
This topic has been closed.