OpenWrt Forum Archive

Topic: php on WRTG54GL

The content of this topic has been archived on 19 Apr 2018. There are no obvious gaps in this topic, but there may still be some posts missing at the end.

hi all

i would like to run php on openWRT (WRTG54GL). i read the how-to at https://forum.openwrt.org/viewtopic.php?id=10330 but the WRT54GL does no have enough flash space to install lighthttpd and all the php files (opkg install lighttpd lighttpd-mod-cgi php5 php5-cgi). Is there another possibility to run php on a WRTG54GL? (php4 is okay too)

i would be happy if someone could help me.

Hi!

Look at this thread for information on using php cgi with the busybox httpd. This way you don't have to install lighttpd. Not sure if that saves enough space though. You could try compiling an image with php already included, that way you get better compression. Also, the php4 package is about half the size of php5, [s]if you're not using any php5 features[/s]. edit: sorry, didn't read your post thoroughly enough, I see sou mention php4 is sufficient

(Last edited by deaday on 18 Aug 2009, 23:31)

hi deaday,

i tried that, but if i want to display a php file i get a blank page. (I do no get an error, it looks like that the httpd does interpret the page somehow. if i remove the line *.php:/usr/bin/php the php file becomes displayed like a normal txt-file.

are there no more configuration parameters? i only change the doc_root in php.ini and add the following line *.php:/usr/bin/php to httpd.conf before i start httpd -p 81 -c /etc/httpd.conf

if you're running low on memory, you may want to try to mount some more space using sshfs?

exactly this memory issue is why I'm not buying a WRT54 from linksys. a usb port or two would make it much easier to install additional memory by plugging in a usb stick or usb HD. for this device its up to you to setup a network fs.

I hope this helps.

(Last edited by NachbarsLumpi on 19 Aug 2009, 18:11)

Hi!

Have you tried adding the following line to /etc/php.ini:

cgi.force_redirect = 0

That did the trick for me.

I'll recount the steps I took:

opkg update
opkg install php4-cgi
echo "*.php:/usr/bin/php" > /etc/httpd.conf
echo "cgi.force_redirect = 0" >> /etc/php.ini
/etc/init.d/httpd restart

(Last edited by deaday on 19 Aug 2009, 21:37)

wow cool, it works now smile
thank you very much!

Hi,

I tried all i sexplained here.
For this I let the luci httpd settings to the port 80.
Due to not enough space I installed PHP on the USB key.

I followed these instructions :
Add the following line to /etc/httpd.conf:
Code:
*.php:/usr/bin/php

Restart httpd:
Code:
/etc/init.d/httpd restart

TO USE A DIFFERENT WWW place I created a WWW on the US Key and I followed the instructions by :
Create a file, phpinfo.php in /www/cgi-bin with the following:
Code:
<?php
phpinfo();
?>

I also installed a simple index.html on the /www (USB Key)

I also followed the instruction by adding :
cgi.force_redirect = 0
cgi.redirect_status_env ="yes";

On the php.ini which is on the USB Key.

I also (personnaly) added those lines in the /etc/config/httpd file :
option 'port'    '81'
option 'home'  '/mnt/usbdrive-1/www'

I also do httpd -p 81 -c /etc/httpd.conf (explained by sn4ke in https://forum.openwrt.org/viewtopic.php?id=21450).

1) The problem is when I use this URL (http://192.168.1.1:81) it well display my index file but directly goes (automatically) to http://192.168.1.1:81/cgi-bin/luci by giving a 404 not found error.
2) The seond problem is I can find the /usr/bin/php which is used in the httpd.conf (I searched in the / of the router and also on the USB Key). I can't find it. And PHP5 is well installed :
php5 - 5.2.6-2 -
php5-mod-mysql - 5.2.6-2 -
php5-mod-session - 5.2.6-2 -
php5-mod-xml - 5.2.6-2 -


Can somebody tell me what to do to give the correct php in the httpd.conf ? And how to keep displayed my index file without going to the  http://192.168.1.1:81/cgi-bin/luci

Sincerely thanks and have a nice day.

Miguipda ;-)

can you post the contents of the index file at '/mnt/usbdrive-1/www'

this is just a guess, doesn't this line redirect to cgi-bin/luci

<meta http-equiv="refresh" content="0; URL=/cgi-bin/luci" />

(Last edited by gTumba on 11 Jan 2010, 00:56)

The discussion might have continued from here.