【问题标题】:Magento theme crash - Error 500 on theme imagesMagento 主题崩溃 - 主题图像上的错误 500
【发布时间】:2012-04-03 07:38:55
【问题描述】:

我成功创建了几个 magento 主题,它们都在网络服务器上运行良好。因为其他开发人员在网络服务器上进行了一些更改(也运行良好),所以我尝试将所有文​​件从我的主题导入回我的本地系统以应用更少的更改。 在那之后,我在本地主机上的主题突然完全崩溃了。网站的来源是好的,但是应该从 skin/../images 文件夹中加载的所有图像都没有显示。如果我尝试使用浏览器打开它们,我会收到 500 内部服务器错误,但它们存储在文件系统中的正确位置。

所以我检查了一些我早期的主题,但如果我将它们从文件系统或其他文件夹备份到我的 magento 安装中,它们都很好。

所以我终于设置了一个新的本地 magento 安装,但也得到了同样的错误。正如我所说,我的所有其他主题都运行良好,并且具有实际主题的网络服务器到目前为止没有问题。

最好的问候

编辑以回答@Oğuz 的想法

感谢您的回答。 我收到错误后检查了日志,并得到以下信息:

[Sun Mar 18 20:53:24 2012] [crit] [client 127.0.0.1] (13)Permission denied: /var/www/theme/media/catalog/category/.htaccess pcfg_openfile: unable to check htaccess file, ensure it is readable, referer: http://localhost/theme/index.php/apparel/shirts.html
[Sun Mar 18 20:53:25 2012] [error] [client 127.0.0.1] script '/var/www/index.php' not found or unable to stat, referer: http://localhost/theme/index.php/apparel/shirts.html
[Sun Mar 18 20:53:25 2012] [crit] [client 127.0.0.1] (13)Permission denied: /var/www/theme/media/catalog/category/.htaccess pcfg_openfile: unable to check htaccess file, ensure it is readable, referer: http://localhost/theme/index.php/apparel/shirts.html
[Sun Mar 18 20:53:39 2012] [error] [client 127.0.0.1] script '/var/www/index.php' not found or unable to stat, referer: http://localhost/theme/index.php/apparel/shirts/zolof-the-rock-and-roll-destroyer-lol-cat-t-shirt.html
[Sun Mar 18 20:53:39 2012] [error] [client 127.0.0.1] script '/var/www/index.php' not found or unable to stat, referer: http://localhost/theme/index.php/apparel/shirts/zolof-the-rock-and-roll-destroyer-lol-cat-t-shirt.html
[Sun Mar 18 20:54:37 2012] [error] [client 127.0.0.1] client denied by server configuration: /var/www/theme/app/etc/local.xml
[Sun Mar 18 20:54:51 2012] [error] [client 127.0.0.1] script '/var/www/index.php' not found or unable to stat, referer: http://localhost/theme/index.php/apparel/shirts/zolof-the-rock-and-roll-destroyer-lol-cat-t-shirt.html
[Sun Mar 18 20:54:51 2012] [error] [client 127.0.0.1] script '/var/www/index.php' not found or unable to stat, referer: http://localhost/theme/index.php/apparel/shirts/zolof-the-rock-and-roll-destroyer-lol-cat-t-shirt.html
[Sun Mar 18 20:56:33 2012] [error] [client 127.0.0.1] client denied by server configuration: /var/www/theme/app/etc/local.xml
[Sun Mar 18 20:56:41 2012] [error] [client 127.0.0.1] client denied by server configuration: /var/www/theme/app/etc/local.xml
[Sun Mar 18 20:56:49 2012] [alert] [client 127.0.0.1] /var/www/theme/skin/frontend/theme/green/images/.htaccess: Invalid command 'ExpiresDefault', perhaps misspelled or defined by a module not included in the server configuration

我不确定,为什么我会突然得到这些。我尝试先关注 local.xml 问题。

编辑#2

感谢您的所有想法和答案。在检查了我的本地服务器后,我发现,我服务器上托管的几乎每个页面都有这个问题。似乎是 apache 配置文件中某处的错误配置。 我会在下一步尝试修复它。

我还检查了 AllowOverride 指令,但它已经设置为“全部”。

【问题讨论】:

  • 你检查过错误日志,了解 500 错误背后的原因吗?
  • 500 Internal Server 是一个一般错误消息,如果没有看到您的代码/环境,没人知道发生了什么。转到网络服务器日志文件并检查那里发生了什么!

标签: magento webserver


【解决方案1】:

这是一个可能的解决方案:

在文件开头添加这一行:

$_baseMedia = Mage::getSingleton('catalog/product_media_config')->getBaseMediaPath();

然后当你包含图像而不是:

echo "<img src=".$this->helper('catalog/image')->init($_product, "image_2")->resize(500, 500);.">";

添加这个:

if(is_file($_baseMedia.$_product->$getImage2())){
    echo "<img src=".$this->helper('catalog/image')->init($_product, "image_2")->resize(500, 500);.">";
 }

这会检查损坏的图像,因此如果找不到图像,magento 不会抛出错误。如果 Magento 找不到可能是 500 错误的原因的图像,则会引发致命错误。

【讨论】:

    【解决方案2】:

    一步一步,首先尝试以下(应该在magento根目录下运行):

    $ find . -type f -exec chmod 644 {} \;
    $ find . -type d -exec chmod 750 {} \;
    $ chmod o+w var var/.htaccess includes includes/config.php app/etc
    $ chmod -R o+w media
    $ chmod -R 777 /lib/PEAR
    $ a2enmod expires
    

    打开 apache 配置文件(或 .htaccess)并在 directory 指令中更改以下内容,这是您的 magento 根目录。

    AllowOverride All
    Order allow,deny
    Allow from all  
    

    如下:

    <Directory /var/www/magento>
        Options Indexes FollowSymLinks MultiViews
        AllowOverride All
        Order allow,deny
        allow from all
    </Directory>
    

    【讨论】:

      【解决方案3】:

      最后,我重新安装了 apache 并解决了我在加载图像时遇到的所有问题。 我无法指定问题的根源,但重新安装为我解决了问题。

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2019-01-01
        • 1970-01-01
        • 2020-03-27
        • 2020-01-04
        • 1970-01-01
        相关资源
        最近更新 更多