我正在开发Sylius 1.5项目,在我的本地环境上一切正常,但是当部署到我的开发环境时,我在过滤后的图像上出现错误(使用liipimagine过滤器)。
环境由运行sylius的docker php-apache容器组成。主机代理对Docker容器的请求。
这是我尝试在浏览器中加载图片的网址时遇到的错误:
Unable to create image for path "b4/11/650996cb08ee2b5fef5dfc75b8b4.jpeg" and filter "sylius_shop_product_thumbnail". Message was "Unable to open image /var/www/html/public/media/image/b4/11/650996cb08ee2b5fef5dfc75b8b4.jpeg"
错误发生在这里:in vendor/imagine/imagine/lib/Imagine/Gd/Imagine.php (line 96)
观察:
以下是发生错误的代码:
public function open($path)
{
$path = $this->checkPath($path);
$data = @file_get_contents($path);
if (false === $data) {
throw new RuntimeException(sprintf('Failed to open file %s', $path));
}
$resource = @imagecreatefromstring($data);
if (!is_resource($resource)) {
throw new RuntimeException(sprintf('Unable to open image %s', $path));
}
return $this->wrap($resource, new RGB(), $this->getMetadataReader()->readFile($path));
}
我尝试转储变量,并且似乎可以成功使用file_get_contents从文件中获取数据,但是imagecreatefromstring失败。
这是Apache配置:
NameVirtualHost 127.0.0.1:8000
Listen 127.0.0.1:8000
LimitRequestBody 10485760
<VirtualHost 127.0.0.1:8000>
ProxyPreserveHost On
DocumentRoot "/var/www/html"
DirectoryIndex index.php
<Directory "/var/www/html">
AllowOverride All
Allow from All
</Directory>
</VirtualHost>
Nginx配置:
server {
listen 80;
client_max_body_size 10M;
server_name mydomain.com;
location / {
proxy_pass http://127.0.0.1:8092;
include /etc/nginx/proxy_params;
}
}
我在弄清楚配置中有什么导致此错误的过程中遇到了麻烦。