Skip to content

Instantly share code, notes, and snippets.

@adamesss
Forked from magnetikonline/README.md
Created July 17, 2016 15:36
Show Gist options
  • Save adamesss/9dc98e2272ed6feb6e4228b88537ffe2 to your computer and use it in GitHub Desktop.
Save adamesss/9dc98e2272ed6feb6e4228b88537ffe2 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.

  • Will ensure Nginx web server has started before kicking off PHP-FPM process.
  • PHP-FPM pid file placed in /run/php7, 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=Nginx web server
After=local-fs.target network.target
[Service]
ExecStart=/usr/local/nginx/sbin/nginx
Type=forking
[Install]
WantedBy=multi-user.target
[Unit]
Description=PHP FastCGI process manager
After=local-fs.target network.target nginx.service
[Service]
ExecStartPre=/bin/mkdir -p /run/php7
ExecStart=/usr/local/sbin/php-fpm --fpm-config /etc/php7/php-fpm.conf
Type=forking
[Install]
WantedBy=multi-user.target
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment