如何为 phpbrew 创建 systemd 单元文件?

如何为 phpbrew 创建 systemd 单元文件?

我想为 systemd 创建一个单元文件,它将在服务器重启后自动启动 PHP FPM。

以下是文件内容:

[Unit]
Description=PHP 5.5.32 FPM

[Service]
User=deploy
Group=deploy
WorkingDirectory=/home/deploy
ExecStartPre=/usr/local/bin/phpbrew use 5.5.32
ExecStart=/usr/local/bin/phpbrew fpm start

[Install]
WantedBy=multi-user.target

但是当我尝试通过运行启动该服务时sudo systemctl start php55-fpm.service,它却不起作用。

以下是输出sudo systemctl status php55-fpm.service

● php55-fpm.service - PHP 5.5.32 FPM
   Loaded: loaded (/usr/lib/systemd/system/php55-fpm.service; enabled; vendor preset: disabled)
   Active: inactive (dead) since Wed 2016-03-30 05:13:52 CDT; 3min 50s ago
  Process: 20444 ExecStart=/usr/local/bin/phpbrew fpm start (code=exited, status=0/SUCCESS)
  Process: 20441 ExecStartPre=/usr/local/bin/phpbrew use 5.5.32 (code=exited, status=0/SUCCESS)
 Main PID: 20444 (code=exited, status=0/SUCCESS)

Mar 30 05:13:52 web1 phpbrew[20444]: sami     - http://get.sensiolabs.org/sami.phar
Mar 30 05:13:52 web1 phpbrew[20444]: phpcs    - https://squizlabs.github.io/PHP_CodeSniffer/phpcs.phar
Mar 30 05:13:52 web1 phpbrew[20444]: pdepend  - http://static.pdepend.org/php/latest/pdepend.phar
Mar 30 05:13:52 web1 phpbrew[20444]: onion    - https://raw.githubusercontent.com/phpbrew/Onion/master/onion
Mar 30 05:13:52 web1 phpbrew[20444]: box-2.5  - https://github.com/box-project/box2/releases/download/2.5.2/box-2.5.2.phar
Mar 30 05:13:52 web1 phpbrew[20444]: phpcov   - https://phar.phpunit.de/phpcov.phar
Mar 30 05:13:52 web1 phpbrew[20444]: phpcpd   - https://phar.phpunit.de/phpcpd.phar
Mar 30 05:13:52 web1 phpbrew[20444]: phpdcd   - https://phar.phpunit.de/phpdcd.phar
Mar 30 05:13:52 web1 phpbrew[20444]: phptok   - https://phar.phpunit.de/phptok.phar
Mar 30 05:13:52 web1 phpbrew[20444]: phploc   - https://phar.phpunit.de/phploc.phar

附加信息:

SELinux 已禁用

[root@web1 deploy]# sestatus
SELinux status:                 disabled

我是否遗漏了什么?

谢谢!

答案1

phpbrew 1.22.0 现在支持fpm setup --systemctl命令来帮助您设置服务。

确保--with-fpm-systemd在构建时启用

相关内容