我无法通过触摸位于我的django应用程序根/应用程序名称中的wsgi.py脚本来重新加载django模板。
脚本和项目位于/var/www下面,所以我需要sudo来执行触摸。
我正在运行生产apache2服务器,在守护进程模式下运行一个带有mod_wsgi的django网站。我可以收集和进行迁移,访问数据库(未经许可的问题)。我还可以在设置中更改调试标志。如果我触摸wsgi.py,它将按预期将生产站点放到调试中,但是html没有加载。同样,我也可以更新静态文件、收藏或修改底层模型,并查看动态更改。同样,我可以使用注释的代码来检索转向程序运行的守护进程模式。它只是导致问题的模板。设置文件、wsgi.py、静态脚本和python脚本将按预期进行响应。
有人知道怎么调试这个吗?
virtualenv python3.8.12 apache2.4为python3.8.12编译的mod_wsgi
wsgi.py
import os
import sys
from django.core.wsgi import get_wsgi_application
sys.path.insert(0, os.path.abspath(os.path.join(os.path.dirname(__file__), "../../")))
sys.path.insert(0, os.path.abspath(os.path.join(os.path.dirname(__file__), "../")))
sys.path.insert(0, os.path.abspath(os.path.join(os.path.dirname(__file__), "../app/")))
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'mb.settings')
application = get_wsgi_application()
#def application(environ, start_response):
# status = '200 OK'
# if not environ['mod_wsgi.process_group']:
# output = u'EMBEDDED MODE'
# else:
# output = u'DAEMON MODE'
# response_headers = [('Content-Type', 'text/plain'),
# ('Content-Length', str(len(output)))]
# start_response(status, response_headers)
# return [output.encode('UTF-8')]apache2站点配置
<VirtualHost *:80>
# The ServerName directive sets the request scheme, hostname and port that
# the server uses to identify itself. This is used when creating
# redirection URLs. In the context of virtual hosts, the ServerName
# specifies what hostname must appear in the request's Host: header to
# match this virtual host. For the default virtual host (this file) this
# value is not decisive as it is used as a last resort host regardless.
# However, you must set it for any further virtual host explicitly.
#ServerName app
ServerAdmin webmaster@localhost
ServerName ------removed for posting-----
ServerAlias -----removed for posting------
DocumentRoot /var/www/vhosts/mb
# Available loglevels: trace8, ..., trace1, debug, info, notice, warn,
# error, crit, alert, emerg.
# It is also possible to configure the loglevel for particular
# modules, e.g.
#LogLevel info ssl:warn
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
# For most configuration files from conf-available/, which are
# enabled or disabled at a global level, it is possible to
# include a line for only one particular virtual host. For example the
# following line enables the CGI configuration for this host only
# after it has been globally disabled with "a2disconf".
#Include conf-available/serve-cgi-bin.conf
<Directory /var/www/vhosts/mb>
Order allow,deny
Allow from all
Require all granted
</Directory>
Alias /static /var/www/vhosts/mb/static
<Directory /var/www/vhosts/mb/static>
Require all granted
</Directory>
<Directory /var/www/vhosts/mb/mb>
<Files wsgi.py>
Require all granted
</Files>
</Directory>
WSGIDaemonProcess mb python-path=/var/www/vhosts/mb python-home=/var/www/vhosts/mb/pyenv
WSGIProcessGroup mb
WSGIScriptAlias / /var/www/vhosts/mb/mb/wsgi.py
WSGIApplicationGroup %{GLOBAL}
</VirtualHost>发布于 2022-01-08 18:27:20
出于某种原因,我使用新的html而不是git推送将scp复制到目录中。结果是什么呢?我在scp上使用了带有-r标志的递归副本。这会自动创建一个子目录。它混淆了守护进程。移除此子目录修复了问题,而touch工作得很好。
https://stackoverflow.com/questions/70627539
复制相似问题