This is just about trying an earlier article, [Ubuntu] After Setting Up a Ramdisk on Raspberry Pi, nginx and MySQL Stopped Starting, So I Handled It with rc-local, on a Raspberry Pi 4 as well. These days MySQL runs in a Docker container, so the only target this time is /var/log/nginx.
Test Environment
Raspberry Pi 4
Ubuntu 20.10 64-bit
$ uname -a
Linux pi4 5.8.0-1017-raspi #20-Ubuntu SMP PREEMPT Mon Mar 1 14:19:20 UTC 2021 aarch64 aarch64 aarch64 GNU/Linux
Workaround
Use the /etc/rc.local Compatibility provided by systemd.
First, prepare /etc/rc.local.
$ sudo vi /etc/rc.local #!/bin/bash mkdir -p /var/log/nginx chown root.www-data /var/log/nginx exit 0 $ sudo chmod +x /etc/rc.local
Enable systemd's rc.local Compatibility.
Add an [Install] section to the bottom of /lib/systemd/system/rc-local.service.
$ sudo vi /lib/systemd/system/rc-local.service SPDX-License-Identifier: LGPL-2.1+ # This file is part of systemd. # systemd is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. This unit gets pulled automatically into multi-user.target by systemd-rc-local-generator if /etc/rc.local is executable. [Unit] Description=/etc/rc.local Compatibility Documentation=man:systemd-rc-local-generator(8) ConditionFileIsExecutable=/etc/rc.local After=network.target [Service] Type=forking ExecStart=/etc/rc.local start TimeoutSec=0 RemainAfterExit=yes GuessMainPID=no kkitta@pi4:~$ cat /lib/systemd/system/rc-local.service SPDX-License-Identifier: LGPL-2.1+ # This file is part of systemd. # systemd is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. This unit gets pulled automatically into multi-user.target by systemd-rc-local-generator if /etc/rc.local is executable. [Unit] Description=/etc/rc.local Compatibility Documentation=man:systemd-rc-local-generator(8) ConditionFileIsExecutable=/etc/rc.local After=network.target [Service] Type=forking ExecStart=/etc/rc.local start TimeoutSec=0 RemainAfterExit=yes GuessMainPID=no[Install] WantedBy=multi-user.target
Enable the service.
$ sudo systemctl enable rc-local Created symlink /etc/systemd/system/multi-user.target.wants/rc-local.service → /lib/systemd/system/rc-local.service.
Reference: if /lib/systemd/system/rc-local.service does not have an [Install] section, the following error appears.
$ sudo systemctl enable rc-local The unit files have no installation config (WantedBy=, RequiredBy=, Also=, Alias= settings in the [Install] section, and DefaultInstance= for template units). This means they are not meant to be enabled using systemctl. Possible reasons for having this kind of units are: • A unit may be statically enabled by being symlinked from another unit's .wants/ or .requires/ directory. • A unit's purpose may be to act as a helper for some other unit which has a requirement dependency on it. • A unit may be started when needed via activation (socket, path, timer, D-Bus, udev, scripted systemctl call, …). • In case of template units, the unit is meant to be enabled with some instance name specified.

I always notice this only after thinking, "Huh, is the web server down?"