回形针图像无法保存在生产轨道中

我刚刚部署了一个rails应用程序,它使用Paperclip处理文件上传到运行apache2,passenger,rails 3.2.3和ruby 1.9.3的linux ubuntu 10.04服务器。

我的设置在开发中完美无缺,但是现在生产中的图像永远不会保存。

我在production.rb中注释掉了以下几行,以便rails处理文件上传,并尝试使用和安装XSendFile。

# Specifies the header that your server uses for sending files # config.action_dispatch.x_sendfile_header = "X-Sendfile" # for apache # config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect' # for nginx 

和我的照片.rb

 attr_accessible :photo_file_name, :photo_file_size, :photo_content_type, :photo, :splash_image validates_presence_of :photo_file_name, :photo_content_type, :photo_file_size has_attached_file :photo, styles: { thumb: "150x150>" }, url: "/assets/splash_images/:id/:style/:basename.:extension", path: ":rails_root/public/assets/splash_images/:id/:style/:basename.:extension" validates_attachment_size :photo, :less_than => 25.megabytes validates_attachment_content_type :photo, content_type: /image/ 

有谁知道会发生什么? 非常感谢

如果未在默认路径上安装ImageMagick,则需要指定路径。 对于Windows用户,在initializers / paperclip.rb中执行以下操作:

要求“paperclip”需要’rbconfig’is_windows =(RbConfig :: CONFIG [‘host_os’] =〜/ mswin | mingw | cygwin /)

Paperclip.options [:command_path] =’C:\ ImageMagick’如果is_windows Paperclip.options [:swallow_stderr] = false

在imagemagick路径中找到“识别”的位置并将其放在此处。 当然,你需要把linux路径放在那里。 (/ usr / bin / …)

感谢Meduza和Hugo指出我正确的方向。 为了成功上传和保存图像,我必须在linux服务器上安装Imagemagick,并对图像路径赋予写权限,如下所示:

如果没有从root运行,请附加sudo

  apt-get install imagemagick apt-get install libmagick9-dev gem install rmagick chmod -R 777 app/app_name/public/assets/image_folder