Djangoで開発したアプリをApacheでデプロイできない
解決したいこと
Django初学者です。Djangoでwebアプリを開発しており、残りはデプロイするだけとなりました。Apacheで公開したいと考えています。
環境は windows10 python3.9 Apache24 です。apacheなど、その他諸々の初期設定は済んでいます。
複数のサイトを参考にさせていただき、Apacheのhttpd.confに下記を追加しました。
httpd.conf
LoadFile "c:/users/taizu/appdata/local/programs/python/python39/python39.dll"
LoadModule wsgi_module "c:/users/taizu/appdata/local/programs/python/python39/lib/site-packages/mod_wsgi/server/mod_wsgi.cp39-win_amd64.pyd"
WSGIPythonHome "c:/users/taizu/appdata/local/programs/python/python39"
WSGIScriptAlias / c:/x/pj_x/pj_x/wsgi.py
<Directory c:/x/pj_x/pj_x>
Options SymLinksIfOwnerMatch ExecCGI IncludesNoExec
<Files wsgi.py>
Require all granted
</Files>
</Directory>
wsgi.pyの中身は下記の通りです。
wsgi.py
"""
WSGI config for appname project.
It exposes the WSGI callable as a module-level variable named ``application``.
For more information on this file, see
https://docs.djangoproject.com/en/3.0/howto/deployment/wsgi/
"""
import os
import sys
from django.core.wsgi import get_wsgi_application
sys.path.append('C:/x/pj_x')
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "pj_x.settings")
#os.environ["DJANGO_SETTINGS_MODULE"] = "pj_x.settings"
application = get_wsgi_application()
自分で試したこと
実行したのですがアクセスできませんでした。
apacheのエラーログを確認したところ、
[Sat Jan 07 16:58:41.239685 2023] [authz_core:debug] [pid 1260:tid 1400] mod_authz_core.c(815): [client 192.168.1.2:60411] AH01626: authorization result of Require all granted: granted
[Sat Jan 07 16:58:41.239685 2023] [authz_core:debug] [pid 1260:tid 1400] mod_authz_core.c(815): [client 192.168.1.2:60411] AH01626: authorization result of <RequireAny>: granted
[Sat Jan 07 16:58:41.240703 2023] [authz_core:debug] [pid 1260:tid 1400] mod_authz_core.c(815): [client 192.168.1.2:60411] AH01626: authorization result of Require all granted: granted
[Sat Jan 07 16:58:41.240703 2023] [authz_core:debug] [pid 1260:tid 1400] mod_authz_core.c(815): [client 192.168.1.2:60411] AH01626: authorization result of <RequireAny>: granted
[Sat Jan 07 16:58:41.240703 2023] [win32:error] [pid 1260:tid 1400] [client 192.168.1.2:60411] AH02102: C:/x/pj_x/pj_x/wsgi.py is not executable; ensure interpreted scripts have "#!" or "'!" first line
[Sat Jan 07 16:58:41.240703 2023] [cgi:error] [pid 1260:tid 1400] (9)Bad file descriptor: [client 192.168.1.2:60411] AH01222: don't know how to spawn child process: C:/x/pj_x/pj_x/wsgi.py
[Sat Jan 07 16:58:41.406385 2023] [authz_core:debug] [pid 1260:tid 1412] mod_authz_core.c(815): [client 192.168.1.2:60412] AH01626: authorization result of Require all granted: granted, referer: http://192.168.1.2/
[Sat Jan 07 16:58:41.406385 2023] [authz_core:debug] [pid 1260:tid 1412] mod_authz_core.c(815): [client 192.168.1.2:60412] AH01626: authorization result of <RequireAny>: granted, referer: http://192.168.1.2/
[Sat Jan 07 16:58:41.406385 2023] [authz_core:debug] [pid 1260:tid 1412] mod_authz_core.c(815): [client 192.168.1.2:60412] AH01626: authorization result of Require all granted: granted, referer: http://192.168.1.2/
[Sat Jan 07 16:58:41.406385 2023] [authz_core:debug] [pid 1260:tid 1412] mod_authz_core.c(815): [client 192.168.1.2:60412] AH01626: authorization result of <RequireAny>: granted, referer: http://192.168.1.2/
[Sat Jan 07 16:58:41.406385 2023] [win32:error] [pid 1260:tid 1412] [client 192.168.1.2:60412] AH02102: C:/x/pj_x/pj_x/wsgi.py is not executable; ensure interpreted scripts have "#!" or "'!" first line, referer: http://192.168.1.2/
[Sat Jan 07 16:58:41.406385 2023] [cgi:error] [pid 1260:tid 1412] (9)Bad file descriptor: [client 192.168.1.2:60412] AH01222: don't know how to spawn child process: C:/x/pj_x/pj_x/wsgi.py, referer: http://192.168.1.2/
というようになっていました。
[win32:error] [pid 1260:tid 1400] [client 192.168.1.2:60411] AH02102: C:/x/pj_x/pj_x/wsgi.py is not executable; ensure interpreted scripts have "#!" or "'!" first line
[cgi:error] [pid 1260:tid 1400] (9)Bad file descriptor: [client 192.168.1.2:60411] AH01222: don't know how to spawn child process: C:/x/pj_x/pj_x/wsgi.py
この部分に何かヒントがあるように感じます。(この部分だけ日付は削除しました)
自分なりに調べたのですが、解決することができませんでした。
つきましては問題解決のための皆様の知識、ご教授を賜りたく思います。
よろしくお願い致します。
0