Skip to content

Instantly share code, notes, and snippets.

@DeadSix27
Forked from magnetikonline/README.md
Last active December 18, 2023 07:02
Show Gist options
  • Select an option

  • Save DeadSix27/ab3a617bc7b802db532d07f76fea0619 to your computer and use it in GitHub Desktop.

Select an option

Save DeadSix27/ab3a617bc7b802db532d07f76fea0619 to your computer and use it in GitHub Desktop.
Example Nginx & PHP-FPM systemd service configs.

Example Nginx & PHP-FPM systemd service configs

A set of really basic systemd configs for starting Nginx and PHP-FPM on system boot.

  • Ensures Nginx web server has started before starting the PHP-FPM process.
  • PHP-FPM pid file placed at /run/php7/php-fpm.pid, PHP7 PHP-FPM config at /etc/php7.
  • Based on usage with Ubuntu 16.04LTS.

Both scripts placed in /lib/systemd/system and enabled by the following:

$ sudo systemctl enable nginx.service
$ sudo systemctl enable php-fpm.service

Fin.

[Unit]
Description=The NGINX HTTP and reverse proxy server
After=syslog.target network.target remote-fs.target nss-lookup.target
[Service]
Type=forking
PIDFile=/opt/nginx/run/nginx.pid
ExecStartPre=/opt/nginx/sbin/nginx -t
ExecStart=/opt/nginx/sbin/nginx
ExecReload=/bin/kill -s HUP $MAINPID
ExecStop=/bin/kill -s QUIT $MAINPID
PrivateTmp=true
[Install]
WantedBy=multi-user.target
[Unit]
Description=PHP FastCGI process manager
After=local-fs.target network.target nginx.service
[Service]
PIDFile=/opt/php/php-fpm.pid
ExecStart=/opt/php/sbin/php-fpm --fpm-config /opt/php/etc/php-fpm.conf --nodaemonize
Type=simple
[Install]
WantedBy=multi-user.target
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment