Original post is here: eklausmeier.goip.de
This blog uses the static site generator Simplified Saaze. I use this generator on Arch Linux. The Linux environment is a very natural environment for such a generator. In case you want to use this generator on Windows, this post shows the steps to install it on Windows.
There are multiple ways to install Simplified Saaze on Windows. The main part is to install PHP on Windows.
- Install PHP by compiling from source using Visual C
- Install PHP by using git-bash
- Install PHP by using WSL
Here we describe the route via WSL (Windows Subsystem for Linux) and using Ubuntu version 22.04. Version 22.04 is the long-term-support release ("LTS"). I think this is the easiest approach.
1. Installing Ubuntu. Windows Subsystem for Linux is started by entering wsl
. If Ubuntu does not already start, then the next two paragraphs may help. Otherwise install Ubuntu from the so called "Windows App Store".
On Windows make sure, whether "Windows Subsystem for Linux" is checked. Run optionalfeatures.exe
:
See Fix: WSLRegisterDistribution Failed with Error 0x8007019e if your WSL is not properly set-up. Choose Ubuntu 22.04 in the Microsoft App Store.
Once WSL and Ubuntu is up and running, then install the following packages with apt-get install
.
- gcc: for md4c
- php
- composer
- libmd4c-html0-dev: MD4C lib
- libmd4c-dev: MD4C header file
- php-yaml, alternatively to this package you can install below:
- php-dev: for
phpize
- libyaml-dev
- php-dev: for
Not strictly required for Simplified Saaze, but handy to have for web-development:
- ripgrep: recursive grep
- webp: to reduce image size
- nano: for those who do not feel comfortabe with
vi
.
2. PHP extensions. Now install the PHP Yaml plugin as described here PECL's Yaml Way Faster Than Symfony's Yaml. In WSL it seems to be important to build this PECL within the filesystem of WSL, not on anything like /mnt/c
, etc. On Ubuntu the yaml.so
file is moved to /usr/lib/php/20210902
.
Activate FFI in php.ini
. Edit file /etc/php/8.1/cli/conf.d/20-ffi.ini
and add below line:
1ffi.enabled=true
3. Apache web-server. Start web-server:
1service apache2 start
Go to any Windows browser, e.g., Firefox, and check http://localhost
. Create /var/www/html/phpinfo.php
with content:
1<?php
2 phpinfo();
3?>
Then check with any browser whether http://localhost/phpinfo.php
shows something like this:
I would recommend to add your user to group www-data
in /etc/group
. This eases later deployment to /var/www/html
. This directory should be chown
-ed to www-data
.
4. Installing example project. Now install example project.
1klm@ITEM-S78314:~$ composer create-project eklausme/saaze-example
2Creating a "eklausme/saaze-example" project at "./saaze-example"
3Info from https://repo.packagist.org: #StandWithUkraine
4Installing eklausme/saaze-example (v1.0)
5 - Downloading eklausme/saaze-example (v1.0)
6 - Installing eklausme/saaze-example (v1.0): Extracting archive
7Created project in /home/klm/saaze-example
8Loading composer repositories with package information
9Updating dependencies
10Lock file operations: 1 install, 0 updates, 0 removals
11 - Locking eklausme/saaze (v1.19)
12Writing lock file
13Installing dependencies from lock file (including require-dev)
14Package operations: 1 install, 0 updates, 0 removals
15 - Downloading eklausme/saaze (v1.19)
16 - Installing eklausme/saaze (v1.19): Extracting archive
17Generating optimized autoload files
Go to vendor/eklausme/saaze
and compile:
1cc -fPIC -Wall -O2 -shared php_md4c_toHtml.c -o php_md4c_toHtml.so -lmd4c-html
Create directory sudo mkdir -p /srv/http
, then move the generated lib to /srv/http
. Although any other place will do as well, as long as you configure this in Config.php
accordingly.
Finally run a build:
1time php saaze
This should produce a directory called build
.
1klm@ITEM-S78314:~/saaze-example$ time php saaze
2Building static site in /home/klm/saaze-example/build...
3 execute(): filePath=/home/klm/saaze-example/content/blog.yml, nentries=35, totalPages=2, entries_per_page=20
4 execute(): filePath=/home/klm/saaze-example/content/music.yml, nentries=11, totalPages=1, entries_per_page=20
5Finished creating 2 collections, 2 with index, and 46 entries (0.18 secs / 913kB)
6#collections=2, YamlParser=0.0085/48-2, md2html=0.0008, MathParser=0.0002/46, renderEntry=46, content=46/0, excerpt=0/0
7
8real 0m0.741s
9user 0m0.016s
10sys 0m0.156s
5. Dynamic mode. As mentioned in Simplified Saaze, there is also a dynamic mode in Simplified Saaze. For this start
1php -S 0:8000 -t ./public &
Start any browser on Windows. You should see something like this: