【发布时间】:2017-05-20 19:45:27
【问题描述】:
我无法使用 Deployer 4.0.2 进行部署,我需要在这方面比我更有经验的人的帮助。
我想将我的存储库部署到Ubuntu 16.04 服务器。
我使用laravel homestead 作为开发环境,我还安装了部署程序。从那里我 ssh 进入我的远程服务器。
我能够使用root 用户部署我的代码,直到我遇到RuntimeException 中止我的部署。
Do not run Composer as root/super user! See https://getcomposer.org/root for details
这让我创建了另一个名为 george 的用户,我授予了超级用户权限。我将我的公钥从本地机器复制到一个新生成的~/.ssh/authorized_keys 文件中,该文件允许我通过 ssh 访问服务器。
然而,当我使用新用户运行 dep deploy 时:
server('production', '138.68.99.157')
->user('george')
->identityFile()
->set('deploy_path', '/var/www/test');
我又收到了一个RuntimeException:
Host key verification failed.
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
现在看起来新用户george 无法访问~/.ssh/id_rsa.pubkey。所以我将它们从根文件夹复制到我的主文件夹中,并在 Github SSH 设置中添加公钥。
cp root/.ssh/id_rsa.pub home/george/.ssh/id_rsa.pub
cp root/.ssh/id_rsa home/george/.ssh/id_rsa
只是得到和以前一样的错误。
最后我不得不将 github 添加到我的授权主机列表中:
ssh-keyscan -H github.com >> ~/.ssh/known_hosts
只为获取下一个RuntimeException
[RuntimeException]
sudo: no tty present and no askpass program specified
我设法在deploy.php 中评论了这段代码
// desc('Restart PHP-FPM service');
// task('php-fpm:restart', function () {
// // The user must have rights for restart service
// // /etc/sudoers: username ALL=NOPASSWD:/bin/systemctl restart php-fpm.service
// run('sudo systemctl restart php-fpm.service');
// });
// after('deploy:symlink', 'php-fpm:restart');
部署过程终于搞定了,现在我问自己,php-fpm的restart是否真的有必要,让我继续调试这个部署工具?或者我可以没有它吗?
如果我需要它,有人可以帮助我了解我需要它吗?而且也许作为一种奢侈品还提供了RuntimeException的解决方案?
【问题讨论】:
-
我假设使用 php-fpm restart 来清除 opcache。但是有更好的解决方案(见deployer.org/recipes/cachetool.html)。
标签: php git laravel ssh deployment