共享主机中的python MemoryError



我试图将django部署在一个共享的网站主机上,而不是django特定的。主机提供旧版本的python安装,但因为我有ssh访问能力,我已经设法扩展python安装与模块,我需要(包括django)通过安装在本地我的主文件夹。好了,我创建了django项目,做了一些需要做的调整(设置PYTHONPATH和PATH全局变量等),制作了django。Fcgi脚本,用于启动django并执行。/django。Fcgi来自shell。这是响应:

WSGIServer: missing FastCGI param REQUEST_METHOD required by WSGI!
WSGIServer: missing FastCGI param SERVER_NAME required by WSGI!
WSGIServer: missing FastCGI param SERVER_PORT required by WSGI!
WSGIServer: missing FastCGI param SERVER_PROTOCOL required by WSGI!
Traceback (most recent call last):
  File "/home/tentacle/lib/python2.4/site-packages/flup-1.0.3.dev_20110405-py2.4.egg/flup/server/fcgi_base.py", line 574, in run
    protocolStatus, appStatus = self.server.handler(self)
  File "/home/tentacle/lib/python2.4/site-packages/flup-1.0.3.dev_20110405-py2.4.egg/flup/server/fcgi_base.py", line 1159, in handler
    result = self.application(environ, start_response)
  File "/home/tentacle/lib/python2.4/site-packages/django/core/handlers/wsgi.py", line 272, in __call__
    response = self.get_response(request)
  File "/home/tentacle/lib/python2.4/site-packages/django/core/handlers/base.py", line 169, in get_response
    response = self.handle_uncaught_exception(request, resolver, sys.exc_info())
  File "/home/tentacle/lib/python2.4/site-packages/django/core/handlers/base.py", line 202, in handle_uncaught_exception
    from django.views import debug
  File "/home/tentacle/lib/python2.4/site-packages/django/views/debug.py", line 9, in <module>
    from django.template import (Template, Context, TemplateDoesNotExist,
  File "/home/tentacle/lib/python2.4/site-packages/django/template/__init__.py", line 53, in <module>
    from django.template.base import (ALLOWED_VARIABLE_CHARS, BLOCK_TAG_END,
MemoryError
Status: 500 Internal Server Error
Content-Type: text/html
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<html><head>
<title>Unhandled Exception</title>
</head><body>
<h1>Unhandled Exception</h1>
<p>An unhandled exception was thrown by the application.</p>
</body></html>

所以,我知道这个问题是关于有限的内存为我的用户(错吗?),但它是如此之低,我不能运行裸django?更糟糕的是,一个月前,同一个提供商给了我一个测试帐户,我不仅可以运行django,还可以在本地安装新版本的python,并且运行得很好。我确实向我的虚拟主机支持寻求帮助,但我没有得到任何可用的答案。而且因为他们是经销商,我不太确定他们能帮多少忙。

有办法克服这个问题吗?欢迎提出任何建议。

Thanks in advance

----------------------------------- 更新 --------------------------------------------------

#!/home/<username>/bin/python
import os, sys
sys.path.insert(0, "/home/<username>/djangoprojects")
sys.path.insert(0, "/home/<username>/djangoprojects/testproject")
os.environ['PATH']= "/home/<username>/bin:"+os.environ['PATH']
os.environ['DJANGO_SETTINGS_MODULE'] = 'testproject.settings'
from django.core.servers.fastcgi import runfastcgi
runfastcgi(method="threaded", daemonize="false")

这就是我的配置。我必须承认有一点错误(解释器路径),但是'settings'文件路径是好的。

在纠正解释器路径到正确的一个之后,首先我得到了StringError (django文件中的一些三重引号文档字符串没有关闭- hm,几乎没有),然后在下一次运行MemoryError,然后再次MemoryError等等。过了一会儿(一个小时),我试图再次执行脚本(没有进一步的更改),并不断结束与分割错误(核心转储)

有什么建议吗?

从命令行运行时,需要显式指定Django参数。假设您在与settings.py所在文件夹相同的文件夹中运行脚本:

import os, sys
sys.path.append(os.path.dirname(os.path.abspath(__file__)))
os.environ['DJANGO_SETTINGS_MODULE'] = 'settings'
# ... rest of your startup script...

另外,检查您的.htaccess文件是否仍然有一个正确的RewriteRule到您的.fcgi脚本。

最新更新