Django を Apache と mod_wsgi とともに使うには?
解決したいこと
Windows10のXAMPPでDjangoを使いたいと思っています。
以下のサイトを参考にしてやってみたのですが、apacheの設定でエラーが出ます。
https://minidaruma.com/blog/2021/05/30/windows10%E3%81%AExampp%E3%81%A7django/
apatcheのhttpd.confの最後に以下を追加しました。
bentoがdjangoのプロジェクト名です。
anacondaでbentoという名前で仮想環境も作っています。
#########################################################################
LoadFile "C:/Users/user/anaconda3/envs/bento/python39.dll"
LoadModule wsgi_module "C:/Users/user/anaconda3/envs/bento/Lib/site-packages/mod_wsgi/server/mod_wsgi.cp39-win_amd64.pyd"
WSGIPythonHome "C:/Users/user/bento/bento/"
WSGIScriptAlias / "C:/Users/user/bento/bento/wsgi.py"
WSGIPythonPath "C:/Users/user/bento/bento"
WSGIApplicationGroup %{GLOBAL}
Require all granted
Alias /static/ "C:/Users/user/bento/bento/static/"
Require all granted
#########################################################################
xamppのコントロールパネルからapacheを起動すると、PIDの値が変動して、error.logには以下のように出ます。
#########################################################################
Current thread 0x000014e4 (most recent call first):
[Mon May 01 11:23:54.127144 2023] [mpm_winnt:notice] [pid 5336:tid 452] AH00428: Parent: child process 904 exited with status 1 -- Restarting.
[Mon May 01 11:23:54.158391 2023] [ssl:warn] [pid 5336:tid 452] AH01909: www.example.com:443:0 server certificate does NOT include an ID which matches the server name
[Mon May 01 11:23:54.174017 2023] [mpm_winnt:notice] [pid 5336:tid 452] AH00455: Apache/2.4.56 (Win64) OpenSSL/1.1.1t PHP/8.2.4 mod_wsgi/4.9.2 Python/3.9 configured -- resuming normal operations
[Mon May 01 11:23:54.174017 2023] [mpm_winnt:notice] [pid 5336:tid 452] AH00456: Apache Lounge VS16 Server built: Mar 7 2023 13:21:03
[Mon May 01 11:23:54.174017 2023] [core:notice] [pid 5336:tid 452] AH00094: Command line: 'c:\xampp\apache\bin\httpd.exe -d C:/xampp/apache'
[Mon May 01 11:23:54.189641 2023] [mpm_winnt:notice] [pid 5336:tid 452] AH00418: Parent: Created child process 8084
[Mon May 01 11:23:54.564612 2023] [ssl:warn] [pid 8084:tid 404] AH01909: www.example.com:443:0 server certificate does NOT include an ID which matches the server name
[Mon May 01 11:23:54.611484 2023] [ssl:warn] [pid 8084:tid 404] AH01909: www.example.com:443:0 server certificate does NOT include an ID which matches the server name
[Mon May 01 11:23:54.642733 2023] [mpm_winnt:crit] [pid 8084:tid 404] (OS 109)パイプは終了しました。 : AH00404: Child: Unable to read socket data from parent
Python path configuration:
PYTHONHOME = (not set)
PYTHONPATH = (not set)
program name = 'python'
isolated = 0
environment = 1
user site = 1
import site = 1
sys._base_executable = 'C:\xampp\apache\bin\httpd.exe'
sys.base_prefix = 'C:\Users\user\anaconda3\envs\bento'
sys.base_exec_prefix = 'C:\Users\user\anaconda3\envs\bento'
sys.platlibdir = 'lib'
sys.executable = 'C:\xampp\apache\bin\httpd.exe'
sys.prefix = 'C:\Users\user\anaconda3\envs\bento'
sys.exec_prefix = 'C:\Users\user\anaconda3\envs\bento'
sys.path = [
'C:\Users\user\anaconda3\envs\bento\python39.zip',
'.\DLLs',
'.\lib',
'C:\xampp\apache\bin',
]
Fatal Python error: init_fs_encoding: failed to get the Python codec of the filesystem encoding
Python runtime state: core initialized
ModuleNotFoundError: No module named 'encodings'
#########################################################################
仮想環境のコマンドプロンプトからはimport encodingsはできます。
どなたか教えていただけたら助かります。
よろしくお願いします。
バージョン
・apache
Server version: Apache/2.4.56 (Win64)
Apache Lounge VS16 Server built: Mar 7 2023 13:21:03
・python 3.9.16
・django 4.1
・mod_wsgi.cp39-win_amd64.pyd