, 4 min read
Installing Simplified Saaze on Android
Simplified Saaze is a static site generator. This very blog uses Simplified Saaze.
It is possible to generate all HTML files on Android using Simplified Saaze! This post shows the necessary steps.
The main trick is to use termux. I had written on termux here: ssh and rsync for Android, Termux.
1. Installing PHP and C compiler
Install the C compiler and Git.
pkg install clang git autoconf
gcc
is not available on termux, therefore we chose clang
.
Git is required further down, when we install MD4C.
Autoconf is required for all PHP extensions, which use configure
.
Simplified Saaze is written in PHP. Therefore we need PHP and optionally composer.
pkg install php composer
composer
is not strictly requiered, but convenient when you want to install one of the many themes.
2. Installing PHP yaml extension
First install libyaml
library:
pkg install libyaml
Next download latest tar-ball from PECL yaml package. Untar the file
tar zxf yaml-2.2.4.tgz
Do the usual three-step:
phpize
./configure
make
Once all has been built, the module is copied or moved to the PHP extension library directory:
mv modules/yaml.so /data/data/com.termux/files/usr/lib/php/
3. Installing MD4C extension
Clone the git directory including its submodule:
git clone --recurse-submodules https://github.com/eklausme/php-md4c.git
The reason for this is that termux does not provide MD4C in its package repositories.
Now the rest is standard again with the usual three-step procedure.
phpize
./configure
make
After the build, move or copy the MD4C so-file.
mv modules/md4c.so /data/data/com.termux/files/usr/lib/php/
4. Setting php.ini
For PHP to use yaml and MD4C we have to edit php.ini
.
It is stored in
/data/data/com.termux/files/usr/etc/php/php.ini
The content is then:
opcache.enable=1
opcache.jit_buffer_size=100M
opcache.jit=1255
short_open_tag = 0
extension=md4c
extension=yaml
Regarding JIT configuration see PHP 8: How to setup the JIT.
Once all is installed and configured, first check with php -m
, then check PHP with phpinfo()
: Create a file phpinfo.php
with below content.
<?php
phpinfo();
?>
Then start the builtin web-server of PHP:
php -S <your-IP-address>:8000 -t .
Assuming that the phpinfo.php
file is in your current directory (therefore -t .
).
Check in your browser whether the yaml and MD4C extension are visible in the output of phpinfo()
.
5. Running Simplified Saaze
Below you will find my entire blog processed on Android.
My blog happens to reside in the directory sndsaaze
.
For that I simply copied it to termux:
tar cf - sndsaaze | ssh x14 'cd ~/php; tar xf -'
Finally:
$ time php saaze -mort
Building static site in ./build...
execute(): filePath=./content/error.yml, nSIentries=0, totalPages=0, entries_per_page=20
execute(): filePath=./content/music.yml, nSIentries=83, totalPages=5, entries_per_page=20
execute(): filePath=./content/gallery.yml, nSIentries=11, totalPages=1, entries_per_page=20
execute(): filePath=./content/blog.yml, nSIentries=491, totalPages=25, entries_per_page=20
execute(): filePath=./content/aux.yml, nSIentries=8, totalPages=1, entries_per_page=20
Finished creating 5 collections, 4 with index, and 625 entries (0.44 secs / 23.44MB)
#collections=5, parseEntry=0.0145/629-5, md2html=0.0363, toHtml=0.0413/625, renderEntry=0.2265/625, renderCollection=0.0101/36, content=625/0
real 0m0.471s
user 0m0.339s
sys 0m0.120s
This entire blog can be processed with Simplified Saaze on Android within less than half a second. These runtimes are for an Xiaomi 14T Pro model.
When using the parallel option in Simplified Saaze the runtime can be brought down to a quarter second.
$ time php saaze -mort -p8
Building static site in ./build...
execute(): filePath=./content/error.yml, nSIentries=0, totalPages=0, entries_per_page=20
execute(): filePath=./content/music.yml, nSIentries=83, totalPages=5, entries_per_page=20
execute(): filePath=./content/gallery.yml, nSIentries=11, totalPages=1, entries_per_page=20
execute(): filePath=./content/blog.yml, nSIentries=491, totalPages=25, entries_per_page=20
nentries=510, procnr=00, pid=24969
nentries=510, procnr=01, pid=24970
nentries=510, procnr=02, pid=24971
nentries=510, procnr=03, pid=24972
nentries=510, procnr=04, pid=24973
nentries=510, procnr=05, pid=24974
nentries=510, procnr=06, pid=24975
execute(): filePath=./content/aux.yml, nSIentries=8, totalPages=1, entries_per_page=20
Finished creating 5 collections, 4 with index, and 115 entries (0.24 secs / 19.54MB)
#collections=5, parseEntry=0.0149/629-5, md2html=0.0364, toHtml=0.0410/625, renderEntry=0.0535/115, renderCollection=0.0142/36, content=625/0
real 0m0.275s
user 0m0.182s
sys 0m0.084s