我相信这是常见的问题,当您收到警告
Warning: Your Magento folder does not have sufficient write permissions.
我试过了
find . -type d -exec chmod 777 {} ;
和
find . -type f -exec chmod 755 {} ;
但这无济于事,我相信我使用了与
777不同的权限,但我想使其更加安全...
我感觉可能是因为我的VirtualHost设置。我的Magento位于
/var/www/example.com/public_html,VirtualHost部分起作用,因为
example.com将您带到我的站点。
我不确定
./mage是否可以正确处理所有问题,有点麻烦,但是我使用SSH,因此这是我唯一的解决方案。
请您参考如下方法:
这将不是您的Apache设置-此警告与PHP将文件写入文件系统的能力有关。这就是Magento Connect的工作方式-当您与GUI前端交互时,PHP将tgz Connect软件包下载到本地文件系统,然后将其解压缩并解压缩到您的Magento安装中。 PHP需要具有创建文件夹的功能。如果您以非特权用户身份运行apache,并且您的文件夹/文件由特权用户(通常是您的用户帐户)拥有,这意味着如果您想使用Magento Connect GUI安装软件包,则需要来提供文件夹777。 。777的意思是计算机上的任何用户帐户都有权在该目录中创建文件。安全风险是,如果黑客设法访问了非特权用户帐户,则他们将能够在此文件夹中创建文件,以帮助他们进一步利用服务器或利用Web应用程序本身。如果您使用的服务器上有多个用户帐户(共享主机),则这也意味着其他用户有权在这些文件夹中创建文件。
好的共享托管公司会进行监视以帮助防止这种情况的发生,但是大多数共享托管公司都不好,并且此权限问题可能是利用攻击任何基于基于PHP的Web应用程序的最常见原因。
同样,Magento Connect GUI因传递有关权限的错误信息而臭名昭著。您经常会遇到这样的情况,即它报告已成功安装某些东西,但未成功安装。如果遇到这种情况,我会在不久前写了一个n98-magerun命令,可以正确安装或不正确安装validate a connect extension。
因此,对于您的特定问题,最好的跟踪方法是查看Magento Connect的源代码并确定它认为具有错误权限的文件/文件夹。
$ ack 'Your Magento folder does not have sufficient write permissions' downloader
downloader/lib/Mage/Connect/Command/Install.php
105: 'Your Magento folder does not have sufficient write permissions, which downloader requires.'
downloader/template/install/writable.phtml
32:<p>Your Magento folder does not have sufficient write permissions, which this web based downloader requires.</p>
downloader/template/writable.phtml
28: <h4>Warning: Your Magento folder does not have sufficient write permissions.</h4>
首先是异常消息
#File: downloader/lib/Mage/Connect/Command/Install.php
if (!$isWritable) {
$this->doError($command, $err);
throw new Exception(
'Your Magento folder does not have sufficient write permissions, which downloader requires.'
);
}
如果您在try块中查看,则会看到
isWritable可以设置为false的两个地方
$isWritable = is_writable($config->magento_root)
&& is_writable($config->magento_root . DIRECTORY_SEPARATOR . $config->downloader_path)
&& is_writable($config->magento_root . $dirCache)
&& is_writable($config->magento_root . $dirTmp)
&& is_writable($config->magento_root . $dirMedia);
$isWritable = $isWritable && is_writable($config->magento_root . $dirMedia)
&& is_writable($config->magento_root . $dirCache)
&& is_writable($config->magento_root . $dirTmp);
在这些行之后添加一些临时调试代码可以帮助您找到Magento认为没有写权限的目录。
if(!$isWritable)
{
var_dump($config->magento_root);
var_dump(is_writable($config->magento_root));
var_dump($config->magento_root . $dirCache);
var_dump(is_writable($config->magento_root . $dirCache));
//etc..
}
接下来是这些
writable.phtml模板文件。 Magento connect有其自己的简单模板系统,因此我们要搜索呈现这些
writable.phtml templates的位置
$ ack 'writable.phtml' downloader
downloader/template/connect/packages.phtml
28:<?php if ($this->get('writable_warning')) echo $this->template('writable.phtml');?>
仅在 中提到另一个模板。如果我们搜索此
packages.phtml模板文件
$ ack 'packages.phtml' downloader
downloader/Maged/Controller.php
315: echo $this->view()->template('connect/packages.phtml');
我们会发现
writable_warning变量设置为
isWritable方法
File: downloader/Maged/Controller.php
if (!$this->isWritable() && empty($remoteConfig)) {
$this->view()->set('writable_warning', true);
}
public function isWritable()
{
if (is_null($this->_writable)) {
$this->_writable = is_writable($this->getMageDir() . DIRECTORY_SEPARATOR)
&& is_writable($this->filepath())
&& (!file_exists($this->filepath('config.ini') || is_writable($this->filepath('config.ini'))));
}
return $this->_writable;
}
同样,一些临时的调试代码可以帮助我们弄清楚为什么Magento认为它没有正确的权限。
if (is_null($this->_writable)) {
var_dump(is_writable($this->getMageDir() . DIRECTORY_SEPARATOR));
var_dump(is_writable($this->filepath()));
var_dump((!file_exists($this->filepath('config.ini') || is_writable($this->filepath('config.ini'));
//etc...
$this->_writable = is_writable($this->getMageDir() . DIRECTORY_SEPARATOR)
&& is_writable($this->filepath())
&& (!file_exists($this->filepath('config.ini') || is_writable($this->filepath('config.ini'))));
}




