WelcomeWelcome | FAQFAQ | DownloadsDownloads | WikiWiki

Author Topic: Busybox httpd server enabling php ?  (Read 30712 times)

Offline Terminator3000

  • Jr. Member
  • **
  • Posts: 64
Busybox httpd server enabling php ?
« on: October 02, 2010, 10:09:50 PM »
Hi just wondered if busybox handles php files and if so if someone might know the way to enable it .

I have Busybox httpd installed working fine with the html files and also MySQL.
However I would like to install the php.tcz but I cant at first glance find any config files or places to put extensions namely the php-mysql one which is essential.

Any tips welcome ! Thanks.

Offline curaga

  • Administrator
  • Hero Member
  • *****
  • Posts: 11044
Re: Busybox httpd server enabling php ?
« Reply #1 on: October 03, 2010, 03:57:25 AM »
Please read httpd.c in the busybox source for the conf file documentation.
The only barriers that can stop you are the ones you create yourself.

Offline gutmensch

  • Retired Admins
  • Hero Member
  • *****
  • Posts: 605
  • I can make it disappear, have no fear!
    • remembrance blog
Re: Busybox httpd server enabling php ?
« Reply #2 on: October 03, 2010, 07:30:56 AM »
apache2 + apache2-mod-php5 = 3.6 MB (very easy, straightforward, full featured web server, mysql extensions included)
busybox + php5 = 5.9 MB (very small features, cgi pita, limited use)

I would definitely go for the first but it's only my opinion ;) To me it doesn't seem very appropriate to try making a php/mysql web server out of busybox httpd...
If I seem unduly clear to you, you must have misunderstood what I said. (Alan Greenspan)

Offline tinypoodle

  • Hero Member
  • *****
  • Posts: 3857
Re: Busybox httpd server enabling php ?
« Reply #3 on: October 03, 2010, 08:05:57 AM »
php5 including dependencies = 30.89 MB
"Software gets slower faster than hardware gets faster." Niklaus Wirth - A Plea for Lean Software (1995)

Offline Terminator3000

  • Jr. Member
  • **
  • Posts: 64
Re: Busybox httpd server enabling php ?
« Reply #4 on: October 03, 2010, 10:02:00 AM »
I agree Apache is probably  better if for eg you are using the machine live to the 'outside world' etc,however I was just talking about a small private server for personal/academic use and I was/am trying Busybox as I have not used it before (and I'm not even sure I can get it to work with php)

Other wise the Apache/MySQL/php5 combo as available from repo seems to be fine.

Offline Terminator3000

  • Jr. Member
  • **
  • Posts: 64
Re: Busybox httpd server enabling php ?
« Reply #5 on: October 03, 2010, 04:11:15 PM »
Stuck a bit here on the attempted Busybox-httpd/MySQL/PHP setup.

Whilst the server(for html) and mysql are working fine,there is a prob with getting php working. After installing the php5.tcz from repo,I have the following problems:)-

A. Busybox seems to have no conf file,in fact there only seem to a couple of folders in /usr/local/httpd.

B. php.ini  entry seems to centre around apache or iis with no specific reference to busybox

C. Cant find the php-mysql.so extension directory

So problems getting php to work and thats before even starting to enable php-mysql.so extension which I cant even find !

So if anyone knows anything about Busybox anf php5 dont hesitate to share !

Thanks.

Offline gutmensch

  • Retired Admins
  • Hero Member
  • *****
  • Posts: 605
  • I can make it disappear, have no fear!
    • remembrance blog
Re: Busybox httpd server enabling php ?
« Reply #6 on: October 03, 2010, 05:12:12 PM »
Did you try it as suggested here https://forum.openwrt.org/viewtopic.php?id=11098 ?

If you're not sure, what conf file to edit, load the strace extension and start busybox httpd like this:

Code: [Select]
# strace -e open httpd
Watch for files the process opens.

@MySQL: php5.tcz may already include mysql support so you won't need a special extension, you can check if mysql is available by executing phpinfo(); and look at the extensions.

If I seem unduly clear to you, you must have misunderstood what I said. (Alan Greenspan)

Offline tinypoodle

  • Hero Member
  • *****
  • Posts: 3857
Re: Busybox httpd server enabling php ?
« Reply #7 on: October 03, 2010, 05:30:18 PM »
mysql.tcz is a dependency of php5.tcz
"Software gets slower faster than hardware gets faster." Niklaus Wirth - A Plea for Lean Software (1995)

Offline Terminator3000

  • Jr. Member
  • **
  • Posts: 64
Re: Busybox httpd server enabling php ?
« Reply #8 on: October 03, 2010, 09:17:35 PM »
Getting somewhere but still probs.After creating a httpd.conf file with the line
*.php:/usr/local/bin/php it now will show an info page with phpinfo() function BUT there is no  color,styling or formatting its just in plain text,has all the right stuff on it showing mysql extension etc.

It wont serve any other php page though so something's wrong somewhere.

The above IS the path to the php.exe.

It wont serve by default an index.php page just get an error.

Typically with Apache that information 'page to serve if no dir requested' would go in  httpd.conf how to put in in busybox httpd ?
« Last Edit: October 03, 2010, 09:27:05 PM by Terminator3000 »

Offline Terminator3000

  • Jr. Member
  • **
  • Posts: 64
Re: Busybox httpd server enabling php ?
« Reply #9 on: October 04, 2010, 06:06:14 AM »
So its displaying an info file of sorts but only if I browse to it and there is no styling to it just plain text,(but the info is there).

Other php pages dont serve at all neither by default or if I browse to them,so there are still some settings problems to fathom out.

I've never had a use for cgi but I notice that the tcz module is built with cgi specifically in mind I suspect the cgi aspect is one of the problems (theres a php-cgi exe next to the php one ) Is there another php module available without the cgi stuff ?

Offline Terminator3000

  • Jr. Member
  • **
  • Posts: 64
Re: Busybox httpd server enabling php ?
« Reply #10 on: October 04, 2010, 10:42:23 AM »
Also how do you start it automatically on startup ? At the mo I start manually using this bash script
#!/bin/bash
sudo /usr/local/httpd/sbin/httpd -p 80 -h /home/tc/webroot -u tc:staff

echo "Server started!"

But its getting tedious, something similar can be put in /etc/init.d/services/ folder to run on auto ??

Cheers.
« Last Edit: October 04, 2010, 12:31:01 PM by Terminator3000 »

Offline Terminator3000

  • Jr. Member
  • **
  • Posts: 64
Re: Busybox httpd server enabling php ?
« Reply #11 on: October 04, 2010, 12:26:16 PM »
Here is some of my phpinfo file,its served in plain text on white background and as seen,with no formatting,strange.


Environment

Variable => Value
TERM => rxvt-unicode
PATH => /usr/local/bin:/usr/local/sbin:/usr/sbin:/usr/bin:/sbin:/bin
LANG => C
TZ => UTC
HOME => /home/tc
DISPLAY => :0.0
XAUTHORITY => /home/tc/.Xauthority
COLORTERM => rxvt
SHELL => /bin/sh
LOGNAME => root
USER => root
USERNAME => root
SUDO_COMMAND => /usr/local/httpd/sbin/httpd -p 80 -h /home/tc/webroot -u tc:staff
SUDO_USER => root
SUDO_UID => 0
SUDO_GID => 0
PATH_INFO => 
REQUEST_METHOD => GET
REQUEST_URI => /info.php
SCRIPT_FILENAME => /home/tc/webroot/info.php
SCRIPT_NAME => /info.php
QUERY_STRING => 
SERVER_SOFTWARE => busybox httpd/1.17.2
SERVER_PROTOCOL => HTTP/1.0
GATEWAY_INTERFACE => CGI/1.1
REMOTE_ADDR => 127.0.0.1
REMOTE_PORT => 40919
HTTP_USER_AGENT => Mozilla/5.0 (X11; U; Linux i686; en-US) AppleWebKit/534.3 (KHTML, like Gecko) Chrome/6.0.472.59 Safari/534.3
HTTP_ACCEPT => application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5
HTTP_ACCEPT_LANGUAGE => en-GB,en-US;q=0.8,en;q=0.6
HTTP_HOST => localhost

and as stated earlier server wont serve php by default or browsed to,html pages come up fine though.

So there is some setting in either php.ini or httpd that needs adjusting.MySQL is recognised as extension as are others like gd,xml,curl etc.

Here is another section of phpinfo

Directive => Local Value => Master Value
allow_call_time_pass_reference => Off => Off
allow_url_fopen => On => On
allow_url_include => Off => Off
always_populate_raw_post_data => Off => Off
arg_separator.input => & => &
arg_separator.output => & => &
asp_tags => Off => Off
auto_append_file => no value => no value
auto_globals_jit => On => On
auto_prepend_file => no value => no value
browscap => no value => no value
default_charset => iso-8859-1 => iso-8859-1
default_mimetype => text/html => text/html
define_syslog_variables => Off => Off
disable_classes => no value => no value
disable_functions => no value => no value
display_errors => STDOUT => STDOUT
display_startup_errors => On => On
doc_root => /home/tc/webroot => /home/tc/webroot
docref_ext => .html .php => .html .php
docref_root => /phpmanual/ => /phpmanual/
enable_dl => Off => Off
error_append_string => no value => no value
error_log => no value => no value
error_prepend_string => no value => no value
error_reporting => 32767 => 32767
exit_on_timeout => Off => Off
expose_php => On => On
extension_dir => /usr/local/lib/php/extensions/no-debug-non-zts-20090626 => /usr/local/lib/php/extensions/no-debug-non-zts-20090626
file_uploads => On => On
highlight.bg => <font style="color: #FFFFFF">#FFFFFF</font> => <font style="color: #FFFFFF">#FFFFFF</font>
highlight.comment => <font style="color: #FF8000">#FF8000</font> => <font style="color: #FF8000">#FF8000</font>
highlight.default => <font style="color: #0000BB">#0000BB</font> => <font style="color: #0000BB">#0000BB</font>
highlight.html => <font style="color: #000000">#000000</font> => <font style="color: #000000">#000000</font>
highlight.keyword => <font style="color: #007700">#007700</font> => <font style="color: #007700">#007700</font>
highlight.string => <font style="color: #DD0000">#DD0000</font> => <font style="color: #DD0000">#DD0000</font>
html_errors => Off => Off
ignore_repeated_errors => Off => Off
ignore_repeated_source => Off => Off
ignore_user_abort => Off => Off
implicit_flush => On => On
include_path => .:/usr/local/lib/php => .:/usr/local/lib/php
log_errors => On => On
log_errors_max_len => 1024 => 1024
magic_quotes_gpc => Off => Off
magic_quotes_runtime => Off => Off
magic_quotes_sybase => Off => Off
mail.add_x_header => On => On
mail.force_extra_parameters => no value => no value
mail.log => no value => no value
max_execution_time => 0 => 0
max_file_uploads => 20 => 20
max_input_nesting_level => 64 => 64
max_input_time => -1 => -1
memory_limit => 128M => 128M
open_basedir => no value => no value
output_buffering => 0 => 0
output_handler => no value => no value
post_max_size => 8M => 8M
precision => 14 => 14
realpath_cache_size => 16K => 16K
realpath_cache_ttl => 120 => 120
register_argc_argv => On => On
register_globals => Off => Off
register_long_arrays => Off => Off
report_memleaks => On => On
report_zend_debug => Off => Off
request_order => GP => GP
safe_mode => Off => Off
safe_mode_exec_dir => no value => no value
safe_mode_gid => Off => Off
safe_mode_include_dir => no value => no value
sendmail_from => no value => no value
sendmail_path =>  -t -i  =>  -t -i
serialize_precision => 100 => 100
short_open_tag => Off => Off
SMTP => localhost => localhost
smtp_port => 25 => 25
sql.safe_mode => Off => Off
track_errors => On => On
unserialize_callback_func => no value => no value
upload_max_filesize => 2M => 2M
upload_tmp_dir => no value => no value
user_dir => no value => no value
user_ini.cache_ttl => 300 => 300
user_ini.filename => .user.ini => .user.ini
variables_order => GPCS => GPCS
xmlrpc_error_number => 0 => 0
xmlrpc_errors => Off => Off
y2k_compliance => On => On
zend.enable_gc => On => On

So php is only half working any one who might know how to fix this remember:)-

CARING IS SHARING!!



Offline gutmensch

  • Retired Admins
  • Hero Member
  • *****
  • Posts: 605
  • I can make it disappear, have no fear!
    • remembrance blog
Re: Busybox httpd server enabling php ?
« Reply #12 on: October 04, 2010, 01:20:58 PM »
did you read the source files here http://git.busybox.net/busybox/tree/networking like curaga suggested? did you try *.php:/usr/local/bin/php-cgi? did you set cgi variables in php.ini? frankly your posts look like some sort of "rtfm" ;) try turning php error logs on and get verbose httpd output, system vars alone are not very helpful...
If I seem unduly clear to you, you must have misunderstood what I said. (Alan Greenspan)

Offline Terminator3000

  • Jr. Member
  • **
  • Posts: 64
Re: Busybox httpd server enabling php ?
« Reply #13 on: October 04, 2010, 07:04:41 PM »
UPDATE ON SAGA

FINALLY got it working !  I didn't realize you had to use the php-cgi from /usr/local/bin and not the php. Set the  cgi.force_redirect = 0 and cgi.redirect_status_env = "yes"; also the cgi.fix_pathinfo=1 and docref_ext = .html .php.

So now I've got a  nice technicolor phpinfo file

Just shows what a little bleating can do.

Offline Terminator3000

  • Jr. Member
  • **
  • Posts: 64
Re: Busybox/MySQL/PHP
« Reply #14 on: October 05, 2010, 12:30:57 PM »
Anyway, Busybox/MySQL/PHP as obtained from Microcore repo seems to make a nice little testing server with a small footprint and despite the drama documented above it is not hard to setup with just a few changes to php.ini and the creation of  a httpd.conf necessary(for busybox).

Ive also installed Webmin 1.520 from here http://www.webmin.com/   Its a pretty comprehensive and free server admin interface for unix and is easy to install on Microcore.
Just download the tar.gz offered and away you go.

Thanks to all posters for the help on this!

UPDATE: After all that however, although I got it all working I decided that gutmensch's suggestion of apache2+apache2-php5-mod.tcz etc was on the ball as there seem to some failings with the busybox setup (no default index.php !). So whilst its fine if you can get used to that,I prefer to have all server functions working a la apache.+ Installation is a doddle as long as you know to install the apache2-php-mod.tcz ext.

 

« Last Edit: October 25, 2010, 06:37:10 PM by Terminator3000 »