在 Windows 的 Xampp Apache 服务器上部署 Django 可以在“localhost”网页中提供无休止的加载

Deploying Django on Xampp Apache server in windows gives endless loading in 'localhost' webpage

提问人:Jaya Rathina 提问时间:8/4/2023 更新时间:8/4/2023 访问量:66

问:

我正在尝试使用 XAMPP 在 Apache 服务器上托管一个 django 应用程序,在完成应用程序运行所需的所有设置后,“localhost”中的网页正在无休止地加载,在此处输入图像描述

这是我的设置:

在 venv 上运行,执行 pip freeze 会得到:

`asgiref==3.7.2
Django==3.2.20
mod-wsgi==4.9.4
mysqlclient==2.2.0
numpy==1.25.2
pandas==1.5.1
python-dateutil==2.8.2
pytz==2023.3
six==1.16.0
sqlparse==0.4.4
typing_extensions==4.7.1`

Django 应用程序位于 C:\xampp\htdocs\virtual_dealer\virtual_dealer 中

目录结构:

`C:\xampp\htdocs\virtual_dealer
|--base      -> app
|--venv     -> virtual environment
|--virtual_dealer    -> python project
|--static     -> static folder for the app
|--templates  -> templates folder for the app`

还将MOD_WSGI_APACHE_ROOTDIR放在环境变量中,以便能够成功执行 pip 安装mod_wsgi

至于 httpd.conf,这是我对 WSGI 的设置:

`LoadFile "C:/Users/Jaya Rathina/anaconda3/python39.dll"
LoadModule wsgi_module "C:/xampp/htdocs/virtual_dealer/venv/lib/site-packages/mod_wsgi/server/mod_wsgi.cp39-win_amd64.pyd"

WSGIScriptAlias / "C:/xampp/htdocs/virtual_dealer/virtual_dealer/wsgi.py"
WSGIPythonHome "C:/xampp/htdocs/virtual_dealer/venv"
WSGIPythonPath "C:/xampp/htdocs/virtual_dealer"

Alias /static/ C:/xampp/htdocs/virtual_dealer/static/


<Directory C:/xampp/htdocs/virtual_dealer/static/>
    Require all granted
</Directory>

<Directory "C:/xampp/htdocs/virtual_dealer/virtual_dealer">
    <Files wsgi.py>
    Require all granted
    </Files>
</Directory>`

和 httpd-vhosts.conf 中的设置,

`<VirtualHost *:80>
    ServerName localhost
    DocumentRoot "C:/xampp/htdocs/virtual_dealer"
</VirtualHost>`

有了这个,我在apache错误日志中没有看到任何错误:

`[Fri Aug 04 10:15:07.734233 2023] [mpm_winnt:crit] [pid 11560:tid 420] AH02538: Child: Parent process exited abruptly. Child process is ending
[Fri Aug 04 10:15:10.969205 2023] [core:warn] [pid 5692:tid 412] AH00098: pid file C:/xampp/apache/logs/httpd.pid overwritten -- Unclean shutdown of previous Apache run?
[Fri Aug 04 10:15:11.042668 2023] [mpm_winnt:notice] [pid 5692:tid 412] AH00455: Apache/2.4.56 (Win64) OpenSSL/1.1.1t PHP/8.2.4 mod_wsgi/4.9.4 Python/3.9 configured -- resuming normal operations
[Fri Aug 04 10:15:11.042668 2023] [mpm_winnt:notice] [pid 5692:tid 412] AH00456: Apache Lounge VS16 Server built: Mar  7 2023 13:21:03
[Fri Aug 04 10:15:11.042668 2023] [core:notice] [pid 5692:tid 412] AH00094: Command line: 'c:\\xampp\\apache\\bin\\httpd.exe -d C:/xampp/apache'
[Fri Aug 04 10:15:11.042668 2023] [mpm_winnt:notice] [pid 5692:tid 412] AH00418: Parent: Created child process 17688
[Fri Aug 04 10:15:12.179471 2023] [mpm_winnt:notice] [pid 17688:tid 448] AH00354: Child: Starting 150 worker threads.
`

我可能遗漏或设置不正确的什么?提前感谢您的帮助!

Apache Xampp mod-wsgi django-deployment

评论


答: 暂无答案