Php Deployer-不存在tty且未指定askpass程序-如何使用Deployer进行部署
我在部署方面有困难,我需要比我更有经验的人的帮助 我想将我的存储库部署到Php Deployer-不存在tty且未指定askpass程序-如何使用Deployer进行部署,php,git,laravel,ssh,deployment,Php,Git,Laravel,Ssh,Deployment,我在部署方面有困难,我需要比我更有经验的人的帮助 我想将我的存储库部署到ubuntu16.04服务器上 我将其用作开发环境,并在其中安装了deployer。从那里我ssh到我的远程服务器 我能够使用root用户部署代码,直到我遇到一个RuntimeException终止部署 Do not run Composer as root/super user! See https://getcomposer.org/root for details 这让我创建了另一个名为george的用户,我给了他超
ubuntu16.04
服务器上
我将其用作开发环境,并在其中安装了deployer。从那里我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\u rsa.pub
密钥。因此,我将它们从根文件夹复制到我的主文件夹中,并在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]
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的重新启动
真的有必要,我要继续调试这个部署工具吗?或者没有它我还能活吗
如果我需要它,有人能帮我理解我需要它的目的吗?也许作为一种奢侈品,它还提供了运行时异常的解决方案?试试以下方法:
->identityFile('~/.ssh/id_rsa.pub', '~/.ssh/id_rsa', 'pass phrase')
它对我来说非常有用-无需askpass程序。在我的经验中,清晰地表达出来是有帮助的 至于你的phpfm重启任务。。我以前没见过。不需要。:) 编辑: 您提供密码可能是一个好迹象,表明如果您将部署程序代码置于源代码控制之下,您应该对其进行一点重构 我正在从YAML文件加载特定于站点的数据,而不是提交给源代码管理 my
stage.yml的第一位:
# Site Configuration
# -------------
prod_1:
host: hostname
user: username
identity_file:
public_key: /home/user/.ssh/key.pub
private_key: /home/user/.ssh/key
password: "password"
stage: production
repository: https://github.com/user/repository.git
deploy_path: /var/www
app:
debug: false
stage: 'prod'
然后,在我的deploy.php
中:
if (!file_exists (__DIR__ . '/deployer/stage/servers.yml')) {
die('Please create "' . __DIR__ . '/deployer/stage/servers.yml" before continuing.' . "\n");
}
serverList(__DIR__ . '/deployer/stage/servers.yml');
set('repository', '{{repository}}');
set('default_stage', 'production');
请注意,当您使用serverList
时,它将替换deploy.php
中的服务器设置。我假设php fpm重启用于清除opcache。但有更好的解决方案(见)。
// 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');