Topic: PHP on the chumby?

Hi all,

I just got my chumby, and i'm really happy with it. I got lighttpd set up and running.

I'd really like it if i could run PHP scripts as well. Shouldn't be too hard to get them running on lighttpd as described here: http://trac.lighttpd.net/trac/wiki/Tuto … ttpdAndPHP . I'd only need compiled binaries for PHP, but i couldn't find any on files.chumby.com/source.

Is there anybody who got PHP working on the chumby? And if so, can he/she share the binaries?

Re: PHP on the chumby?

It's not hugely difficult to build PHP for the chumby, although it looks like the standard PHP source distribution really isn't properly built for cross-compilation.

From Chumby Industries' "teach-a-man-to-fish-department":

Basically, put together an ARM9 toolchain as shown on the wiki, download and unpack the source to PHP from php.net, then

# ./configure --disable-all --build=i386-linux --host=arm-linux --prefix=/usr/arm-linux --enable-fastcgi --enable-discard-path --enable-force-cgi-redirect

It appears their configuration doesn't actually target the architecture correctly, so you'll have to edit the MakeFile to set CC to "arm-linux-gcc" instead of just "gcc"

Then:

# make
# sudo make install

At this point, you should have the PHP binaries sitting at /usr/arm-linux/bin.  First thing to do is strip them to make them smaller:

arm-linux-strip /usr/arm-linux/bin/php /usr/arm-linux/php-cgi

They should end up a little over 2MB.

You'd then copy the php-cgi binary to a dongle, then edit the lighttpd.conf file per the instructions on the page you linked to let lighty know where the php-cgi binary is located.

Note that this builds a very basic PHP with no optional modules - if you want them, you'll need to build their library dependencies separately for ARM (libxml2 being the most necessary) and then reconfigure and rebuild PHP with each of the modules enabled and disabled as you wish.

Here's what I get on my chumby:

chumby:/mnt/usb# ./php -v
PHP 5.2.5 (cli) (built: Dec 18 2007 14:43:07) 
Copyright (c) 1997-2007 The PHP Group
Zend Engine v2.2.0, Copyright (c) 1998-2007 Zend Technologies
chumby:/mnt/usb# ./php-cgi -v
PHP 5.2.5 (cgi-fcgi) (built: Dec 18 2007 14:42:53)
Copyright (c) 1997-2007 The PHP Group
Zend Engine v2.2.0, Copyright (c) 1998-2007 Zend Technologies
chumby:/mnt/usb#

Re: PHP on the chumby?

Thanks for the quick reply! I'll try to get the toolchain setup, and then compile PHP myself. :-)

Re: PHP on the chumby?

When you get it done all the way, please feel welcome to post more complete instructions on the wiki, perhaps linked from the lighttpd instructions.

Re: PHP on the chumby?

And can you post the file to download (Contact me if you need a webspace to host the .zip)

Re: PHP on the chumby?

Well, thanks to Duane's help, it's going well:

http://webtwee.net/images/php_on_chumby.jpg

Over the weekend i'll work some more on it (it needs to be able to find the php.ini, and i'd like to have some of the standard modules)

When i'm done i'll post instructions and binaries for those interested..

Re: PHP on the chumby?

Sounds good to me!  I know I would be interested in the binaries!

Re: PHP on the chumby?

Any Lick, This one will be SWEET

Re: PHP on the chumby?

Hey bopp, did you have any luck with this

Re: PHP on the chumby?

I downloaded the tool chain and compiled the latest PHP (5.2.5), posted the Chumby binaries here

http://www.vrtisworks.com/cmsms/index.p … ource-code

Nick

Re: PHP on the chumby?

PHP as a scripting language....

Something I ran across while working  on a Mac.. it is possible to use PHP instead of Bash or SH as a command line scripting language...
What this means is that if you were to create a file called testphp and put it in /psp/cgi-bin, you could actually serve up a php generated web page using the built in Chumby web server....

#!/mnt/usb/php
<?php
 phpinfo();
?>

This assumes that you have php on your usb stick plugged into the #1 usb port.  Fire up you friendly browser and go to http://chumby.ip.xxx/cgi-bin/custom/testphp and you'll see the PHP info.  Not very pretty because it comes out as plain text, but it sure does open up some possibilities.  And you don't need to hassle with loading another HTTP server.

Nick

12

Re: PHP on the chumby?

this rocks! thanks for posting the compiled binaries. Question -- what's the difference between the PHP-CGI binary and the PHP binary? Thanks.

Re: PHP on the chumby?

PHP-CGI runs as a FASTCGI module.  So it doesn't work too well as a shell script.

Re: PHP on the chumby?

Hi,

I would like to thank for this PHP related discussion. I am looking for Chumby developers mailing list instead of the forum like maemo-developers mailing list. I don't know but I don't like the forum way of discussion. Is there any chumby developers mailing list?

Apart from this, I am going to get my chumby by tomorrow in Bangalore, India. I am already working on project, where I have already cross-compiled PHP5, d-bus, GTK+, Xserver, lighttpd, perl etc under scratchbox for ARM9.

I was looking for some good developement environment like openembedded or sbox which really eases the pain of cross-compilation. I feel that this needs to be addressed first.

First thing I am planning for is to create sbox based development environment for chumby, and due to this I was looking for chumby-developers mailing list, instead of forum way...If any ML exists, where original chumby developers are also part of, then please notify me, as it helps to speed up the development. Thanx.

Recently there is also PHP-DBus bindings project was started by Tobias, which is in very much initial stage, and I think PHP-DBus bindings can also be useful with chumby too.

---Trilok Soni

15 (edited by jyee 2009-01-01 00:16:23)

Re: PHP on the chumby?

big thanks to Nick for the php-cgi binary!

I'm a seasoned LAMP user, but i'm really new to the chumby and lighttpd... so setting this all up took me a bit of time.
Since no one has explicitly given steps to installing php, here's my "idiots" guide:

1. get lighttpd... the binary at the bottom of the page works well. http://wiki.chumby.com/mediawiki/index. … web_server
unpack it to a fat16 or fat32 formatted flash drive.

2. get Nick/vrtisworks php-cgi binary (link is a few posts above) and put it on the flash drive.

3. edit your lighty/lighttpd.conf file to add the fastcgi module:

server.modules = ( "mod_cgi", "mod_accesslog", "mod_fastcgi" )

and also add the following lines to your lighttpd.conf file... 127.0.0.1 is localhost, so it'll work if your chumby is on dhcp or for whatever ip your chumby has. bin-path is obviously wherever you put the php-cgi from step 2:

fastcgi.debug = 1
fastcgi.server = (
    ".php" => (( 
        "host" => "127.0.0.1",
        "port" => 80,
        "bin-path" => "/mnt/usb/php-cgi"
    ))
)

anyway, I hope that helps.  I'm by no means any sort of expert... I'm just someone who'd rather not compile things or read loads of documentation... and I figure this might help people like me. smile

Re: PHP on the chumby?

Hi there,

I started trying this out and so far it works pretty well. One question: how do I get http authentication to work? I used to do a "http://user:password@address/" in my Ap server, but does not seem to work ligth lighttpd.

Thanks,
Jose

Re: PHP on the chumby?

Any thoughts on this? All documentation I find about lighttpd and the fast cgi php implementation seems to think http authentication ( ala http://user:pass@address/) should work.

Maybe I have something not set right in my config files?

Thanks,
Jose

18 (edited by jyee 2009-01-07 12:00:20)

Re: PHP on the chumby?

I haven't actually enabled authentication, but i think the process would be something like:
1. ensure hat mod_auth.la and mod_auth.so are in the /mnt/usb/lighty/lib folder (or wherever you lighttpd lib folder is)
2. update your lighttpd.conf file to include mod_auth in your server.modules and set the mod_auth settings:

server.modules = ("mod_accesslog", "mod_auth", "mod_fastcgi")
auth.backend = "htpasswd_"
auth.backend.htpasswd.userfile = "/mnt/usb/lighty/.htpasswd"

notes:
-the documentation had an underscore in "htpasswd_"... i'm not sure if it's needed, so try it with and without.
-the documentation (and my info above) seems to indicate that lighttpd will apply the authentication to the entire site, that than doing something like apache, where you can put unique .htaccess/.htpasswd files in individual directories.
-the .htpasswd file can be created using the tools from apache.  you'll need to do something like:
  htpasswd -c -m .htpasswd user
Then copy the .htpasswd file to location in the lighttpd.conf file.  "-c" creates the file, "-m" specifies md5 encryption.
You can find more info on htpasswd here http://httpd.apache.org/docs/1.3/programs/htpasswd.html


**note to mods: this and the previous notes from Josep don't really relate to php... they probably ought to be moved to a "mod_auth" thread.**

19 (edited by guillaume 2009-07-28 04:25:26)

Re: PHP on the chumby?

Hello,

firstly I'm french, so sorry for my english tongue

I want to use PHP sript on my chumby but I try all the solutions in this topic and nothing is working.
The firmware installed is the 1.7 .
Maybe the php-cgi and php files are build for 1.6 firmware only?

20 (edited by guillaume 2009-07-28 04:22:44)

Re: PHP on the chumby?

I think that the problem comes from the firmware version. the gnu toolchain isn't the same since the 1.7 firmware. I'm not a linux user so if anybody can build PHP for 1.7.1 firmware, it'll help me a lot, and also be useful for other people...
Thanks

Edit : I build PHP 5.2.5 for the 1.7.1 firmware (with GCC 4.3.2) and now it works perfectly. If anybody is interested I can give you the php files (php and php-cgi).
PS : I tried to build PHP 5.3 but i had more than 1 hundred errors !!! I don't know why.

Re: PHP on the chumby?

i could do with some of that php build guillaume!

also, note as an extension to jyee's excellent instructions
you need to add this to your debugchumby to get lighttpd to start on boot:

#!/bin/sh
# kill the built-in web server
killall httpd
# create the log directory
mkdir /tmp/logs
# start lighttpd
LD_LIBRARY_PATH=/mnt/usb/lighty/lib
/mnt/usb/lighty/sbin/lighttpd -f /mnt/usb/lighty/lighttpd.conf

i'm pretty sure that last line is wrong in the wiki so i corrected it here

also, you need to edit lighttpd.conf with unix type editor otherwise you get lots of lovely errors
you can use vi which is installed on the chumby

Re: PHP on the chumby?

anybody else able to compile this?
i'm in a bit of a rush and the toolchain isn't working on my osx
(trying to get ubuntu setup on another computer just to build php-cgi smile)

Re: PHP on the chumby?

What you might consider is running an Ubuntu image in VMware Fusion on your OSX device.  That's what many of us do here.

We do not currently support a toolchain to run under OSX directly.

Re: PHP on the chumby?

sounds like a plan, i've got VMware Fusion already
will give it a go
also. if i want to compile php-cgi
is that already in the standard php download?

25 (edited by elliotwoods 2009-08-21 03:48:46)

Re: PHP on the chumby?

for anyone who wants this prebuilt for current chumby
here's the goodness
also, i've included a debugchumby and lighttpd for good measure
so all you need do is stick this on your stick and start putting stuff in /mnt/usb/lighty/html
good luck!