簡體   English   中英

共享主機中的python MemoryError

[英]python MemoryError in shared hosting

我試圖在不特定於Django的共享Web主機上部署Django。 Host提供了已安裝的python的舊版本,但是由於我具有ssh訪問能力,因此我設法通過將其安裝在本地文件夾中的本地模塊來擴展python安裝所需的模塊(包括Django)。 好的,所以我創建了django項目,進行了需要做的調整(設置PYTHONPATH和PATH全局變量等),制作了django.fcgi腳本,該腳本啟動django,並從shell中執行了./django.fcgi。 這是響應:

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並很好地運行它。 我確實曾向我的網絡托管支持尋求幫助,但沒有任何可用的答案。 另外,由於他們是轉銷商,所以我不確定他們能提供多少幫助。

有辦法解決這個問題嗎? 任何建議都歡迎。

提前致謝

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

#!/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")

這就是我的配置。 我必須承認有一點錯誤(解釋器路徑),但是“設置”文件路徑很好。

修正解釋路徑,以正確的之后,首先我得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文件是否仍然對.fcgi腳本具有正確的RewriteRule

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM