从php脚本运行git pull
发布时间:2020-12-13 16:33:45 所属栏目:PHP教程 来源:网络整理
导读:我正在尝试 Perfect Workflow,with Git,GitHub,and SSH,我有一切设置,除了从php运行命令git pull. 当我运行exec(‘git pull’)我得到: Could not create directory ‘/.ssh’. Host key verification failed. fatal: The remote end hung up unexpectedly
我正在尝试
Perfect Workflow,with Git,GitHub,and SSH,我有一切设置,除了从php运行命令git pull.
当我运行exec(‘git pull’)我得到:
如果我在终端(以root身份)运行它,它的工作原理很好,但是我需要这个钩子才能从Post-Receive URL(Github)工作. 如果我执行exec(‘whoami’)我得到apache. 这是一个(dv)从CentOS的mediatemple.
如果您希望apache(用户)能够从git中拉取,则必须为apache创建一个ssh密钥,然后将其添加到github上的只读密钥.
流动是这样的(调整你的需要) usermod -s /bin/bash apache su apache cd ~ ssh-keygen # work through the keygen dance (added a dash) 上传(这里指的是apache的homedir)?/ .ssh / id_rsa.pub到github并给予apache访问需要从哪个repos. 那么你可以在服务器上再次测试一下apache并运行git pull su apache cd ~/working-copy git clone my-project 一旦工作,你应该能够通过PHP运行git. (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |