Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/321.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/django/22.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
PythonDjango网页手动工作,但域在共享主机上出现404错误_Python_Django_Shared Hosting - Fatal编程技术网

PythonDjango网页手动工作,但域在共享主机上出现404错误

PythonDjango网页手动工作,但域在共享主机上出现404错误,python,django,shared-hosting,Python,Django,Shared Hosting,我正在使用justhost(共享主机)在我的子域dev.domain_name.com上测试python django网页 我使用了以下教程:获得以下输出 命令获取以下内容:python mysite.fcgi WSGIServer: missing FastCGI param REQUEST_METHOD required by WSGI! WSGIServer: missing FastCGI param SERVER_NAME required by WSGI! WSGIServer: m

我正在使用justhost(共享主机)在我的子域dev.domain_name.com上测试python django网页

我使用了以下教程:获得以下输出

命令获取以下内容: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。它看起来像是根据命令手动工作,但是我无法在我的子域中看到它。如果需要更多信息,请务必告诉我。

首先查看以下文档中的注释:

自1.7版起:
FastCGI支持已弃用,将在Django 1.9中删除

因此,可能会首选另一种方法

我注意到您的
mysite.fcgi
有一个print语句。删除它,我认为fastcgi进程无法访问stdout()。这可能会造成问题

如果这不能解决问题,那么首先要做的就是尝试并确定错误在哪里。我认为最有可能发生在以下地点之一:

  • 重定向不起作用
  • 或者Apache找不到mysite.fcgi
  • 或者mysite.fcgi调用Django,Django返回404
  • 或者Django正在工作,但是使用返回404的视图

查看Apache
error.log文件,查看是否有任何线索表明其中哪一个是问题区域。

首先查看:

自1.7版起:
FastCGI支持已弃用,将在Django 1.9中删除

因此,可能会首选另一种方法

我注意到您的
mysite.fcgi
有一个print语句。删除它,我认为fastcgi进程无法访问stdout()。这可能会造成问题

如果这不能解决问题,那么首先要做的就是尝试并确定错误在哪里。我认为最有可能发生在以下地点之一:

  • 重定向不起作用
  • 或者Apache找不到mysite.fcgi
  • 或者mysite.fcgi调用Django,Django返回404
  • 或者Django正在工作,但是使用返回404的视图

  • 查看Apache
    error.log文件,查看是否有任何线索表明其中哪一个是问题区域。

    下一个是my.htaccess和django.fcgi文件。
    这些文件在JustHost中正常工作。 我目前正在Justhost中使用此配置运行3个Django支持的网站

    AddHandler fcgid-script .fcgi
    RewriteEngine On
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule ^(.*)$ django.fcgi/$1 [QSA,L]
    
    我使用的是一个简约的.fcgi文件(在我的例子中是django.fcgi)

    编辑:

    我正在使用Django 1.8.x。我目前没有任何使用Django 1.9.x的项目,下一个是我的.htaccess和Django.fcgi文件。
    这些文件在JustHost中正常工作。 我目前正在Justhost中使用此配置运行3个Django支持的网站

    AddHandler fcgid-script .fcgi
    RewriteEngine On
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule ^(.*)$ django.fcgi/$1 [QSA,L]
    
    我使用的是一个简约的.fcgi文件(在我的例子中是django.fcgi)

    编辑:

    我正在使用Django 1.8.x。我目前没有任何Django 1.9.x版本的项目“成功了!祝贺你第一个使用Django的页面。”-这是你第一次启动Django时得到的默认页面,什么不起作用了?它在域(dev.domain_name.com)上不起作用,我收到一个404错误,未找到此服务器上请求的URL/mysite.fcgi/。当我在服务器“python mysite.fcgi”上手动运行它时,它显示了成功输出,包括:WSGIServer:missing FastCGI-param-REQUEST\u WSGI所需的方法!WSGIServer:缺少WSGI所需的FastCGI参数服务器名称!WSGIServer:缺少WSGI所需的FastCGI参数服务器\u端口!WSGIServer:缺少WSGI所需的FastCGI param SERVER_协议!你能告诉我们一些关于文件夹结构的信息吗?级别1:子域根目录:/home2/username/public\u html/subdomain/级别2:子域根目录下的文件和文件夹:/home2/username/public\u html/subdomain/:mysite.fcgi.htaccess mysite/Level 3:mysite下的文件和文件夹:/home2/username/public\u 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“成功了!祝贺你第一个使用Django的页面。”-这是你第一次启动Django时得到的默认页面,什么不起作用?它在域上不起作用(dev.domain_name.com),我收到一个404错误“找不到”请求的URL/mysite.fcgi/在此服务器上找不到。当我在服务器“python mysite.fcgi”上手动运行它时,它显示了成功输出,包括:WSGIServer:missing FastCGI-param-REQUEST\u WSGI所需的方法!WSGIServer:缺少WSGI所需的FastCGI参数服务器名称!WSGIServer:缺少WSGI所需的FastCGI参数服务器\u端口!WSGIServer:缺少WSGI所需的FastCGI param SERVER_协议!你能告诉我们一些关于文件夹结构的信息吗?级别1:子域根目录:/home2/username/public\u html/subdomain/级别2:子域根目录下的文件和文件夹:/home2/username/public\u html/subdomain/:mysite.fcgi.htaccess mysite/Level 3:mysite下的文件和文件夹:/home2/username/public\u html/subdomain/mysite:manage.py级别4:/home2/username/public_html/subdomain/mysite/mysite:init.py settings.py settings.pyc url.py url.pyc wsgi.py wsgi.pycThanks Brian,我删除了注释,但没有区别,我当前在我的url上收到[处理此指令时出错]。不幸的是,由于共享主机,我无法访问apache设置和日志。我使用的是1.8.7 django,它具有fastcgi库,并且在共享主机上运行命令python mysite.fcgi会提供上述输出,因此它能够识别fastcgi。我相信可能是我的.htaccess文件(尤其是路径)造成了问题。谢谢Brian,我删除了注释,但没有区别,我目前在我的url上收到了[处理此指令时出错]。不幸的是,自从ApacheSettin