# [solved] PHP-FPM + systemd

## StalkerNOVA

Does anyone have a .service file for PHP-FPM?Last edited by StalkerNOVA on Mon Feb 13, 2012 8:32 am; edited 1 time in total

----------

## Etal

Here's one from Fedora 17:

```
[Unit]

Description=The PHP FastCGI Process Manager

After=syslog.target network.target

[Service]

Type=forking

PIDFile=/var/run/php-fpm/php-fpm.pid

ExecStart=/usr/sbin/php-fpm

ExecReload=/bin/kill -USR2 $MAINPID

ExecStop=/usr/sbin/httpd $OPTIONS -k stop

[Install]

WantedBy=multi-user.target
```

with a corresponding tmpfiles.d/fpm-php.conf:

```
d /var/run/php-fpm 755 root root
```

And here's one from Exherbo:

```
[Unit]

Description=php-fpm

[Service]

Type=forking

ExecStart=/usr/sbin/php-fpm

[Install]

WantedBy=multi-user.target
```

See which one (or combination of) works.

----------

## StalkerNOVA

```
[Unit]

Description=The PHP FastCGI Process Manager

After=syslog.target network.target

[Service]

Type=forking

PIDFile=/var/run/php-fpm.pid

ExecStart=/usr/bin/php-fpm -g /var/run/php-fpm.pid -y /etc/php/fpm-php5.3/php-fpm.conf

ExecReload=/bin/kill -USR2 $MAINPID

ExecStop=kill $MAINPID

[Install]

WantedBy=multi-user.target
```

Here is my version. Not sure about ExecReload and ExecStop but ExecStart works perfect.

Main problem - it's version-dependant   :Embarassed:  Gentoo stores configs there and php-fpm not ready to get them without parameters   :Crying or Very sad: 

----------

## constantined

Maybe something like

```
[Unit]

Description=The PHP FastCGI Process Manager

After=syslog.target network.target

[Service]

Type=forking

PIDFile=/var/run/php-fpm.pid

ExecStart=/bin/sh -c '/usr/bin/php-fpm -g /var/run/php-fpm.pid -y /etc/php/fpm-$(eselect php show fpm)/php-fpm.conf'

ExecReload=/bin/kill -USR2 $MAINPID

ExecStop=kill $MAINPID

[Install]

WantedBy=multi-user.target

```

----------

## mbjr

Noticed that systemd 216 cries if not absolute path is used to call the binary - in above example ExecStop needs /bin/kill instead of kill, here goes:

```
[Unit]

Description=The PHP FastCGI Process Manager

After=syslog.target network.target

[Service]

Type=forking

PIDFile=/var/run/php-fpm.pid

ExecStart=/bin/sh -c '/usr/bin/php-fpm -g /var/run/php-fpm.pid -y /etc/php/fpm-$(eselect php show fpm)/php-fpm.conf'

ExecReload=/bin/kill -USR2 $MAINPID

ExecStop=/bin/kill $MAINPID

[Install]

WantedBy=multi-user.target
```

Have fun  :Wink: 

----------

