Page 1 of 7

How to add PHP to Hiawatha server?

Posted: Sun 17 Aug 2008, 16:07
by Lobster
Been looking at Hiawatha Server in Puppy Dingo+1 Alpha6 . . .
Works OK
ahem . . .
but I need a PHP server - is it available? As a pet - or Slackware or part of a Lamp module . . .

Posted: Sun 17 Aug 2008, 19:52
by Lobster
Just about to try this PHP .pet. . . details soon . . .
http://www.murga-linux.com/puppy/viewto ... 634#164304

OK I have installed it - eh now what . . . ?

try this

Posted: Tue 19 Aug 2008, 02:41
by raffy
Put this in a test.php file:

Code: Select all

<? phpinfo(); ?>
Then type its URL in your browser, like http://localhost/test.php

You should see the PHP details if PHP is working.

For the download of this Growler's LAMP, look here:
http://dotpups.de/..Internet/LAMP-6.16-5.1.35-5.2.9.pet

Posted: Tue 19 Aug 2008, 12:07
by Lobster
Thanks Raffy I may well be calling on your Lamp expertise :)

LAMP is one of the most successful usages of Linux
LAMP is used in critical situations were un-operating and micky mouse operating systems (mentioning no names - ahem - Windows) are not robust enough

L = Linux
A = Apache Server
M = MySQL
P = PHP

What is it? What can you do?

Well the Puppy equivalent would be to use Hiawatha as the server component . . .

Basically you could have a server on an intranet or the internet with a URL - independent of an ISP

PHP generates HTML webpages
so it can grab data from any source (usually a database)
and generate pages . . .

What does this mean?
Well Eric in Canada (who very kindly sent me a Puppy T shirt with Vincent on it)
provides server space - he has taught himself . . .
The server is hosted elsewhere . . .

But what if we start moving some puppy programs
onto our own servers?

Or creating an online database?
We too can learn and test using Hiawatha . . .

This is why this is in cutting edge
. . . playtime continues . . .

http://hiawatha.leisink.org/

8)

P.S. Puppy says woof woof

Posted: Tue 19 Aug 2008, 19:49
by boscobearbank
I'm very interested in this, but can't seem to get php to run under hiawatha. I did a default install of php-5.2.5-i486.pet. Adding the following to /etc/hiawatha/httpd.conf:

Code: Select all


# BoscoBearbank extensions
CGIhandler = /usr/local/bin/php:php
CGIextension = php


Directory {
        Path = /root/httpd/hiawatha/katieskitchen
        ExecuteCGI = yes
        UploadSpeed = 10,2
}
when I try to access /root/httpd/hawatha/katieskitchen/info.php (code below)

Code: Select all

<html>                                                                          
<head></head>                                                                   
<body>                                                                          
  <H1>TEST</H1>                                                                 
  <? phpinfo(); ?>                                                              
</body>                                                                         
</html>      
I get a 500-Internel Server error whereas when rename the file to info.html and access it, I see, as expected, the word TEST.

What other changes do I need to make to my configuration files to get this to work?

TIA

Posted: Wed 20 Aug 2008, 09:19
by Lobster
I am finding 4.1 Alpha 6 too unstable to continue
I may try to install hiawatha as a pet - is it available?
and Php on Puppy 4
or use another machine . . .

Keep us informed and advised - maybe able to use another computer tonight . . .

PHP support in puppy

Posted: Wed 20 Aug 2008, 23:13
by rob
I waffle a bit in the next paragraph. Feel free to skip it.

I've been waiting for PHP support within puppy for a long while now. PHP is basically a fully fledged programming language. It is written in C++ and it shines!!! In the future, it would be possible to run commands like they can be run in a terminal. Remote controlling puppy becomes much easier, for example, by having a music or video server controlled via a mobile phone web browser. Ok. I got a bit carried away, but this will be one of my first projects once a stable version of php is available.

Back to the task, below is some sample code. You type in an address in your browser on pc1. The browser on pc1 asks the webserver on pc2 for a page (index.php). The webserver on pc2 checks to see what it should do to the file based on its settings. It should, for .php files, be set to send them to a php parser. php then parses the file returning the "answer" to those parts of the code inside <? and ?> tags, but leaving the rest intact. If it is not set to parse the file (.htm files for example are sometimes set not to be parsed) the webserver will return all of the file, including the php tags <? and ?> without processing them. <? to ?> is invalid html and so will not be rendered when received by the web browser. This will result in the title "PHP Test" in the following example if not parsed or "PHP Test Working" if PHP is parsing the file correctly.

Code: Select all

<html>
  <head>
    <title>PHP Test <?php echo "Working";?></title>
  </head>
  <body>
    <?php echo "php is working";?>
  </body>
</html>
That was all an extremely long winded way of saying the reason your code half worked is because the webserver just passed you the file. PHP did not parse it unless you got the php info screen, detailing your php settings.

Posted: Thu 21 Aug 2008, 03:04
by Lobster
Lob, can you block him?
Perhaps.
Maybe telepathically . . .
. . . though holding up two flowers might work for some . . .
http://tmxxine.com/wik/wikka.php?wakka=NewBodhis :)

I probably need some vitamins and a bit of augmentation
http://open-rtms.sourceforge.net/
and a matrix style plug in . . .

However using conventional methods
just provide a link to the 'report spam'
thread for 'Flashy' attention.
Right click on the tiny 'folder' of a spam post to copy the location of any spam . . .

I notice you are coding Muppy like a maniac (days at a time)
(that is why you are a YinYana Boddhisattva)

Your mantra incidentally is
MU MU MU

pronounced Moooooooooo Moooooooooo Moooooooooo
Obviously it is sacred to cows

but has the added benefit of being your ego
and a triple negation

MU = negation or void
2 x negation = existence
3 x negation = the void dependent on form for its 'non-existence'
Image

It will also allow you to oxygenate the brain and replenish it
It may make you laugh or cry
The humming (as used by cats) also is healing
Cats purr when injured

. . . sanity is now resumed . . .

Posted: Tue 14 Oct 2008, 21:42
by Lobster
once a stable version of php is available
Is a stable PHP available? Does it have to be compiled in devx for 4.1?
the only version I have is now also hosted here:
http://www.tmxxine.com/pets/php-5.2.5-i486.pet

- not sure if it is working in 4.1 in a stable manner?

I have been using Hiawatha - seems to work OK
- just type hiawatha from the command line in Puppy 4.1
PHP (link in earlier post) seems to be running - not experienced enough to configure . . .
but my output is the HTML - the source with no parsed web page generated. . . .

Any ideas or tips welcome?
:)

Posted: Fri 17 Oct 2008, 01:47
by Lobster

PHP and Mysql

Posted: Fri 24 Oct 2008, 09:01
by growler
I made a pet of mysql 5.0.67 and PHP 5.2.6 - I compiled the latest vesions as of around 13th Oct. immediately after the availability of devx410.sfs

My .pet is less than 9Meg - so way smaller than the monster LAMP systems around and uses Hiawatha - already in puppy 4.1. It has an install script that creates the mysql tables etc and sets things up so it just works - the server is started at each boot (and post installation). PHP works as a Fast CGI program (not as a module - as it can with Apache) - and performance seems pretty good. Running as a module is theoretically faster but I'm not sure this is still true. Also Apache is a massive memory hog.

Simply install the pet from

[edited and again] for download of the latest see:
http://www.weberp.org/PuppyLinux
[/edited]

then point a browser to

http://localhost/

to see the output of

phpinfo()

this shows the versions and system variables etc. and proves php is working.

You simply install php application below

/root/httpd/hiwatha - the web document directory.

I have made hiawatha and mysql run as the user nobody.

BTW - also included is the phpMyAdmin 3.00 php mysql administration tool.

http://localhost/phpMyAdmin/

you'll need to login as the user root - password is blank by default - this should be changed -see the mysql manual for details on how to change the mysql root user's password.

PHP and Mysql

Posted: Fri 24 Oct 2008, 09:06
by growler
Lobser: but my output is the HTML - the source with no parsed web page generated. . . .
Well that's because you need to configure Hiawatha to use php as a cgi or Fast CGI program and that any files ending in .php are sent off to the php binary - /usr/bin/php-cgi for parsing ... the php interpreter returns html which the browser renders as nice pretty webpages.

HIawatha How-to for CGI programs (like PHP or Perl):
3.3 Running CGI programs
Making Hiawatha run CGI programs is easy. You can allow CGI execution per website.

VirtualHost {
...
ExecuteCGI = yes
}

Specify the extension of CGI programs via the CGIextension option.

CGIextension = cgi

If you want to run CGI scripts, you have to specify where Hiawatha can find the binary that can parse these scripts.

CGIhandler = /usr/bin/php4-cgi:php4
CGIhandler = /usr/bin/php5-cgi:php,php5
CGIhandler = /usr/bin/perl:pl
CGIhandler = /usr/bin/python:py

You can limit the maximum runtime of CGI programs (in seconds) via the TimeForCGI option.

VirtualHost {
...
TimeForCGI = 5
}

And the Hiawatha Fast CGI how-to:
5.1 FastCGI
Although this section has been placed under "Advanced configuration", using FastCGI with Hiawatha is actually quite easy. In this example, we'll use PHP via FastCGI. First, install php-cgi with FastCGI support (compile PHP with --enable-fastcgi or check that your precompiled php-cgi package has FastCGI support). Edit the configurationfile php-fcgi.conf (which is located in your Hiawatha configuration directory). For every Server configuration line, a PHP FastCGI daemon will be started. Every Server configuration line consist of at least 3 options: the path to the php-cgi binary, the binding (interface:port) and the userid the PHP FastCGI daemon must switch to. An optional fourth option tells the path to the php.ini file. A typical configuration line looks like this:

Server = /usr/bin/php5-cgi;127.0.0.1:2005;www-data

Run php-fcgi (probably in /usr/sbin or /usr/local/sbin) to start the PHP FastCGI daemon(s). Run with the '-k' option to kill the running PHP FastCGI daemons.

In httpd.conf, you have to tell Hiawatha how to reach this FastCGI server and when to use it (for which file extensions). Give it a unique id and use this id with the FastCGI option for every virtual host which must use this FastCGI server.

FastCGIserver {
FastCGIid = PHP5
ConnectTo = 127.0.0.1:2005
Extension = php
}

VirtualHost {
...
FastCGI = PHP5
}

A FastCGIserver section with the same extension as a CGIhandler, overrules this CGIhandler.

If you specify more then one ConnectTo parameter, Hiawatha will switch between these FastCGI servers for every connection. You can use this load-balancing feature for heavy websites. To prevent CGI sessions from getting disrupted, Hiawatha must know the timeout (in minutes) of such session.

FastCGIserver {
FastCGIid = PHP5
ConnectTo = 10.0.0.100:2005, 10.0.0.101:2005, 10.0.0.102:2005
Extension = php
SessionTimeout = 15
}
My PET has PHP configured as a FastCGI program - so if you install it you won't need to mess with hiawatha configs - its all done for you.

Posted: Fri 24 Oct 2008, 11:05
by Lobster
Excellent we need some testers and maybe even an SFS
:)
This complete PHP+MYSQL pet - great stuff - just tried, seems OK
A good name for this is the English version of 'streetlight' - Lamppost
http://www.murga-linux.com/puppy/viewto ... 811#242811

Thanks for putting it together growler :)

LAMP or PHMP

Posted: Fri 24 Oct 2008, 19:41
by growler
LAMP

L inux
A pache
M ysql
P HP

But we are using

P uppy Linux
H iawatha
M ysql
P HP

But the world knows the platform as LAMP so probably best to stick with the brand that is so well known.

I wanted to make a .sfs as I had done for 3.01 and 4.00 but because I had to modify the config of Hiawatha the squash file could not over-write the /etc/hiawatha/httpd.conf file in pup_410.sfs due to the sequence of the filesystem layers I guess. I already posted on the subject but no-one else had any ideas - or at least didn't respond.

Also since I compiled without PEAR and mysql without clustering, the test-suite or documentation etc the size of the applications are much more managable - PHP is just 3 Meg uncompressed. Mysql has become huge but this way again it is more managable. I was pleased to get the .pet with the whole shbang in at 8.5 Meg.

Since .pet works more easily with a HD install (no manual extraction to the .sfs files to the root directory) and it is so easy to uninstall I am happy with just having the .pet - I suspect once installed and the imagination of a developer captured it will never be uninstalled and no future machine will be complete without PHMPing my puppy ride.

PHP works localhost but not via real IP

Posted: Fri 21 Nov 2008, 16:09
by gmlogan
Hi,
I installed the package pet file, and a basic PHP page works as long as I ref as http://localhost/ (so loopback) but when I use the real IP http://192.168.1.9/ it simply passes the file unprocessed.

Thanks in advance.

PHP works localhost but not via real IP

Posted: Fri 21 Nov 2008, 20:34
by growler
The file /etc/hiawatha/httpd.conf contains the configuration of hiawatha. The standard config contains only one VirtualHost section for localhost. If you wish to connect using urls containing different host info then you need to add additional VirtualHost sections into you config file.

Hiawatha will not work with http://127.0.0.1/ either until you add another section

Code: Select all

VirtualHost {
	Hostname = 127.0.0.1
	WebsiteRoot = /root/httpd/hiawatha
	StartFile = index.php
	ExecuteCGI = yes
	FastCGI = PHP5
}
and for your example another virtual host for 192.168.1.9

Code: Select all

VirtualHost {
	Hostname = 192.168.2.9
	WebsiteRoot = /root/httpd/hiawatha
	StartFile = index.php
	ExecuteCGI = yes
	FastCGI = PHP5
}
or course if you have your external ip mapped to a real domain you need to have a Hostname = myrealdomain.com
so that hiawatha will process urls using that http://myrealdomain.com

Another trap I learned was that you can only have one VirtualHost section for the same hostname - seems obvious now but a different configuration for the same hostname will not be processed - only the first listed VirtualHost section is used

Posted: Sat 22 Nov 2008, 03:13
by gammagone
this is a great package
it's something i've been wanting
but i need help - i don't really know how to code - just guessing at it

with it auto starting at boot i click on
Menu -> Personal -> PPLog personal log
and it doesn't know hiawatha is already running
and if i click start it gives the error message

i changed two things in usr/sbin/pplog_gui

(1)
if [ "`echo "$PSSTATUS" | grep ' hiawatha'`" = "" ];then
took out space before hiawatha
if [ "`echo "$PSSTATUS" | grep 'hiawatha'`" = "" ];then

now when i click pplog i get a 404, so i do

(2)
exec defaulthtmlviewer http:127.0.0.1:80/blog/pup_pplog.pl
change to
exec defaulthtmlviewer http://localhost/blog/pup_pplog.pl

this seems to fix the conflict but it doesn't really give me all i want
and maybe going in the wrong direction?
i know how to stop the auto start
but i'd really love a menu item to start and stop hiawatha php
and mysql when i want to

i'll keep trying on my own but it may be a while, if ever

Hiawatha On an Off Script

Posted: Sat 22 Nov 2008, 05:01
by growler
This is my fault - I did not consider BK's PPLOG script to start Hiawatha - cos I always want to have it going. If you don't want to have hiawatha started at boot time then move the script /etc/init.d/rc.httpd from its current location to somewhere else or ditch it althogether - also my .pet starts mysql too - the same would apply to /etc/init.d/rc.mysqld.

You can then use BK's scripts to start and stop Hiawatha. Your fix to take out the space in front of hiawatha is necessary since I was running it using the full path - if my rc.httpd script is not used then hiawatha is started without the full path and BKs script to stop it works again.

Also, if you wish to use PPLOG then you can browse happily over to

http://localhost/blog/pup_pplog.pl

to run the blog. You don't need to run it from the short cut on the menu - perhaps a bookmark in your browser.

One potential pit-fall is that /etc/init.d/rc.httpd starts the fastcgi php daemons - BKs script doesn't since PHP is not in the standard puppy. Perhaps the thing is to just move this script out of /etc/init.d/ to say /root/my-applications/

then call it manually:

/root/my-applications/rc.httpd start

to start hiawatha and PHP daemons and

/root/my-application/rc.httpd stop

to stop hiawatha and PHP daemons.

Posted: Mon 16 Mar 2009, 18:39
by awatar100
I dont know why but in my puppy i have to config firewall also so vhost work

clean the pids when stopping Hiawatha

Posted: Mon 23 Mar 2009, 19:00
by tcubed
Hello-
I have 2.6.21.7; maybe this is already taken care of in the latest release.

In /etc/init.d/rc.httpd, I had to add

Code: Select all

rm -f /var/run/php-fcgi.pid
to the stop section.

HTH