2011-03-24 29 views
2

我在本地機器(OSX 10.6.6,Rails3.0.1,WEBrick)中編寫了導軌應用程序。簡單驗證碼正常工作。當我將應用程序推送到我的網絡服務器(Centos5.5,Rails 3.0.1,Phusion Passenger version 3.0.2)時,沒有發現錯誤,但圖像不顯示在站點中。驗證碼圖像不適用於我的製作環境但開發良好

我注意到/tmp有一些文件,如simple_captcha20110324-19769-1bf4hah.jpg。我在我的服務器中打開它,圖像是驗證碼圖像。所以我認爲驗證碼生成工作正常,但在生產環境中出現了問題。我跟蹤過程,發現ioctl(27, SNDCTL_TMR_TIMEBASE or TCGETS, 0x7fffc3fad550) = -1 ENOTTY (Inappropriate ioctl for device)。你有什麼建議嗎?

strace的信息:

... 
stat("/tmp/simple_captcha20110324-3073-14fnzd6.jpg", {st_mode=S_IFREG|0600, st_size=1808, ...}) = 0 
stat("/tmp/simple_captcha20110324-3073-14fnzd6.jpg", {st_mode=S_IFREG|0600, st_size=1808, ...}) = 0 
geteuid()        = 500 
getegid()        = 500 
getuid()        = 500 
getgid()        = 500 
access("/tmp/simple_captcha20110324-3073-14fnzd6.jpg", R_OK) = 0 
open("/tmp/simple_captcha20110324-3073-14fnzd6.jpg", O_RDONLY) = 27 
ioctl(27, SNDCTL_TMR_TIMEBASE or TCGETS, 0x7fffc3fad550) = -1 ENOTTY (Inappropriate ioctl for device) 
brk(0x63b0000)       = 0x63b0000 
write(3, "\n\nStarted GET \"/simple_captcha/e"..., 133) = 133 
clock_gettime(CLOCK_REALTIME, {1300937319, 188732000}) = 0 
writev(11, [{"Status: ", 8}, {"200", 3}, {"\r\n", 2}, {"X-Powered-By: ", 14}, {"Phusion Passenger (mod_rails/mod"..., 44}, {"\r\n", 2}, {"Content-Disposition", 19}, {": ", 2}, {"inline; filename=\"simple_captcha"..., 37}, {"\r\n", 2}, {"Content-Transfer-Encoding", 25}, {": ", 2}, {"binary", 6}, {"\r\n", 2}, {"Content-Type", 12}, {": ", 2}, {"image/jpeg", 10}, {"\r\n", 2}, {"Cache-Control", 13}, {": ", 2}, {"private", 7}, {"\r\n", 2}, {"X-UA-Compatible", 15}, {": ", 2}, {"IE=Edge,chrome=1", 16}, {"\r\n", 2}, {"Set-Cookie", 10}, {": ", 2}, {"_newuser_session=BAh7CEkiD3Nlc3N"..., 275}, {"\r\n", 2}, {"X-Sendfile", 10}, {": ", 2}, ...], 39) = 623 
shutdown(11, 1 /* send */)    = 0 
close(11)        = 0 
... 

UPDATE:

我覺得有些錯誤在https://github.com/galetahub/simple-captcha可能。我選擇了這個分支https://github.com/kares/simple_captcha所有的env工作正常!

回答

0

您應該嘗試在config/environments/production.rb文件中設置config.serve_static_assets = true。

默認情況下,出於性能方面的原因,rails在生產模式下不提供靜態內容。你的網絡服務器應該被配置來做到這一點。

+0

sudo apt-get install imagemagick libmagickwand-dev ....我無法看到簡單的驗證碼圖像,所以找到imagemagick沒有安裝,所以安裝後,我看到圖像:) ..... – 2015-07-13 15:48:32

0

如果我記得captcha在開發和生產環境中有不同的密鑰,您是否已經檢查過它?

+0

simple-captcha does不需要用於開發和生產環境的配置密鑰 – jean 2011-03-24 07:47:49

+0

對不起,我正在使用recaptcha,而這個,需要。 – 2011-03-24 14:29:55

+0

我之前使用它。我認爲,如果人們母語是英語,那麼recaptcha就是一個很好的解決方案。 – jean 2011-03-24 15:44:11

相關問題