Skip to content

Instantly share code, notes, and snippets.

@Mr-Bossman
Last active August 3, 2025 20:50
Show Gist options
  • Save Mr-Bossman/c7b90995deb348358053c61c56831fd3 to your computer and use it in GitHub Desktop.
Save Mr-Bossman/c7b90995deb348358053c61c56831fd3 to your computer and use it in GitHub Desktop.
Read-only filesystem support for Nginx
#!/bin/bash
do_install() {
cat <<EOF > /etc/systemd/system/ronginx.service
[Unit]
Description=Read-only filesystem support for Nginx
After=tmp.mount
[Service]
Type=oneshot
ExecStart=/bin/ronginx run
[Install]
WantedBy=multi-user.target
RequiredBy=nginx.service
EOF
mv "$0" /bin/ronginx
systemctl enable ronginx.service
}
run() {
chown -R www-data:www-data /var/lib/nginx || true
}
help() {
echo To allow Nginx to run on read-only filesystem run:
echo "$0" run
echo To install this service run:
echo "$0" install
}
case "$1" in
"install")
do_install
;;
"run")
run
;;
*)
help
;;
esac
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment