1 php apache ssh virtualhost magento
我相信当你收到警告时,这是一个常见的问题
警告:您的Magento文件夹没有足够的写入权限.
我试过了
find . -type d -exec chmod 777 {} ;
Run Code Online (Sandbox Code Playgroud)
和
find . -type f -exec chmod 755 {} ;
Run Code Online (Sandbox Code Playgroud)
但这并没有帮助,我相信我使用了不同的权限,777但我想保持它更安全...
我有一种感觉,可能是因为我的VirtualHost设置.我的Magento在/var/www/example.com/public_html,VirtualHost部分是功能,因为example.com带你到我的网站.
我不确定./mage正确处理所有事情并且有点痛苦但是我使用SSH这是我唯一的解决方案.
这不是你的Apache设置 - 这个警告与PHP将文件写入文件系统的能力有关.这就是Magento Connect的工作方式 - 当您与GUI前端交互时,PHP会将tgzConnect Packages 下载到您的本地文件系统,然后解压缩并解压缩到您的Magento安装中.PHP需要能够创建文件夹.如果您以非特权用户身份运行apache,并且您的文件夹/文件归特权用户(通常是您的用户帐户)所有,则表示如果要使用Magento Connect GUI安装软件包,则需要提供文件夹777.
什么777意思是计算机上的任何用户帐户都有权在该目录中创建文件.安全风险是,如果黑客设法访问非特权用户帐户,他们将能够在此文件夹中创建文件,以帮助他们进一步利用服务器,或利用Web应用程序本身.如果您在具有多个用户帐户(共享主机)的服务器上,则还意味着其他用户有权在这些文件夹中创建文件.
好的共享托管公司有监控来帮助防止这种情况,但大多数共享托管公司并不好,这个权限问题可能是任何基于PHP的Web应用程序漏洞利用的最常见原因.
此外,Magento Connect GUI因传递有关权限的虚假信息而臭名昭着.您经常遇到报告已成功安装的情况,但却没有.如果遇到这种情况,我会在n98-magerun一段时间后编写一个命令,可以验证连接扩展是否正确安装.
因此,针对您的具体问题,跟踪此问题的最佳方法是查看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>
Run Code Online (Sandbox Code Playgroud)
第一个地方是异常消息
#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.'
);
}
Run Code Online (Sandbox Code Playgroud)
如果你查看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);
Run Code Online (Sandbox Code Playgroud)
在这些行之后添加一些临时调试代码可以帮助您跟踪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..
}
Run Code Online (Sandbox Code Playgroud)
接下来是那些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');?>
Run Code Online (Sandbox Code Playgroud)
它只是在另一个模板中提到.如果我们搜索此packages.phtml模板文件
$ ack 'packages.phtml' downloader
downloader/Maged/Controller.php
315: echo $this->view()->template('connect/packages.phtml');
Run Code Online (Sandbox Code Playgroud)
我们会发现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;
}
Run Code Online (Sandbox Code Playgroud)
同样,一些临时调试代码可以帮助我们弄清楚为什么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'))));
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
454 次 |
| 最近记录: |