【发布时间】:2016-01-17 19:49:36
【问题描述】:
我正在使用 justhost(共享主机)在我的子域 dev.domain_name.com 上测试 python django 网页
我使用以下教程:http://flailingmonkey.com/install-django-justhost/ 获得以下输出。
获取以下内容的命令:python mysite.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!
Status: 200 OK
X-Frame-Options: SAMEORIGIN
Content-Type: text/html
<!DOCTYPE html>
<html lang="en"><head>
<meta http-equiv="content-type" content="text/html; charset=utf-8">
<meta name="robots" content="NONE,NOARCHIVE"><title>Welcome to Django</title>
<style type="text/css">
html * { padding:0; margin:0; }
body * { padding:10px 20px; }
body * * { padding:0; }
body { font:small sans-serif; }
body>div { border-bottom:1px solid #ddd; }
h1 { font-weight:normal; }
h2 { margin-bottom:.8em; }
h2 span { font-size:80%; color:#666; font-weight:normal; }
h3 { margin:1em 0 .5em 0; }
h4 { margin:0 0 .5em 0; font-weight: normal; }
table { border:1px solid #ccc; border-collapse: collapse; width:100%; background:white; }
tbody td, tbody th { vertical-align:top; padding:2px 3px; }
thead th {
padding:1px 6px 1px 3px; background:#fefefe; text-align:left;
font-weight:normal; font-size:11px; border:1px solid #ddd;
}
tbody th { width:12em; text-align:right; color:#666; padding-right:.5em; }
#summary { background: #e0ebff; }
#summary h2 { font-weight: normal; color: #666; }
#explanation { background:#eee; }
#instructions { background:#f6f6f6; }
#summary table { border:none; background:transparent; }
</style>
</head>
<body>
<div id="summary">
<h1>It worked!</h1>
<h2>Congratulations on your first Django-powered page.</h2>
</div>
<div id="instructions">
<p>
Of course, you haven't actually done any work yet. Next, start your first app by running <code>python manage.py startapp [app_label]</code>.
</p>
</div>
<div id="explanation">
<p>
You're seeing this message because you have <code>DEBUG = True</code> in your Django settings file and you haven't configured any URLs. Get to work!
</p>
</div>
</body></html>
Tech Stack:
Python 2.7.2
flup 1.0.2
django 1.8.7
**My subdomain dev.domain_name.com returns:**
Not Found The requested URL /mysite.fcgi/ was not found on this server.
Below is .htaccess & mysite.fcgi
[~/public_html/subdomaindirectory]# vi mysite.fcgi
#!/home2/findity/python/bin/python
import sys, os
sys.path.insert(0, "/home2/findity1/python")
path = '/home2/findity1/public_html/findityaardev/mysite'
if path not in sys.path:
sys.path.append(path)
print(sys.path)
os.environ['DJANGO_SETTINGS_MODULE'] = 'mysite.settings'
from django.core.servers.fastcgi import runfastcgi
runfastcgi(method="threaded", daemonize="false")
.htaccess file:
[~/public_html/subdomaindirectory]# vi .htaccess
AddHandler fcgi-script .fcgi
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ /mysite.fcgi/$1 [QSA,L]
注意:我从 cpanel 添加了 .fcgi apache 处理程序,这使我从 500 内部服务器错误变为 404。看起来它是根据命令手动工作的,但是我无法在我的子域中看到它。如果需要更多信息,请告诉我。
【问题讨论】:
-
“它成功了!恭喜你获得了第一个 Django 驱动的页面。” - 这是你第一次启动django时得到的默认页面,什么不起作用?
-
它在域 (dev.domain_name.com) 上不起作用,我收到 404 错误 Not Found 在此服务器上找不到请求的 URL /mysite.fcgi/。当我在服务器“python mysite.fcgi”上手动运行它时,它会显示成功输出,包括以下内容: WSGIServer: missing FastCGI param REQUEST_METHOD required by WSGI! WSGIServer:缺少 WSGI 所需的 FastCGI 参数 SERVER_NAME! WSGIServer:缺少 WSGI 所需的 FastCGI 参数 SERVER_PORT! WSGIServer:缺少 WSGI 所需的 FastCGI 参数 SERVER_PROTOCOL!
-
你能告诉我们一些关于文件夹结构的信息吗?
-
级别 1:子域的根目录:/home2/username/public_html/subdomain/ 级别 2:子域根目录下的文件和文件夹:/home2/username/public_html/subdomain/: mysite.fcgi .htaccess mysite / 级别 3:mysite 下的文件和文件夹:/home2/username/public_html/subdomain/mysite:manage.py 级别 4:/home2/username/public_html/subdomain/mysite/mysite:init.py settings.py settings.pyc urls.py urls.pyc wsgi.py wsgi.pyc
标签: python django shared-hosting