Pandora The LiMPS Project


Magic Sam

Forever Homebrew
Joined
Aug 10, 2007
Messages
2,542
Age
41
Location
Yuzu onsen
Hi all,

As I already said elsewhere, I attended a 3 days MySQL / PHP training session this week. It was nice, I learnt a lot, but it was also way too short, and I'll need a lot more practice before being proficient with these technologies...

Since the Pandora is the computer I carry around the most, I decided to use it as a portable LAMP server. Given the scope of this project (mostly training, it will never go into production AFAIK), and the limited resources available on the Pandora, I decided to use the following pieces of software, instead of the regular LAMP environment:

Linux : Super Zaxxon 1.75 (Angstrom Linux)

Monkey Project :
Monkey is a lightweight and powerful web server and development stack for Linux & OSX. It has been designed to be very scalable with low memory and CPU consumption, the perfect solution for embedded devices. Made for ARM, x86 and x64.

PHP :
PHP is a popular general-purpose scripting language that is especially suited to web development.
Fast, flexible and pragmatic, PHP powers everything from your blog to the most popular websites in the world.

SQLite :
SQLite is a high-reliability, embedded, zero-configuration, public-domain, SQL database engine. SQLite is the most used database engine in the world.

I gave them a go yesterday evening, and they all compiled effortlessly thanks to @ptitSeb 's latest beta Code::Blocks :) Now, "all" that's left to do is configure all those little guys to work correctly with each others...

Please let me know what you think about this tiny project. If there's some interest from the community, I could even package everything up in a convenient PND :)

Cheers, Magic Sam
 
Last edited:
Nice work, but beware of differences between SQLite and MySQL. SQLite only supports a subset of the SQL language. For example, there is no user management and some functions are missing.
 
Hi all :)

Time really does fly...

I need to resume this project, as my next job could involve databases.

Cheers, Magic Sam
 
Related to this. I may try to publish a standalone MySQL pnd. Not sure if this can be usefull to anyone (and not sure it does work and is usefull yet, but at least it's compiled).
 
Last edited:
Hi again,

I'm almost done with Monkey Web Server 1.6.9 PND :)

Stay tuned !

Cheers, Magic Sam
 
Hey... never read this before. Did you manage to compile Monkey with SSL support? I tried Hiawatha, but never got it to compile, I switched over to httpi, but that required additional perl libs to run, so kinda made my own mini perl webserver (non-ssl)... but I'd rather use something compiled...
 
Hi all :)

I'm rebuilding Monkey Web Server 1.6.9 with @ptitSeb 's latest beta Code::Blocks (GCC 6.3).

@FBnil : I think SSL support is enabled, but I'll check again.

@FBnil : you were right, SSL support is disabled by default, I had to force the compilation as a plugin with the following options:
pandora:/media/Pandora1/dev/monkey-1.6.9$ ./configure --prefix=/mnt/utmp/monkey-magicsam --enable-plugins=auth,cgi,cheetah,dirlisting,fastcgi,liana,logger,mandril,tls

N.B: liana is being built as a static library.

Cheers, Magic Sam
[doublepost=1490803815,1490799341][/doublepost]Hi again,

@kuru , @FBnil , @ptitSeb : the PND is available there for testing purposes:

http://sviscapi.chaosnet.org/monkey-magicsam.pnd

Monkey Web Server should show up in your Network menu. Click on the icon and wait a while. You can monitor the process with "tail -f /tmp/pndrun_monkey-magicsam.out", or with "ps aux | grep monkey". I may add a small Zenity pop-up reading "Monkey is running..." in a future build.

When everything is working correctly, point your favourite Web browser to 127.0.0.1:2001, and you should see the Monkey Web Server default page.

etc and var directories are copied to appdata/monkey-magicsam on the first run for you to tweak the settings.

Feedback would be really appreciated, as I have very little experience with Web servers...

EDIT: when you are done with it, just kill Monkey's PID.

Cheers, Magic Sam
 
Last edited:
EDIT: when you are done with it, just kill Monkey's PID.
donotkill.jpg
 
Hi again,

I have just built SQLite 3.17 with @ptitSeb 's latest beta Code::Blocks :) I only had to replace "-Ofast" with "-O3" in the CFLAGS as SQLite is incompatible with "-ffast-math".

I'll try to package it ASAP (tomorrow if possible).

Cheers, Magic Sam
 
Hi again,

I have just built SQLite 3.17 with @ptitSeb 's latest beta Code::Blocks :) I only had to replace "-Ofast" with "-O3" in the CFLAGS as SQLite is incompatible with "-ffast-math".

I'll try to package it ASAP (tomorrow if possible).

Cheers, Magic Sam
Other solution is to add
Code:
#pragma GCC optimize "no-fast-math"
at the beggining of sqlite.c
(but I think this version is already in codeblocks).
 
Hi all :)

@ptitSeb : thanks for the information, and sorry for duplicating your work, but I'd rather have Monkey, SQLite and PHP as standalone applications, with maybe an overarching LiMPS PND (a la Code::Blocks, which would mount all three PNDs and set them up to work together as a lightweight LAMP server) later on.

On a side note, I'm about to compile PHP with SQLite support. I could add MySQL support too if you want ;)

EDIT: @FBnil : did you have time to try Monkey Web Server and its SSL plugin ?

Cheers, Magic Sam
 
Don't do a standalone PND with just SQLite. It's just a single lib.

MySQL support can work, but I have to validate the usabilty of the MySQL PND when automounted...
 
Hi again,

Here is SQLite 3.17:

http://sviscapi.chaosnet.org/sqlite-magicsam.pnd

@ptitSeb : I decided to package it as a PND because I believe it'll be easier to maintain (at least for me) in the long run. I also included the "sqlite3" command, so that I can issue SQL queries straight from the CLI :)

Cheers, Magic Sam
[doublepost=1490882475,1490876065][/doublepost]Hi again,

I have updated the SQLite PND (same link as before). The official documentation is now incuded.

Cheers, Magic Sam
 
EDIT: @FBnil : did you have time to try Monkey Web Server and its SSL plugin ?
Not yet, only a helloworld.html. Exhaused, long days at work, will do on the weekend.
I could run VLC, Arora and Monkey and still have plenty of RAM... impressive!
 
Hi all :)

@FBnil : thanks for giving Monkey Web Server a try. There's no hurry, just let me know if you find anything strange with this build.

I also finished compiling PHP 7.1.3 this morning ("make test" completed with errors though). I'll package it ASAP (on Monday if possible).

Cheers, Magic Sam
 
playing around with it. But no luck getting https working. I suspect it want 443, and this being a port below 1000 needs root. So I killed monkey, sudo'd to root and started it as root, but still no luck. Reading documentation. Ill monkey around with GCI first, get phtml working, and then venture into it again.

Things done:

Added all required [config] parts (actually: plugins.load => uncomment, tls.conf => full paths to ssl keys (selfsigned, but there could be a mismatch with the hostname, so need to re-create them) and in monkey.conf added TransportLayer mbedtsl, but it still defaults to liana... so that is the last thing I am unable to manage). Looked at netstat -a |grep LISTEN and only finding :2001 as being read.

using wget -S --secure-protocol=auto --https-only https://127.0.0.1

also: sudo su, and chmod 777 the required files to save them with mousepad...


hmm... if I run ./sbin/monkey -s monkey.conf -p 80 it is unable to set the listening port to 80, because when you start it as root, it runs as www-data user (lower priviledges)... I did a chmod +R 777 * to give if more access, but it still does not load additional plugins

another update: the perl CGI is spewed out as-is, not interpreted. So it is the plugins... I guess it is not read it?
 
Last edited:
Hi all :)

@FBnil: thanks for testing Monkey Web Server, it's really appreciated !

Just to be sure, did you follow the official documentation regarging SSL ?

http://www.monkey-project.com/documentation/1.6/plugins/tls.html

Cheers, Magic Sam
[doublepost=1491217662,1491217474][/doublepost]And about PHP, I think I'll first have to complete my PHP 7.1.3 package, then one would have to set up the FastCGI plugin, as per the official documentation:

http://www.monkey-project.com/documentation/1.6/plugins/fastcgi.html

Cheers, Magic Sam
[doublepost=1491247066][/doublepost]Hi again :)

@FBnil : here is PHP 7.1.3:

http://sviscapi.chaosnet.org/php-magicsam.pnd

If you want, you could try to set up Monkey to use PHP with the FastCGI plugin. I'll try this myself later, as I'm not in the mood tonight...

@ptitSeb : this first test build doesn't feature MySQL support yet, only SQLite.

Cheers, Magic Sam
 
I did not follow the "Build", should I?

What I see is that there are 2 configuration files:

Code:
spica:/mnt/utmp/monkey-magicsam# find . |grep monkey.conf
./etc/monkey/monkey.conf
./config/etc/monkey/monkey.conf
spica:/mnt/utmp/monkey-magicsam# diff ./etc/monkey/monkey.conf ./config/etc/monkey/monkey.conf
5a6,20
> [PLUGINS]
>      Load /mnt/utmp/monkey-magicsam/lib/monkey-auth.so
>      Load /mnt/utmp/monkey-magicsam/lib/monkey-cgi.so
>      Load /mnt/utmp/monkey-magicsam/lib/monkey-cheetah.so
>      Load /mnt/utmp/monkey-magicsam/lib/monkey-dirlisting.so
>      Load /mnt/utmp/monkey-magicsam/lib/monkey-fastcgi.so
>      Load /mnt/utmp/monkey-magicsam/lib/monkey-logger.so
>     Load /mnt/utmp/monkey-magicsam/lib/monkey-mandril.so
>     Load /mnt/utmp/monkey-magicsam/lib/monkey-tls.so
>
> [SSL]
> CertificateFile /media/PANTOFFEL/DATA/SSLKEYS/srv_cert.pem
> RSAKeyFile /media/PANTOFFEL/DATA/SSLKEYS/rsa_key.pem
> DHParameterFile /media/PANTOFFEL/DATA/SSLKEYS/dhparam.pem
>
6a22
> TransportLayer mbedtsl
20a37,38
> Listen 2443 ssl
>
Just like python, the configuration does not get processed if the keys inside a header are not well indented (4 spaces, not more, not less)

due to permission problems, ports below 1000 are not supported (I did a chmod recursively, but did not try a chown recursively). it runs as a special low priviledged user, so tht is why
Code:
spica:/mnt/utmp/monkey-magicsam# ./run.sh
Monkey HTTP Server v1.6.9
Built : Mar 29 2017 17:17:14 (/mnt/utmp/codeblocks/usr/bin/cc 6.3.0)
Home  : http://monkey-project.com
[+] Process ID is 2647
[+] Server listening on 0.0.0.0:80
[+] Server listening on 0.0.0.0:443
[+] 1 threads, may handle up to 1024 client connections
[+] Loaded Plugins: liana
[2017/04/03 22:10:14] [   Info] HTTP Server started
[2017/04/03 22:10:14] [Warning] Error binding socket
[2017/04/03 22:10:14] [  Error] Cannot listen on 0.0.0.0:80
[2017/04/03 22:10:14] [  Error] [server] Failed to bind server socket to 0.0.0.0:80.
[2017/04/03 22:10:14] [  Error] Failed to initialize listen sockets.
spica:/mnt/utmp/monkey-magicsam# whoami
root
spica:/mnt/utmp/monkey-magicsam#

running from ephimeral ports at least starts http, but not https... so this low priviledged user is not able to read/execute something. Ill look into it later, mosquitos are biting...
Code:
spica:/mnt/utmp/monkey-magicsam# ./run.sh
Monkey HTTP Server v1.6.9
Built : Mar 29 2017 17:17:14 (/mnt/utmp/codeblocks/usr/bin/cc 6.3.0)
Home  : http://monkey-project.com
[+] Process ID is 2654
[+] Server listening on 0.0.0.0:8880
[+] Server listening on 0.0.0.0:8443
[+] 1 threads, may handle up to 1024 client connections
[+] Loaded Plugins: liana
[2017/04/03 22:11:13] [   Info] HTTP Server started
[2017/04/03 22:11:13] [  Error] SSL/TLS not supported
 
@FBnil : thanks for the hint regarding the indentation of the configuration file :) I was wondering why I couldn't get the FastCGI plugin to run...

The only configuration files you have to care about are in your appdata folder, in monkey-magicsam/etc and var (or /mnt/utmp/monkey-magicsam/etc and var when the PND is mounted). The files in config are copied there on the first run, so that you can easily edit them (otherwise you could not, as the PND is mounted in read-only mode).

Last but not least, I forgot to ship a php.ini file with the PHP PND. I'll fix this later.

Cheers, Magic Sam
 
Last edited:
AH, my method is sudo su, and as root, kill monkey, then start it with ./run.sh from the commandline it then gives a little output about it's state and configuration (as shown in the previous post).
I guess I need to adduser this www-* low priviledged user so it can properly sudo to it. Not sure which rights it is missing . For that, I will have to read the source... will take a while
 
Back
Top