python 404使用Cpanel部署Django时出错

gjmwrych  于 2023-02-07  发布在  Python
关注(0)|答案(1)|浏览(111)

我最近把我的Django应用程序部署到了我的Linux CPanel共享主机上,在测试之后,一切都很好,但是部署之后不久,每当用户尝试导航到一个URL时,我的应用程序都会显示404 Not Found页面(包括内置的Django管理面板)。
以下是我的部署网站:https://covid19.africansurveyors.net
我联系了我的托管服务提供商,为我检查问题可能在哪里,但不幸的是,它没有得到解决,因为他们提到的代码错误。所以我然后把我的应用程序Heroku和管理部署。
Heroku应用程序(仍为同一应用程序)的URL为:该应用程序在Heroku上运行得非常好,但在CPanel共享主机上运行不好。
我还检查了我的服务器日志文件的--tail,这是出现的问题。

App 2247037 output: wsgi = imp.load_source('wsgi', 'passenger_wsgi.py')
App 2247037 output:   File "/home/<my_username>/virtualenv/public_html/covid19.africansurveyors.net/3.7/lib64/python3.7/imp.py", line 169, in load_source
App 2247037 output:     
App 2247037 output: module = _exec(spec, sys.modules[name])
App 2247037 output:   File "<frozen importlib._bootstrap>", line 623, in _exec
App 2247037 output:   File "<frozen importlib._bootstrap>", line 568, in _init_module_attrs
App 2247037 output:   File "<frozen importlib._bootstrap>", line 409, in cached
App 2247037 output:   File "<frozen importlib._bootstrap_external>", line 372, in _get_cached
App 2247037 output:   File "<frozen importlib._bootstrap_external>", line 296, in cache_from_source
App 2247037 output: RecursionError
App 2247037 output: : maximum recursion depth exceeded while calling a Python object
App 2388434 output: /opt/passenger-5.3.7-9.el6.cloudlinux/src/helper-scripts/wsgi-loader.py:26: DeprecationWarning: the imp module is deprecated in favour of importlib; see the module's documentation for alternative uses
App 2388434 output:   import sys, os, io, re, imp, threading, signal, traceback, socket, select, struct, logging, errno
App 436449 output: /opt/passenger-5.3.7-9.el6.cloudlinux/src/helper-scripts/wsgi-loader.py:26: DeprecationWarning: the imp module is deprecated in favour of importlib; see the module's documentation for alternative uses
App 436449 output:   import sys, os, io, re, imp, threading, signal, traceback, socket, select, struct, logging, errno
App 439960 output: /opt/passenger-5.3.7-9.el6.cloudlinux/src/helper-scripts/wsgi-loader.py:26: DeprecationWarning: the imp module is deprecated in favour of importlib; see the module's documentation for alternative uses
App 439960 output:   import sys, os, io, re, imp, threading, signal, traceback, socket, select, struct, logging, errno

我还在passenger_wsgi.py文件中以这种方式配置了WSGI

import os
import sys
from covid.wsgi import application

其中我的应用程序名称为covid
我不知道到底发生了什么事。如果有人能帮忙,我将不胜感激。

xiozqbni

xiozqbni1#

我遇到了同样的问题,然后像这样解决它。
乘客_wsgi. py

from flask_app import app as application

flask _应用程序. py

from flask import Flask
from werkzeug.middleware.proxy_fix import ProxyFix
app = Flask(__name__)
app.wsgi_app = ProxyFix(app.wsgi_app)
app.config.from_pyfile("config/settings.py")
init_app(app)

CPanel配置:

  • 应用程序根目录:<root_app_dir>
  • 应用程序启动文件:乘客_wsgi. py
  • 应用程序入口点: flask 应用程序
  • 乘客日志文件:/乘客日志<root_dir>/passenger.logs

相关问题