📜 ⬆️ ⬇️

Pocket MiniX server, or review of server technologies for Android


At this time, from the MiniX, we will not do an Internet outlet , but a real web server. True, small, but with a full-fledged php, python, bash, MySQL.


Httpd


httpd, from busybox .
The one that was used for the online outlet. Can CGI, so you can write web applications in any language that you can run on Android. And you can run a lot of things - Python, Perl, BeanShell / Rhino (JavaScript), Bsh, Lua.

Runs from the console or via ssh , like this:
httpd -p80 -vv -f -h /sdcard/www -c /sdcard/www/http.cfg 

-p80 - port parameter
-vv - debug mode, -f - do not become a demon. useful when debugging - shows access to the server and access to files.
-h / sdcard / www - server root directory
-c /sdcard/www/http.cfg - configuration file.
')
From the configuration, this line is the most interesting:
* .sh: / system / bin / sh - file extension (or name), and how this file is executed. There are no restrictions on the folder (cgi-bin), files can be executed in any directories.

In busybox, the default is sh, but if suddenly you write scripts in bash (I believe there are no such things among you), you can find it here .

We write the script in this way (let me give an example from the previous topic):
 !/bin/sh /system/bin/echo $QUERY_STRING >/dev/ttyUSB0 echo "Content-type: text/html" echo "" echo "<html><header></header><body>" echo "</body></html>" 


All that we output to stdout is passed to the browser. All parameters passed to get are in the $ QUERY_STRING variable, in the form “r = 1 & g = 3”. Write the parser yourself. Do not forget that the execution time of the script = loading time of the web page.

By the way, busybox has almost everything you need to write scripts on a shell:


Installing other interpreters is also quite simple. Download, for example Python , install, run.

Click Install, waiting for download and installation.


However, just to start python will not work, it is focused on running the GUI.
In order to be able to execute console scripts, you will need to make a simple startup script:

py:
 PW=`pwd` export EXTERNAL_STORAGE=/mnt/sdcard export LANG=en PYTHONPATH=/mnt/sdcard/com.googlecode.pythonforandroid/extras/python PYTHONPATH=${PYTHONPATH}:/data/data/com.googlecode.pythonforandroid/files/python/lib/python2.6/lib-dynload export PYTHONPATH export TEMP=/mnt/storage/com.googlecode.pythonforandroid/extras/python/tmp export PYTHON_EGG_CACHE=$TEMP export PYTHONHOME=/data/data/com.googlecode.pythonforandroid/files/python export LD_LIBRARY_PATH=/data/data/com.googlecode.pythonforandroid/files/python/lib cd $PW /data/data/com.googlecode.pythonforandroid/files/python/bin/python "$@" 


Then mount -oremount, rw / system; cp ./py / system / bin /; chmod 755 / system / bin / py
Everything, it is possible to start and receive the console of a python:

Or set as CGI:
cat "* .py: / system / bin / py"> /sdcard/www/http.cfg

ALHPM (Android + lighttpd + PHP + MySQL)


For android there is a wonderful program KSWEB Server, which includes PHP 5.4.4, MySQL 5.1.62 and Lighttpd 1.4.29 (in version 2.5)

Here is phpinfo () from a running server, if anyone is interested.
It is paid, but I think to find $ 3 is not difficult.
Actually, we get a full-fledged web server, on which, for example, you can put ModX (yes, I specifically put ModX on the MiniX :)

And which will really work:

Here is the offsite server.

kWS Android Web Server


There is also such a server, in free and paid versions.

Able to SSI (from which you can call CGI including), Dynamic DNS (from no-ip.com and dyndns.com), SSL, encryption. Not able to PHP and MySQL.


Ip webcam


A wonderful free program that you can get here .
Allows you to make an IP-camera from any Android device. Settings - a bunch.

Looks like that:


Especially true for minix. We connect the webcam, we install the program, we configure start when loading. Beauty.

Dynamic DNS


And what if you want to get more access from the outside world? If your provider has an external real IP (albeit a dynamic one), then many services providing dynamic DNS will save the father of Russian democracy .
Customers - for all tastes. Universal , official dyndns , universal paid and a handful. In kWS client built.

And you can subscribe in order not to miss new reviews on the company’s page and in my profile (“subscribe” button)

Source: https://habr.com/ru/post/149482/


All Articles