django - Django - XAMPP - Apache - Cookiecutter
问题描述
我有一个使用 cookiecutter 配置的 Django 项目,我需要在 Windows 10 上使用 XAMPP 和带有 mod_wsgi 的 apache 部署项目。我已经尝试了一些解决方案,但对我不起作用。这是我的配置:
Apache/2.4.48 (Win64) OpenSSL/1.1.1k PHP/8.0.8 mod_wsgi/4.9.0 Python/3.7 Django 版本 3.2
wsgi.py
import os
import sys
from pathlib import Path
from django.core.wsgi import get_wsgi_application
ROOT_DIR = Path(__file__).resolve(strict=True).parent.parent
sys.path.append(str(ROOT_DIR / "cinema"))
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "config.settings.production")
application = get_wsgi_application()
apache xampp 中的 httpd.conf
LoadFile "D:/Tools/Anaconda3/python37.dll"
LoadModule wsgi_module modules/mod_wsgi.so
WSGIPythonHome "D:/Trabajo/ByT/CINEMA/venv"
WSGIPythonPath "D:/Trabajo/ByT/CINEMA/cinema/config/"
<VirtualHost *:80>
ServerName localhost
WSGIPassAuthorization On
ErrorLog "logs/cinema.error.log"
CustomLog "logs/cinema.access.log" combined
WSGIScriptAlias /cinema/ "D:/Trabajo/ByT/CINEMA/cinema/config/wsgi.py"
<Directory "D:/Trabajo/ByT/CINEMA/cinema/config">
<Files "wsgi.py">
Order allow,deny
Allow from all
Require all granted
</Files>
</Directory>
Alias /static "D:/Trabajo/ByT/CINEMA/cinema/staticfiles/"
<Directory "D:/Trabajo/ByT/CINEMA/cinema/staticfiles/">
Require all granted
</Directory>
Alias /media "D:/Trabajo/ByT/CINEMA/cinema/media/"
<Directory "D:/Trabajo/ByT/CINEMA/cinema/media/">
Require all granted
</Directory>
</VirtualHost>
当我运行 apache 服务器时,我收到服务器错误 500,这是日志中的一个片段:
[Tue Nov 09 17:54:49.688418 2021] [wsgi:error] [pid 7892:tid 1980] [client ::1:19759] ModuleNotFoundError: No module named 'config'\r
解决方案
推荐阅读
- loops - Scilab:无效索引
- proguard - 由于 proguard 规则,生成签名 APK 时出错
- python - Python:excel中不同单元格中的每个元素
- hadoop - Map 可以多次计算出现次数吗?
- security - 在 SPA 中存储 JWT 访问令牌的位置(即 Angular 应用程序)
- c++ - std::find_if 和一个 lambda - 错误 void 值没有被忽略,因为它应该被忽略
- asp.net - 使用 Axios 和 React Native 将 base64 图像上传到服务器
- windows - 如何在 Powershell 的 GetCredential 中传递密码?
- javascript - 与淘汰赛 foreach 的数据绑定不起作用
- vue.js - Bootstrap vue @ok 没有被触发