2013-05-13 68 views
0

我已經在softlayer VPS上設置了carrierwave。 Carrierwave提供了將文件保存到本地存儲的選項。Carrierwave VPS符號鏈接不工作

如果我使用符號鏈接public/imagesshared_path/images然後圖像被上傳但不會被渲染。 當我刪除符號鏈接並直接將圖像存儲在public/images中時,我能夠看到圖像,但最少使用它的版本不會具有這些圖像。

我上傳類app/uploader/image_uploader.rb看起來像這樣

class ImageUploader < CarrierWave::Uploader::Base 
    include CarrierWave::MiniMagick 

    storage :file 

    def default_url 
    "/assets/default.gif" 
    end 

    def extension_white_list 
    %w(jpg jpeg gif png) 
    end 

    def store_dir 
    "images" 
    end 
end 

我已經在我的部署腳本

set :shared_children, shared_children + %w{public/images} 

    desc "Symbolic Link for Uploads" 
     task :symlink_uploads, :roles => [:app, :web] do 
     run "rm -rf #{release_path}/public/images && 
       ln -nfs #{shared_path}/images #{release_path}/public/images" 
    end 

    after 'deploy:update_code', 'deploy:symlink_uploads' 

嘗試設置權限也使用符號鏈接。但仍然沒有看到我上傳的圖片。

我獲得以下消息時,我嘗試從瀏覽器

Forbidden 
You don't have permission to access /images/my_profile.jpg on this server. 
Apache/2.2.14 (Ubuntu) Server at example.com Port 80 

還通過 Capistrano and Carrierwave搜索訪問圖像, Carrierwave files with Capistrano

我是否需要設置的目錄可訪問特定的權限? 例如:

chmod 755 shared_path/images 

無法找到任何工作解決方案。 非常感謝您的幫助。

在此先感謝。

回答

0

明白了,這是缺少

Options FollowSymLinks 

apache permissions error

雖然我有Options -Indexes +FollowSymLinks MultiViews

<Directory></Directory>

想知道爲什麼下了+FollowSymLinks不工作