我正在开发一个即将上线的Magento网站,我set the permissions of the Magento project as recommended by Magento使用下面的shell脚本。
#!/bin/bash
# Script to set permissions on Magento as recommeneded in the Magento Docs
# http://devdocs.magento.com/guides/m1x/install/installer-privileges_after.html
find . -type f -exec chmod 400 {} \;
find . -type d -exec chmod 500 {} \;
find var/ -type f -exec chmod 600 {} \;
find media/ -type f -exec chmod 600 {} \;
find var/ -type d -exec chmod 700 {} \;
find media/ -type d -exec chmod 700 {} \;
但是,在执行此脚本后,我无法再执行git pull
,我收到ssh
错误,说它无法解析主机名并检查我的访问权限。
$ sudo git pull
ssh: Could not resolve hostname our-git-repo: Name or service not known
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
our-git-repo
是host
文件中设置的~./.ssh/config
。
当我以递归方式将Magento项目根目录的权限更改为777时,我可以解决此问题,因此我可以成功执行git pull
。
$ sudo chmod 777 -R /var/www/magento-project/
$ git pull
remote: Counting objects: 11, done.
remote: Compressing objects: 100% (4/4), done.
remote: Total 4 (delta 3), reused 0 (delta 0)
Unpacking objects: 100% (4/4), done.
From our-git-repo:/var/git/magento-project
175..........376 master -> origin/master
fa8..........d24 magento-uat -> origin/magento-uat
Updating 175e490..d6f8376
Fast-forward
.gitignore | 1 +
1 file changed, 1 insertion(+)
1。为什么Magento项目中的文件夹权限会影响 ssh ?
ssh: Could not resolve hostname our-git-repo: Name or service not known
2。我应该在shell脚本中设置哪些权限,以便git pull
有效?
即使在.git/
目录上设置了正确的权限,我仍然遇到同样的问题。
我认为这必须与所有权有关,当我sudo su
进入root并运行ls -al
命令以查看{{1}上的permisons和所有权时我没有看到该文件夹的全部内容。
知道为什么吗?这可能是问题的原因吗?
~./.ssh/
答案 0 :(得分:3)
重要文件夹是项目中的.git
文件夹。将Git用户的写入权限设置为该文件夹。例如:
chmod -R 755 .git/
然后它应该工作。您不需要设置完整的文件夹。