事象
PHPのデプロイメントツールであるDeployerを実行したところ、にエラー「Call to undefined function Deployer\Utility\posix_setsid()」が発生し、デプロイが行えなかった。
プログラム
エラーが出る最小のプログラム(deploy.php)は以下の通り。
<?php
require 'recipe/composer.php';
ファイル構成
[vagrant@localhost deployer_test]$ ls -l
合計 1140
-rw-rw-r--. 1 vagrant vagrant 159 4月 11 00:04 deploy.php
-rw-rw-r--. 1 vagrant vagrant 1156888 3月 5 14:59 deployer.phar
エラーの内容
以下のように、Deployer\Utility\posix_setsid()関数が無いとのエラーが発生する。
(同時にdeploy_pathが無いエラーも出ているがこちらは本家とは関係ない)
> php deployer.phar deploy
✈︎ Deploying HEAD on localhost
➤ Executing task deploy:prepare
➤ Executing task deploy:failed
✔ Ok
In Configuration.php line 93:
Configuration parameter `deploy_path` does not exists.
deploy [-p|--parallel] [-l|--limit LIMIT] [--no-hooks] [--log LOG] [--roles ROLES] [--hosts HOSTS] [-o|--option OPTION] [--] [<stage>]
[vagrant@localhost deployer_test]$
[Error] Call to undefined function Deployer\Utility\posix_setsid()
#0 phar:///home/vagrant/deployer_test/deployer.phar/src/Deployer.php(375):
Deployer\Utility\Reporter::report(Array)
#1 [internal function]: Deployer\Deployer->collectAnonymousStats(Object(Deployer\Console\CommandEvent))
...
理由
Deployerはphp-processに依存しているが、php-processパッケージが入っていなかったため、該当のメソッドが呼び出せなかった。
対処方法
CentOSでremiのPHP7.1を使っている場合は、以下のようにしてパッケージを入れて、再度deployer.pharを実行すれば解消した。
sudo yum install --enablerepo=remi,remi-php71 php-process -y
参考URL
https://github.com/deployphp/deployer/issues/1201
こちらもおススメ