简体   繁体   中英

Internal Server Error using apache django mod_wsgi or 500 internal server error mod_wsgi apache

wsgi.py

import os
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'gis_api.settings')

from django.core.wsgi import get_wsgi_application
application = get_wsgi_application()

httpd.conf

ServerName 127.0.0.1:81
LoadFile "C:/Users/test/AppData/Local/Programs/Python/Python310/python310.dll"
LoadModule wsgi_module "C:/Users/test/AppData/Local/Programs/Python/Python310/lib/site-packages/mod_wsgi/server/mod_wsgi.cp310-win_amd64.pyd"
WSGIPythonHome "C:/Users/test/AppData/Local/Programs/Python/Python310"
WSGIPythonPath "C:/Users/test/AppData/Local/Programs/Python/Python310/lib/site-packages/"
<VirtualHost *:81>
    WSGIScriptAlias / "D:/django_project/gis_api/gis_api/gis_api/wsgi.py"
    <Directory "D:/django_project/gis_api/gis_api/gis_api/">    
        <Files wsgi.py>
            Require all granted
        </Files>
    </Directory>

    Alias /static "D:/django_project/gis_api/gis_api/static/"
    <Directory "D:/django_project/gis_api/gis_api/static/">
        Require all granted
    </Directory>


    Alias /media "D:/django_project/gis_api/gis_api/media/"
    <Directory "D:/django_project/gis_api/gis_api/media/">
        Require all granted
    </Directory>
</VirtualHost>

error.log

  • mod_wsgi (pid=20212): Failed to exec Python script file 'D:/django_project/gis_api/gis_api/gis_api/wsgi.py'., referer: http://127.0.0.1:81/
  • mod_wsgi (pid=20212): Exception occurred processing WSGI script 'D:/django_project/gis_api/gis_api/gis_api/wsgi.py'., referer: http://127.0.0.1:81/
  • Traceback (most recent call last):\r, referer: http://127.0.0.1:81/
  • ModuleNotFoundError: No module named 'gis_api'\r, referer: http://127.0.0.1:81/

version:

  • Django 4.1.1
  • mod-wsgi 4.9.4
  • os window 10

I have try to all solution. But getting error. I am beginner to deployment in django apache. Pl guide me best path of deployment.

my project structure在此处输入图像描述

WSGIPythonPath needs to point to your app directory like

WSGIPythonPath "D:/django_project/gis_api"

For the moment you are twice adding the environment path (WSGIPythonHome and...Path) to the python search path but not your apps directory.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM