[APP] php 5.4.2 + lighttpd 1.4.29 in FCGI mode, crosscompiled for ARM

Search This thread

viulian

Inactive Recognized Developer
Apr 6, 2011
419
411
hex.ro
Update 7 May 2012: New version released, containing PHP 5.4.2 with curl / openssl modules built in (still for armv5). Besides the version number, installation steps remain the same.

Introduction

The web page of the project, containing more information, licenses, configuration fils, list of modules for php and lighttpd, etc is here:
http://hex.ro/wp/blog/php-and-lighttpd-for-android/

It also contains and example, how to install SMF forum onto the phone :)

Download

This comes with NO WARRANTY. Use it at your own risk!

php-5.4.2_lighttpd_1.4.29_armv5.tar.gz

php-5.3.8_lighttpd_1.4.29_armv5.tar.gz

Installing

After you copy the archive above into the root of your SD Card, installation is easy:

Code:
cd /
tar xf /sdcard/php-5.3.8_lighttpd_1.4.29_armv5.tar.gz
reload-fcgi.sh
reload-lighttpd.sh

Make sure you are on the root file system (/) before executing tar command.

Also, mandatory: rooted phone + busybox + /system partition mounted read only.

Below information is older - which was before the bundle was ready

Coming soon:

(excerpt from phpinfo() now running on my phone)

PHP:
System 		Linux localhost 2.6.32.9-perf #1 PREEMPT Fri Jul 8 13:45:08 2011 armv7l
Build Date 	Aug 30 2011 22:07:32
...
PHP Version						5.3.8 
...
Server API							CGI/FastCGI
Virtual Directory Support			disabled
Configuration File (php.ini) Path	/system/etc/php
Loaded Configuration File			/system/etc/php/php.ini 
...
_SERVER["_"]	/system/bin/php
_SERVER["FCGI_ROLE"]	RESPONDER
_SERVER["SERVER_SOFTWARE"]	lighttpd/1.4.29
_SERVER["SERVER_NAME"]	192.168.1.3
_SERVER["GATEWAY_INTERFACE"]	CGI/1.1

I have managed to compile lighttp 1.4.29 with fcgi support as well as php 5.3.8 (both latest version).

All graphics libraries are in as well as SQLite.
I will still have to play with OpenSSL to get it running. Maybe MySQL in the future :D

It will take a while to set everything up (a web page for source code, wiki on how to install), but we're close to have a fuller Linux experience on Android powered phones.
 
Last edited:

viulian

Inactive Recognized Developer
Apr 6, 2011
419
411
hex.ro
Thank you for the kind words :)

Yes, everything works now, and I've tried out a PHP gallery as well as PHP file editor (so you can edit .php files within Opera connected to local host).

It works. Unfortunately, on my Arc, it takes about 3 seconds to generate a thumbnail of a camera image. Now I understand why the whole thing with Media Server indexing files first time after reboot, when phone is slow and etc .. and why the need that apps have to notify Media Server to index additional files when apps create them. So by the time user gets to open the gallery, their thumbnails are already there (it masks the delay).

I want to try out more scripts and then create an installer for the whole thing. If members here report it works, then I will upload it to the market.
 

Adolf1994

Senior Member
Jun 2, 2010
411
65
Fertőrákos
I think I will try a bunch of forum engines.
How many additional modules will there be? ImageMagik is really useful… or at least GD :p

EDIT: ohh, didn't see OP says all graphic libraries included (^_^; )
 
Last edited:

krzych

Senior Member
Jul 29, 2009
1,141
301
Warsaw
Thank you for the kind words :)
We should thank you for your efforts. And we are.

I want to try out more scripts and then create an installer for the whole thing. If members here report it works, then I will upload it to the market.
You can count on me. I'm not a full time PHP developer, but I wrote few little "systems" in "my way" so it should test non-standard approach at least. but I believe you've already tested basic PHP behaviour ;)

By the way - you mentioned something about mysql... I would personally prefer PostgreSQL, but I do not know anything about a way it's written so theoretically it can be harder to move to arm platform. Postgres is more flexible in many ways, and sometimes (I've heard) a way faster because of simplicity of mysql.

But if anything will be problematic with sql, I can always fall back to sqlite ;)
 
Last edited:

viulian

Inactive Recognized Developer
Apr 6, 2011
419
411
hex.ro
Update:

libcurl won't be bundled (PHP will be compiled without --with-curl argument).

It seems that libcurl has a dependency on libc - and it tries to load libc.so causing php executable to crash.

Output from strace:

Code:
open("/system/lib/libc.so", O_RDONLY)   = 3
fstat(3, {st_mode=S_IFREG|0644, st_size=273912, ...}) = 0
close(3)                                = 0
--- {si_signo=SIGSEGV, si_code=SEGV_MAPERR, si_addr=0xfde0004} (Segmentation fault) ---
+++ killed by SIGSEGV +++
Segmentation fault
 

Adolf1994

Senior Member
Jun 2, 2010
411
65
Fertőrákos
that's really sad. cURL is sooo cool. (´Д`)
but so far you always found a way to make things work and I hope the same will apply to this as well.
If you have an idea that would work, then will this released later? or you let us play with the cURL-less boundle? :D
 

krzych

Senior Member
Jul 29, 2009
1,141
301
Warsaw
I won't mind lacking of cURL. We have wget onboard for simple downloads. For more sophisticated actions android isn't the best platform ;)
 

viulian

Inactive Recognized Developer
Apr 6, 2011
419
411
hex.ro
Here's the info.php generated using lighttpd / php statically built for Android:

info.php.zip

I've been on a trip with limited access to internet, and so far I managed to find a fix for lighttpd which, when statically built, would not load the modules in the correct order. It was a mess to use :) I've documented it here: http://redmine.lighttpd.net/issues/2343

ImageMagick is not ported yet (just standard gd as you will see). I'm tempted to port ImageMagick also, since it seems that batch operations are faster with it than with the built in gd (and on my Arc, generating the thumbnail of a camera taken photo takes about 3 seconds, which is slow).

So far I've tested fotogallery and monoedit (to edit php files on the phone using any browser) and they work fine.

Please expect updates :) soon.
 
  • Like
Reactions: Adolf1994

viulian

Inactive Recognized Developer
Apr 6, 2011
419
411
hex.ro
I've just managed to cross-compile ImageMagick for Android, and it takes mogrify about 4.2 seconds (on my Arc) to create a 120x90 px thumbnail for a 1.8Mb photo from the camera.

Code:
[root@arc]/sdcard/DCIM/100ANDRO# time mogrify -path thumbs -thumbnail 120x90 DSC_0172.jpg

real    0m4.176s
user    0m3.950s
sys     0m0.130s

Also, each executable has about 5.3Mb when statically linked (convert, mogrify, etc...) which makes the ImageMagick bundle to around 57Mb in total (which is huge).

Thus, no ImageMagick for now :) waiting for better hardware.
 

viulian

Inactive Recognized Developer
Apr 6, 2011
419
411
hex.ro
:) I'm working on a web page on my blog where I'll present everything - and will post an update here. If not later tonight, then tomorrow I'll release it.

For now it is compiled for armv5 CPUs (meaning it will work on many phones, even older and slower ones). I've tested it on a Sony X10 Mini (MSM7227, 600Mhz, ArmV5) and Sony Arc (MSM8255, 1Ghz, ArmV7) and works a treat!

Also installed SMF (Simple Machines Forum with sqlite) and it works.
 
  • Like
Reactions: krzych

dateno1

Senior Member
Oct 15, 2010
217
45
i think max request size is too small :(

it will make 413 error when try to attach file :(

default value is 2Gb but i think viulian set too small value (even i can't attache 250kb jpg :mad:)

if someone want to increase it

add this lines on your lighttpd.conf
server.max-request-size=10240
server.network-backend=”writev”
server.upload-dirs=( “/sddata/www/tmp” )


size=kb
dirs=must same as upload_tmp_dir on your php.ini

there are my config files
 

Attachments

  • conf.zip
    22.3 KB · Views: 15
Last edited:
  • Like
Reactions: viulian

viulian

Inactive Recognized Developer
Apr 6, 2011
419
411
hex.ro
Thank you for the updates :)

Both php and lighttpd come with the default values - I did not change anything ... (in an attept to offer as much as possible the Linux experience with them, when you have to reconfigure things).

The only change I did was to set the temp folder for php to /data/local/tmp (although your suggestion to use the /sdcard might work out better in case of a lot of uploads since the /data space is limited compared to /sdcard).
 

dateno1

Senior Member
Oct 15, 2010
217
45
i also think sdcard is better but /sdcard can't save permission and ownner

it's big secure hole :(

i think sd-ext is best
 

Top Liked Posts

  • There are no posts matching your filters.
  • 8
    Update 7 May 2012: New version released, containing PHP 5.4.2 with curl / openssl modules built in (still for armv5). Besides the version number, installation steps remain the same.

    Introduction

    The web page of the project, containing more information, licenses, configuration fils, list of modules for php and lighttpd, etc is here:
    http://hex.ro/wp/blog/php-and-lighttpd-for-android/

    It also contains and example, how to install SMF forum onto the phone :)

    Download

    This comes with NO WARRANTY. Use it at your own risk!

    php-5.4.2_lighttpd_1.4.29_armv5.tar.gz

    php-5.3.8_lighttpd_1.4.29_armv5.tar.gz

    Installing

    After you copy the archive above into the root of your SD Card, installation is easy:

    Code:
    cd /
    tar xf /sdcard/php-5.3.8_lighttpd_1.4.29_armv5.tar.gz
    reload-fcgi.sh
    reload-lighttpd.sh

    Make sure you are on the root file system (/) before executing tar command.

    Also, mandatory: rooted phone + busybox + /system partition mounted read only.

    Below information is older - which was before the bundle was ready

    Coming soon:

    (excerpt from phpinfo() now running on my phone)

    PHP:
    System 		Linux localhost 2.6.32.9-perf #1 PREEMPT Fri Jul 8 13:45:08 2011 armv7l
    Build Date 	Aug 30 2011 22:07:32
    ...
    PHP Version						5.3.8 
    ...
    Server API							CGI/FastCGI
    Virtual Directory Support			disabled
    Configuration File (php.ini) Path	/system/etc/php
    Loaded Configuration File			/system/etc/php/php.ini 
    ...
    _SERVER["_"]	/system/bin/php
    _SERVER["FCGI_ROLE"]	RESPONDER
    _SERVER["SERVER_SOFTWARE"]	lighttpd/1.4.29
    _SERVER["SERVER_NAME"]	192.168.1.3
    _SERVER["GATEWAY_INTERFACE"]	CGI/1.1

    I have managed to compile lighttp 1.4.29 with fcgi support as well as php 5.3.8 (both latest version).

    All graphics libraries are in as well as SQLite.
    I will still have to play with OpenSSL to get it running. Maybe MySQL in the future :D

    It will take a while to set everything up (a web page for source code, wiki on how to install), but we're close to have a fuller Linux experience on Android powered phones.
    2
    I was wondering if you guys have seen Botbrew? It has lightpad and imagemagick, along with curl, gcc, python, ruby, git, subversion...

    It's pretty cool and is looking at some of the same things you are.

    the dev is about to release Botbrew +1, with a debian chroot INSIDE android, giving you access to basically the whole debian library. From what I understand, there will have to be some custom runit scripts written on an as-needed basis for some of sections of the debian package library to be usable, but it is going to be done on a piecemeal basis until everything is available.

    Here is the Botbrew thread

    And here is the thread for Pengdroid, the debian distro that will be incorporated for the jump to Botbrew +1

    I'm not trying to divert or show up the project, just show you a new resource. inportb, the dev behind it, really couldn't be nicer or more supportive of proects just like yours. I'm sure he'd be interested to see what you've come up with so far.
    1
    Here's the info.php generated using lighttpd / php statically built for Android:

    info.php.zip

    I've been on a trip with limited access to internet, and so far I managed to find a fix for lighttpd which, when statically built, would not load the modules in the correct order. It was a mess to use :) I've documented it here: http://redmine.lighttpd.net/issues/2343

    ImageMagick is not ported yet (just standard gd as you will see). I'm tempted to port ImageMagick also, since it seems that batch operations are faster with it than with the built in gd (and on my Arc, generating the thumbnail of a camera taken photo takes about 3 seconds, which is slow).

    So far I've tested fotogallery and monoedit (to edit php files on the phone using any browser) and they work fine.

    Please expect updates :) soon.
    1
    :) I'm working on a web page on my blog where I'll present everything - and will post an update here. If not later tonight, then tomorrow I'll release it.

    For now it is compiled for armv5 CPUs (meaning it will work on many phones, even older and slower ones). I've tested it on a Sony X10 Mini (MSM7227, 600Mhz, ArmV5) and Sony Arc (MSM8255, 1Ghz, ArmV7) and works a treat!

    Also installed SMF (Simple Machines Forum with sqlite) and it works.
    1
    i think max request size is too small :(

    it will make 413 error when try to attach file :(

    default value is 2Gb but i think viulian set too small value (even i can't attache 250kb jpg :mad:)

    if someone want to increase it

    add this lines on your lighttpd.conf
    server.max-request-size=10240
    server.network-backend=”writev”
    server.upload-dirs=( “/sddata/www/tmp” )


    size=kb
    dirs=must same as upload_tmp_dir on your php.ini

    there are my config files