好的,我在 Bluehost 的共享服务器上遇到了这个问题,我找不到任何想法。
我已经上传了我的应用程序,除了一件事,我正在使用的照片上传器(这是网站的核心)之外,一切似乎都运行良好。我正在使用 stdimage2 Django 应用程序(stdimage 的一个分支),它在开发服务器(Ubuntu 10.04)上运行良好。但目前它遇到了重大问题,我正在寻找任何可能的想法或我所缺少的东西的暗示。
以下是正在打印的错误(上传者将四张图片作为单独的请求一个接一个地发送):
[Wed Dec 21 09:47:03 2011] [warn] [client 128.187.97.6] (104)Connection reset by peer: mod_fcgid: error reading data from FastCGI server, referer: http://gallery.fernstenfamily.com/backend/upload/1/
[Wed Dec 21 09:47:03 2011] [error] [client 128.187.97.6] Premature end of script headers: mySite.fcgi, referer: http://gallery.fernstenfamily.com/backend/upload/1/
[Wed Dec 21 09:47:03 2011] [warn] RewriteCond: NoCase option for non-regex pattern '-f' is not supported and will be ignored.
[Wed Dec 21 09:47:03 2011] [warn] [client 128.187.97.6] (104)Connection reset by peer: mod_fcgid: error reading data from FastCGI server, referer: http://gallery.fernstenfamily.com/backend/upload/1/
[Wed Dec 21 09:47:03 2011] [error] [client 128.187.97.6] Premature end of script headers: mySite.fcgi, referer: http://gallery.fernstenfamily.com/backend/upload/1/
[Wed Dec 21 09:47:04 2011] [warn] [client 128.187.97.6] (104)Connection reset by peer: mod_fcgid: error reading data from FastCGI server, referer: http://gallery.fernstenfamily.com/backend/upload/1/
[Wed Dec 21 09:47:04 2011] [error] [client 128.187.97.6] Premature end of script headers: mySite.fcgi, referer: http://gallery.fernstenfamily.com/backend/upload/1/
[Wed Dec 21 09:47:05 2011] [error] mod_fcgid: process /home3/fernsten/public_html/ffamily/gallery/mySite.fcgi(22492) exit(communication error), get unexpected signal 11
这是我的 fcgi 文件的样子:
#!/home3/fernsten/local/Python-2.7/bin/python
import sys, os
print "sys.path is ", sys.path
#add a custom Python path and pray it works dddd
sys.path.insert(0, "/home3/fernsten/local/lib/python2.7/site-packages")
sys.path.insert(0, "/home3/fernsten/local/lib/python2.7")
sys.path.insert(0, "/home3/fernsten/local/lib/python2.7/site-packages/flup-1.0.2-py2.7.egg")
sys.path.insert(0, "/home3/fernsten/django_projects")
sys.path.insert(0, "/home3/fernsten/django_projects/gallery")
sys.path.insert(0, "/home3/fernsten/local/lib/python2.7/site-packages/MySQL_python-1.2.3- py2.7-linux-x86_64.egg")
os.chdir("/home3/fernsten/django_projects/gallery")
os.environ['DJANGO_SETTINGS_MODULE'] = "gallery.settings"
from django.core.servers.fastcgi import runfastcgi
runfastcgi(method="threaded", daemonize="false")
最后是它死亡的函数:
if request.method == 'POST':
result = []
newform = Photo()
newform.image= request.FILES.get('file')
newform.album=Album.objects.get(pk=album_pk)
newform.save()
result.append({"name":"Uploaded image",
"size":newform.image.size,
"url":MEDIA_URL + newform.image.url,
"thumbnail_url": newform.image.url.replace(".",".thumbnail."),
"delete_url":'/backend/delete_img/' + str(newform.pk)+'/',
"delete_type":"POST",
})
response_data = simplejson.dumps(result)
return HttpResponse(response_data, mimetype='application/json')
return render_to_response('backend/upload_images.html',{'album_pk':album_pk},context_instance=RequestContext(request))
我相当肯定它正在这个区域发生,因为当我执行 newform.save() stdimage2 时,它会在后台执行操作,例如重命名上传的图片以及创建和命名缩略图。正在重命名图像,但未生成缩略图。
任何想法都会很棒,因为我无法找到很多关于可能出错的地方。
更新
我也无法使用 Django 中的管理界面上传图像。好吧,我可以上传图像,但那时它会中断。StdImage2 根据模型定义更改上传的图像名称,但不创建缩略图。在数据库中,它使用上传的图像名称存储图像的 URL,而不是生成的图像。
为了覆盖我的所有基础,我从服务器复制了文件并在本地运行它,完全没有任何问题。这只会引起更多的困惑和沮丧。
更新 2
在使用 Django shell 并以这种方式尝试之后(至少我希望我做得正确,我收到以下错误:
image = Image.open('/home3/fernsten/www/ffamily/media/media/albums/1/image_1.jpeg')
>>> newform.image = image
>>> newform.album = Album.objects.get(pk=1)
>>> newform.save()
Traceback (most recent call last):
File "<console>", line 1, in <module>
File "/home3/fernsten/local/lib/python2.7/site-packages/django/db/models/base.py", line 460, in save self.save_base(using=using, force_insert=force_insert, force_update=force_update)
File "/home3/fernsten/local/lib/python2.7/site-packages/django/db/models/base.py", line 543, in save_base for f in meta.local_fields if not isinstance(f, AutoField)]
File "/home3/fernsten/local/lib/python2.7/site-packages/django/db/models/fields/files.py", line 253, in pre_save
if file and not file._committed:
File "/home3/fernsten/local/lib/python2.7/site-packages/PIL/Image.py", line 512, in __getattr__
raise AttributeError(name)
AttributeError: _committed