View Full Version : running php on wl500g
Guys,
Can someone write a short introduction to help me get PHP running on my router. I'm not using the default httpd (just for admin gui) but I run busybox_httpd. Now i want to make it possible to run php.
please help me out!
RoNin
On the OpenWRT forum I found this:
http://davidoffdotnet.net/openwrt/ipkg/
There are the following packages which provide PHP for the Linksys WRT54g, so they might work on the WL-500g as well:
Package: lwhp
Version: 1.0.0
Section: net
Architecture: mipsel
Maintainer: sam <sam@davidoffdotnet.net>
MD5Sum: 96bd50f8625f94f54e62255456b3a683
Size: 143640
Filename: lwhp_1.0.0_mipsel.ipk
Source: http://davidoffdotnet.net/openwrt/ipkg/lwhp_1.0.0_mipsel.ipk
Description: a lightweight hypertext processor
Package: thttpd-php
Version: 2.21b-2
Section: net
Architecture: mipsel
Maintainer: sam <sam@davidoffdotnet.net>
MD5Sum: b0660a8072d3c9bfd42a26fccf7571c4
Size: 402230
Filename: thttpd-php_2.21b-2_mipsel.ipk
Source: http://davidoffdotnet.net/openwrt/ipkg/thttpd-php_2.21b-2_mipsel.ipk
Description: The thttpd webserver compiled with php4 support.
The first seems to me a simple php library (I don't know what its features are).
The second package contains a webserver.
I hope this is helpful and, as allways, if it works for you please report back here :)
Scoundrel
29-12-2004, 11:10
I've tryed these packages, but after starting the php application died with 'Segmentation Fault' error. Can anybody write me how to make install these packages correctly? I'm newbie in LINUX :-(
My configuration is: ASUS WL-500GX, Firmware 1.9.2.7 RC2 (OLEG)
Please help me out.
SC
Packages: http://davidoffdotnet.net/openwrt/ipkg/
You have to replace the current firmware by OpenWRT if you wish to use OpenWRT packages. Read at least this thread: http://wl500g.info/showthread.php?t=737&highlight=openwrt The firmware download link seems to be dead at the moment but it should be available soon.
Any possibilities on cross-comping these applications to Asus source tree?
erik_bies
04-01-2005, 23:26
I gave it a try and compiled these.
Here is PHP3 & thttpd (without PHP4). I'll give the thttpd+php4 combi another try later, but sofar that resulted in a long list of errors
For me it is working on 1.9.2.7-2 software.
Good luck
Scoundrel
05-01-2005, 09:51
Eric,
Thanks for PHP stuff.
I tried these programs, but the browser sends me this message:
403 Forbidden
The requested URL '/index.html' resolves to a file which is marked executable but is not a CGI file; retrieving it is forbidden.
Can you tell me the correct setup process to WL-500GX device?
My configuration is: ASUS WL-500GX, Firmware 1.9.2.7 RC2 (OLEG)
SC
-----------------
Here is PHP3 & thttpd (without PHP4). I'll give the thttpd+php4 combi another try later, but sofar that resulted in a long list of errors
For me it is working on 1.9.2.7-2 software.
Good luck[/QUOTE]
same issue for me. php works fine, script can be run from command line.
Seems this problem is due to the fact, that fat/fat32 is not a native linux filesystem, i.e. it does not have all required file attributes, so by default all files on the fat volumes are executable. So, either thttpd or it config should be adjusted to check for file extension or particular directory, or alternatively you could switch to ext3 filesystem.
You're going far on this one Oleg :D
Use this command instead to run thttpd from sbin folder:
./thttpd -C ../etc/thttpd.conf -c /cgi-bin/*
Problem is the cgipat variable not set up in thttpd.conf
This team is working great, but most of the site library are in PHP4. I will wait for your try in compiling V4 or try it myself out of despair ;-)
erik_bies
05-01-2005, 21:55
if you want to compile it for yourself, you need to build it statically with uClib from CVS. Than apply the paches for dns.c & remove the problems with testing in ./configure
uClib that is standard for the WL500g supplied won't work cuz of missing functions (e.g. in dns.c)
Unfortunately I'm still struggling to get a decent new up2date toolchain working. For the rest it should comile without many problems. Oh you need to take an older version of thhtpd as the most recent version (ahum dec 2003) is not supported.
haha, my last try ended this way :eek: :confused:
gcc -IZend/ -I/usr/local/root/php-4.3.9/Zend/ -DPHP_ATOM_INC -I/usr/local/root/php-4.3.9/include -I/usr/local/root/php-4.3.9/main -I/usr/local/root/php-4.3.9 -I/usr/local/root/thttpd-2.21b -I/usr/local/root/php-4.3.9/Zend -D_XPG_IV -I/usr/local/root/php-4.3.9/TSRM -g -O2 -c /usr/local/root/php-4.3.9/Zend/zend_execute.c -o Zend/zend_execute.o && echo > Zend/zend_execute.lo
gcc: Internal error: Terminated (program cc1)
Please submit a full bug report.
See <URL:http://gcc.gnu.org/bugs.html> for instructions.
make: *** [Zend/zend_execute.lo] Error 1
This looks ugly. What about trying to staticaly link it to glibc (using mipsel-linux toolchain from firmware?) I've had good result for my xmail project, where the uclibc where insuficient.
Also the -IZend/ looks strange, if not worst. Where is this folder come from? is it a cutted path?
erik_bies
05-01-2005, 22:06
This looks ugly. What about trying to staticaly link it to glibc (using mipsel-linux toolchain from firmware?) I've had good result for my xmail project, where the uclibc where insuficient.
the result is an enormous file. I did it first with the PHP3, I believe it resulted in a 3MB file dynamically! linked vs 700k static linked uClib.
1 sec, I'll give it a try and let u know.
also read my edited comment about -IZend/
erik_bies
10-01-2005, 23:31
Ok, here is a working minimal build of the PHP4 enabled thhtpd
The extensions are mostly disabled now, I'll see if I can build one that is more 'feature enabled'
Yummy. Going to test this... Thanks Erik
Scoundrel
11-01-2005, 14:44
THTTPD works fine... :-)
Which PHP commands are implemented? (The PHP echo is correct! ;-))
SC
Most command are working.
Funnily, preg_replace() doesn't, even if other text replace command do :confused:
erik_bies
11-01-2005, 21:33
Ok and here is the (almost)full version.
For me to sucessfully run it I have to add some swap space
With this one I sucessfully run some of the nice scripts like Gallery & phpsysinfo
Good luck
It is working fully for me. Even without swap space... Thanks for this Erik
I can run guppy PHP server as frontend on the WL-hhd. Thats cool for testing and debugging.
Scoundrel
12-01-2005, 09:40
It works me too. Thanks for creators... :)
Here is a modified script to get HD info under phpsysinfo. You must replace the corresponding file in /include/os in your phpsysinfo root
Scoundrel
12-01-2005, 11:58
I tried the modified script. Correct!!! :)
It seems the more we have, the more we want. I Would like to add some libs. Did you have to modify your source? or was it a makefile optimisation story?
Would you mind giving here your make info to add our own libs to the process?
Gerrit2K
12-01-2005, 20:15
I gave it a try and compiled these.
Here is PHP3 & thttpd (without PHP4). I'll give the thttpd+php4 combi another try later, but sofar that resulted in a long list of errors
For me it is working on 1.9.2.7-2 software.
Good luck
How do I install this?
I use Firmware v.1.9.2.7 CR3
copy it to router using ftp, run it using telnet
something like ./thttpd-php4f_2.21b-2_mipsel -p 81 -d yoursourcefolder
put some php files in the source folder, give them enough rights (get up stand up!) and learn how to use php.
erik_bies
12-01-2005, 23:23
take the config file out of the PHP3 package
than take the thhtpd+PHP4 file.
edit the script with your desired directories. dump some files in the www directory (from config file)
run
thttpd -C thttp.conf
make sure ur running it on a port different from port 80
It seems the more we have, the more we want. I Would like to add some libs. Did you have to modify your source? or was it a makefile optimisation story?
Would you mind giving here your make info to add our own libs to the process?
there is a small change in the dns.c, and fiddeling with makefiles for the remaining. I'll try to dig up and make a wiki page
BTW. thanks for the patch of the Linux.inc.php file. Do you maybe know why it does not want to see the 2nd file system?
It it shown using a mount command?
Hmm, I'm giving phpsysinfo (2.3) a try and I get the following error:
Error: Linux is not currently supported
Any ideas?
This version is working fully on my box. Most of the script is using system command. If some are unavailable, it won't be able to run. Do you have any specific firmware?
Oh, yes, I forgot: 1.8.1.7 CR3. I'm not running from rootfs. I did see Oleg upped 1.9.2.7 CR3b on which I was waiting, so I'll be happy to upgrade.
It has been tested on the latest Oleg firmware, so yes it should work.
Still no luck :o
Here's what I've done so far:
- Upgraded to latest custom firmware 1.9.2.7 CR3b from Oleg (ofcourse :))
- Created an ext3 partition on my HDD, initialized it and mounted it on /tmp/extra:
mkdir /tmp/extra
mount -o rw /dev/scsi/host0/bus0/target0/lun0/part5 /tmp/extra
- Then I've copied the first build from erik_bies (the one with the subdirectories) to the ext3 partition and updated the thttpd program with the latest build with PHP4 support.
- I changed the rights of several directories:
drw-r--r-- 2 admin nobody 1024 Jan 15 15:23 etc
drwx------ 2 admin root 12288 Jan 15 00:26 lost+found
drw-r--r-- 3 admin nobody 1024 Jan 15 15:23 man
drw-r--r-- 2 admin nobody 1024 Jan 15 15:23 sbin
drwxr-xr-x 4 admin nobody 1024 Jan 15 15:23 www
I've noticed that the /www directory needs execute priviledges, otherwise the webserver will report an '500 - internal server error'.
- I copied phpsysinfo-dev into the /www directory and also into the /www/cgi-bin directory.
drwxr-xr-x 3 admin nobody 1024 Jan 15 15:28 cgi-bin
-rw-r--r-- 1 admin nobody 323 Jan 4 00:30 index.html
drwxr-xr-x 5 admin nobody 1024 Jan 15 15:42 phpsysinfo-dev
- I've renamed the config.php.new to config.php
When I request the index.html page it says:
If you see this you are sucessfully running thttpd on wl500x
When I request the phpsysinfo page (http://wl500g:81/phpsysinfo-dev) it says:
Error: Linux is not currently supported
Also when I request the same page from cgi-bin (http://wl500g:81/cgi-bin/phpsysinfo-dev) it says the same as above.
I've also written a test php script which I placed into the /www and the /www/cgi-bin folder, and in both cases the script worked perfect (Hello World).
My conclusion so far is: PHP is running fine, I only need some extra stuff for phpsysinfo. Any ideas what might cause the phpsysinfo to report the error?
Styno:
I had the same problem with phpsysinfo that it said that Linux was not supported.
The problem was that phpsysinfo looks for a file called class.Linux.inc.php in sysinfo/includes/os/
I had that file but with a lowercase L in the word class.Linux.inc.php.
Moved the file with
mv class.linux.inc.php class.Linux.inc.php
and it worked fine after that.
Hope this will work for you too.
The problem was that phpsysinfo looks for a file called class.Linux.inc.php in sysinfo/includes/os/
I had that file but with a lowercase L in the word class.Linux.inc.php.
Yep, that was my problem too, among with some other files who were also lowercase. It's because I copied the files through a SAMBA share (which converts every file/dir to lowercase) that I had this problem.
So to everyone: Do not unpack the files to a SAMBA share, because it will break the website.
Thanks Jaap!
Starting with 1.9.2.7-3 samba preserves file case (i.e. required options are set in the config file).
FYI
By default thttpd is trying to load whole page to memory before sending it to client. This means that kernel will kill it, when somebody wants to download any huge file from your web.
But it can be changed! Look for following lines in configure script:
> if test "$cross_compiling" = yes; then
> ac_cv_func_mmap_fixed_mapped=no
WL500g CAN do mmap, so you can set ac_cv_func_mmap_fixed_mapped to yes.
Then thttpd only memory-maps file and big files are served without impact on free memory.
Friend compiled it for me, but without PHP.
Blackfire
25-01-2005, 20:43
where does it go wrong with me ??
When i install the thttpd with php is works great on *.html and *.php
After rebooting my wl500g
and start the ./thttpd -C ../etc/thttpd.conf -c /cgi-bin/* again
i get this on *.html :(
403 Forbidden
The requested URL '/' resolves to a file which is marked executable but is not a CGI file; retrieving it is forbidden.
*.php still works fine.
You will have to do a chmod -x on all html files. Also the filesystem needs to be ext2 or ext3 (on FAT filesystems all files have execute rights).
Blackfire
26-01-2005, 14:09
ok thank you styno
chmod is no probleem
only thing is that i have only windows xp running and can't format too ext2 or ext3.
Is it possible to format it on the wl500g itself ?
thanks too all
Yes, the newer firmwares from Oleg allow you to format ext2 and ext3 partitions. Don't know if there is a tool present to create those partitions though, but you can use Ranish partition manager (freeware) for that.
Check this thread: http://wl500g.info/showthread.php?t=1518
Yes, the newer firmwares from Oleg allow you to format ext2 and ext3 partitions. Don't know if there is a tool present to create those partitions though, but you can use Ranish partition manager (freeware) for that.
Check this thread: http://wl500g.info/showthread.php?t=1518
In recent Oleg's firmwares is FDISK applet present (as part of Busybox) so you don't need any external application. :)
Hello,
Hello i have some problem to acces some file with this web server.For exemple if i try to see a jpg or gif file i obtain an error witch say 403 Forbiden this file is executable but not containing a CGI scipt.
I have made all the file executable.
ThX :eek:
Hello,
Hello i have some problem to acces some file with this web server.For exemple if i try to see a jpg or gif file i obtain an error witch say 403 Forbiden this file is executable but not containing a CGI scipt.
I have made all the file executable.
ThX :eek:
Chmod -x the .jpg file.
Hello,
I have thttpd with php by erik_bies (thttpd-php4f_2.21b-2_mipsel - the latest one from this forum) up and running on my wl500b (1.9.2.7-3c). Everything works quite well, but if I try this:
<form action="test.php" method="post">
<input name="test" type="text">
<input type="submit">
</form>
<?
echo $test;
?>
variable $test remains empty after post (get). Any ideas?
Thanks
Scoundrel
07-02-2005, 18:13
Nabla,
try this:
<form action="test.php" method="post">
<input name="test" type="text">
<input type="submit">
</form>
<?
echo $_GET['test']
?>
Scoundrel
07-02-2005, 19:25
The aswer has been sended by private message to you...
It seems clear to me that this topic is not intended for all basic PHP language questions. Further basic language questions will be trashed/deleted.
For PHP language questions visit: www.php.net or use Google.
Sorry, I supposed that it was question related to thttpd+php behavior.
Next time I'll better keep quiet.
Sorry, I supposed that it was question related to thttpd+php behavior.
Next time I'll better keep quiet.
I was not responding directly to you, but just posted a general 'warning'. :)
Yesterday I installed the thttp+PHP4 (thttpd-php4f_2[1].21b-2_mipsel.zip) on my Asus. It works really great! I want to thank Erik_Bies for the effort.
There is only a small issue with this version of thttp . It loads the complete webpage/file into memory before sending abroad. Serving huge files (like zip files of > 50MB in size) from the Asus becomes a problem this way because of lack of memory (even with 32 Mb swap space :eek: ) .
According to YATO there is solution for this (as decribed below):
-------------------------
Yato
--> mmap v thttpd <--
FYI
By default thttpd is trying to load whole page to memory before sending it to client. This means that kernel will kill it, when somebody wants to download any huge file from your web.
But it can be changed! Look for following lines in configure script:
> if test "$cross_compiling" = yes; then
> ac_cv_func_mmap_fixed_mapped=no
WL500g CAN do mmap, so you can set ac_cv_func_mmap_fixed_mapped to yes.
Then thttpd only memory-maps file and big files are served without impact on free memory.
Friend compiled it for me, but without PHP.
---------------------
Who is able to recompile the project with this flag/setting enabled. I would really appreciate it. It will make the thttpd more versatile.
I am using Busybox_httpd at this moment. It can serve huge pages, but it does not support PHP4. Thttpd would be the ideal solution.
Thanx in advance for effort ;-)
Can you send me ipk package, i want too php in my Asus.
thx
sohottoday
26-02-2006, 17:40
hi erik_bies ..
can u share your thttpd-php compile script? thx..
It has been discussed before but no solution has been posted.
I seem to have the same problem with the latest php-thttpd packages (2.25b+php5.0.4) as posted by NABLA on my wl500g.
Whatever I do I cannot post form information, but the get method works fine. I assume it has something to do with header parsing by the thttpd server since it seems that the server never starts to process the php script called by the form. Anyone have a solution?
Strange enough it sometimes works if i restart the server several times with the S80 script in /opt/etc/init.d although not very stable.