Skip to content

Resources ยท Saphira-D systemd

nginx.service

Saphira webDragon nginx: terminating TLS and proxying PHP requests to PHP-FPM.

Saphira Linux dragon mascot

What this unit does

nginx serves webDragon's HTTPS traffic, terminates TLS 1.3 and passes PHP requests to php-fpm85 over the Unix FastCGI socket. The unit runs nginx in the foreground (daemon off;) so systemd tracks the master process, tests the config first (ExecStartPre nginx -t), and reloads gracefully with nginx -s reload.

Unit file

systemd units belong in /usr/lib/systemd/system. The complete unit is shown below and can be downloaded as a file.

[Unit]
Description=Saphira webDragon nginx
After=network.target

[Service]
Type=simple
ExecStartPre=/usr/sbin/nginx -t
ExecStart=/usr/sbin/nginx -g "daemon off;"
ExecReload=/usr/sbin/nginx -s reload
Restart=on-failure

[Install]
WantedBy=multi-user.target

Install manually

Place the unit in /usr/lib/systemd/system, reload the daemon, then enable it so it starts at boot:

install -m 0644 nginx.service /usr/lib/systemd/system/
systemctl daemon-reload

Enable and disable

Enable and start now:

root@saphira-d:/etc/php-fpm.d# systemctl enable --now nginx.service
Created symlink '/etc/systemd/system/multi-user.target.wants/nginx.service' -> '/etc/systemd/system/nginx.service'.

Disable and stop now:

root@saphira-d:/etc/php-fpm.d# systemctl disable --now nginx.service
Removed '/etc/systemd/system/multi-user.target.wants/nginx.service'.