OSError:[Errno 22]无效参数,在共享主机上运行Django

时间:2017-01-28 19:43:14

标签: python django cgi shared-hosting

我正在将我的网络迁移到另一台服务器,并且我正在为django工作设置所有内容。 我可以解决很多问题,但这个问题打败了我。我不知道是什么原因造成的。

这是日志:

Traceback (most recent call last):
  File "/home/usuario/public_html/cgi-bin/dispatch.cgi", line 24, in <module>
    runfastcgi(method="threaded", daemonize="false")
  File "/home/usuario/test/lib/python3.4/site-packages/django/core/servers/fastcgi.py", line 182, in runfastcgi
    WSGIServer(get_internal_wsgi_application(), **wsgi_opts).run()
  File "/home/usuario/test/lib/python3.4/site-packages/flup/server/fcgi.py", line 114, in run
    ret = ThreadedServer.run(self, sock)
  File "/home/usuario/test/lib/python3.4/site-packages/flup/server/threadedserver.py", line 85, in run
    clientSock, addr = sock.accept()
  File "/home/usuario/test/lib/python3.4/socket.py", line 184, in accept
    fd, addr = self._accept()
OSError: [Errno 22] Invalid argument

htaccess的:

AddHandler dispatch.cgi
Options +FollowSymLinks
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_URI} !(cgi-bin/dispatch.cgi)
RewriteRule ^(.*)$ cgi-bin/dispatch.cgi/$1 [L]

dispatch.cgi:

#!/home/usuario/test/bin/python3.4m
import sys, os
import traceback

sys.path += ['/home/usuario/app-test']
os.environ['LD_LIBRARY_PATH'] = '/home/usuario/test/lib'

#Switch to new python
PYTHON_EXE = '/home/usuario/test/bin/python3.4'

sys.path.insert(0,'home/usuario/test/bin')
sys.path.insert(0,'home/usuario/test/lib/python3.4/site-packages/django')
sys.path.insert(0,'home/usuario/test/lib/python3.4/site-packages/flup')
sys.path.insert(0,'home/usuario/test/lib/python3.4/site-packages')

os.environ['DJANGO_SETTINGS_MODULE'] = "app.settings"

try:
    from django.core.servers.fastcgi import runfastcgi
    runfastcgi(method="threaded", daemonize="false")
except:
    traceback.print_exc(file=open('/home/usuario/public_html/log.txt','w'))

重要的是要指出我在服务器上没有ssh访问权限,因此如果有人提出解决方案,则必须不需要ssh。 这是配置问题吗?还是服务器端?如果是,是否有解决方法?

我使用python 3.4和Django 1.6.5

0 个答案:

没有答案