PHP for PirateBox

Posted by Matthias 
This forum is currently read only. You can not log in or make any changes. This is a temporary situation.
Now, this forum is in read-only mode. You find details Details hereContinue on /r/PirateBox
PHP for PirateBox
June 10, 2012 10:52AM
I added the instruction for creating PHP support for PirateBox. [piratebox.aod-rpg.de]
Can someone check if this is working for him ( it tested it, but I don't used a PHP Based application like "dokuwiki" for testing).

Thank you smiling smiley
Matthias
Re: PHP for PirateBox
June 11, 2012 01:55AM
grinning smiley ill check...
Re: PHP for PirateBox
June 11, 2012 02:23AM
it keeps saying no space left on device
Re: PHP for PirateBox
June 11, 2012 04:50AM
I installed my php on a relative fresh installed PirateBox and I was able to install a bunch of modules, too.
Can you please post your results of
df -h
That I can confirm, that you have the correct /mnt/ext "disc" size. Maybe you didn't overwrite it correctly or you have bunch of chunk installed in your extent-image... maybe you have to clean something up (by hand or with a reinstall)

Matthas
Re: PHP for PirateBox
June 12, 2012 09:04PM
Re: PHP for PirateBox
June 13, 2012 05:35AM
Kenshen, you are doint it wrong.
you have to use:

opkg -d piratebox install php

then the install is redirected to /mnt/ext.

best regards
Matthias
Re: PHP for PirateBox
June 13, 2012 12:31PM
no problem at all on install it works as a charm great !!!! Thanks Matt !thumbs up
Re: PHP for PirateBox
June 13, 2012 01:07PM
Re: PHP for PirateBox
July 12, 2012 01:39PM
Here is some other change to make:

In /opt/piratebox/conf/lighttpd/lighttpd.conf:

change
static-file.exclude-extensions = ( ".php",".pl", ".fcgi" , ".cgi" , ".py" )
to
static-file.exclude-extensions = ( ".pl", ".fcgi" , ".cgi" , ".py" )

In /etc/php.ini

change
doc_root = "/www"
to
doc_root = "/opt/piratebox/www"

Now php work fine ! thumbs up
Re: PHP for PirateBox
July 12, 2012 07:17PM
Hi,
fine!
Thank you for feedback, I added it to to modification list

Matthias
Re: PHP for PirateBox
July 16, 2012 09:11AM
Now... let's try to make an index.php that support multi-language
Re: PHP for PirateBox
July 18, 2012 09:51PM
Index.php work fine with multi language.
Soon the code to make it winking smiley
Re: PHP for PirateBox
August 04, 2012 01:28PM
Index.php with multilanguage:

after install of php and other modification specified here

modifiy the file "/opt/piratebox/conf/lighttpd/lighttpd.conf":

$HTTP["url"] =~ "^/php/" {
cgi.assign = ( ".php" => "/usr/local/bin/php-cgi" )
}


to be
$HTTP["url"] =~ "^" {
cgi.assign = ( ".php" => "/usr/local/bin/php-cgi" )
}


I hope this will help some of you...

it's to 'php' be available from your '/'

1) rename your index.html file in "index.php"
with just that, you can verify that everything work fine.

2) create a new directory "lang" in /opt/piratebox/www"
in this new directory, create a file "en-lang.php"

your language file look like

<?php

$menu1 = "About PirateBox";
$menu2 = "...";
...
?>


3) edit your index.php
add at the beginning:

<?php
// enable this line if you add php-mod-session
//session_start();

//--- set default language ---------
$default_language = 'en';
if(isset($_GET['lang']) ) $lang = $_GET['lang'];

// enable this line if you add php-mod-session
//else if (!empty($_SESSION['lang'])) $lang = $_SESSION['lang'];

else $lang = (substr($_SERVER['HTTP_ACCEPT_LANGUAGE'], 0, 2));

//modifiy this line if you add other file
if ($lang <> "en") $lang = $default_language;

//---choose language file ---------------
include('lang/'.$lang.'-lang.php');

// enable this line if you add php-mod-session
//$_SESSION['lang'] = $lang;
?>


And for each text you want to be multilanguage, replace it buy:
<?php echo $menuXX; ?>

now you can create several language file like:
fr-lang, it-lang ...
Re: PHP for PirateBox
August 17, 2012 01:43PM
Pharaon, thanx for the code. I'll try to create multilanguage myself

multilanguage support
Re: PHP for PirateBox
December 22, 2012 07:02PM
I installed piratebox in a TP-Link mr3020. Everything works great. I want to install PHP to use h5ai (http://larsjung.de/h5ai/) to have a better design. I could see php5 package in opkg repositories, but I don't exactly which version (cli, cgi) could be better for this use.

Thanks!
Re: PHP for PirateBox
December 22, 2012 10:32PM
Have a look at this page: [piratebox.aod-rpg.de]

There are hints what to do
Re: PHP for PirateBox
March 22, 2013 12:12AM
... No tutorial for PHP on Piratebox und your modification list any more. :*(
Re: PHP for PirateBox
March 22, 2013 06:01AM
Hi,
it is, it is only splitted [piratebox.aod-rpg.de]?
Re: PHP for PirateBox
April 05, 2013 02:25PM
Did you get h5ai working?

I have PHP up and running and can run a phpinfo() page and get the php config so I know it is working.. I have tried the Lighttp Directory mod instructions posted in the "hints" page and have also tried to get h5ai working, but have been unsuccessful with both of them.

Has anyone succeeded in getting something running that delivers a little nicer "Shared" file listing?
Re: PHP for PirateBox
April 05, 2013 04:27PM
check "/opt/piratebox/tmp/break.log or /opt/piratebox/tmp/error.log" - maybe you need additional php-modules installed.

just be a short code-review, you'll need at least:

php5-mod-json
php5-mod-gd



Edited 1 time(s). Last edit at 04/05/2013 04:33PM by Matthias.
Re: PHP for PirateBox
December 27, 2015 01:39PM
can you please add the instruction again for installing PHP for PirateBox.

Thanks, mayank
Re: PHP for PirateBox
December 27, 2015 10:16PM
[piratebox.cc]


This is only my signature.
Re: PHP for PirateBox
December 28, 2015 12:08PM
Thanks for your reply !
I am getting below error while installing PHP in Piratbox for below command:

root@piratebox:~# opkg -d ext install extendRoot-php lighttpd-mod-fastcgi
Unknown package 'extendRoot-php'.
Unknown package 'lighttpd-mod-fastcgi'.
Collected errors:
* opkg_install_cmd: Cannot install package extendRoot-php.
* opkg_install_cmd: Cannot install package lighttpd-mod-fastcgi.


Another issue while enabling piratebox for getting the internet for piratebox for below command i am getting uci: Entry not found
uci set network.wan.ifname=$( uci get network.lan.ifname )
uci: Entry not found
uci set network.wan.macaddr=$( uci get network.lan.macaddr )
uci: Entry not found

Please help.

Thanks, mayank
Re: PHP for PirateBox
December 28, 2015 06:35PM
Read carefully, you need to make your Box internet-access-possible... if you do it wrong or forget "opkg update" it can't find any packages.

If you didn't choose PirateBox because of anonymity reasons you might be interested into LibraryBox, which comes with PHP preinstalled & configured.

regards
Matthias


This is only my signature.
Re: PHP for PirateBox
February 28, 2016 11:41AM
i have installed piratebox on mr3020 .
i want to add php in it i have connected my router on my laptop and as it requires internet i try to do stepa that ARE mentioned in piratebox.cc .......i m unable to do it correctly .....i have an internet with wifi on my pc and when i do that steps error comes.....like uci:entry not found ...can any1 plz help me with ss or proper guide plz.
Re: PHP for PirateBox
January 28, 2018 04:21AM
You also need to add the following line at the end of your lighttpd.conf file:

fastcgi.map-extensions = ( ".html" => ".php" )

This allows you to put php code into an html file, like for instance:

<?php echo "Hello World"; ?>
Re: PHP for PirateBox
January 29, 2018 04:38AM
Bill B Wrote:
-------------------------------------------------------
> You also need to add the following line at the end
> of your lighttpd.conf file:
>
> fastcgi.map-extensions = ( ".html" => ".php" )
>
> This allows you to put php code into an html file,
> like for instance:
>
> <?php echo "Hello World"; ?>


Mmmm... I dont think php will execute inside an html container. Usually php is used to build the html code.

Edit: I stand corrected.


PirateBox Installs:
2x Zsun's (both testing, one with serial interface)
A5-V11 (mostly for OpenWRT testing DIY)
2x RPi Zero's
(one active in car 24/7, gets a lot of hits at Walmart, movie theaters and the mall)
2x RPi3's (both home servers, one Ubuntu custom install along side a ton of other services)
1x RPi2 (currently work server)



Edited 1 time(s). Last edit at 01/29/2018 04:41AM by TheExpertNoob.