環境
CentOS 7.9
Apache 2.4.54
Anaconda 4.12.0
Django 4.1.2
以下のサイトを参考にしてwsgi_moduleの設定を行っています。
https://qiita.com/roy29fuku/items/578de62fbdd65f8ffbaa
/etc/httpd/conf/httpd.conf の末尾に以下を記載しました。
/etc/httpd/conf/httpd.conf
LoadModule wsgi_module /root/anaconda3/lib/python3.9/site-packages/mod_wsgi/server/mod_wsgi-py39.cpython-39-x86_64-linux-gnu.so WSGIScriptAlias / /usr/local/TEST/Django/Django/wsgi.py WSGIPythonHome /root/anaconda3/ WSGIPythonPath /usr/local/TEST/Django <Directory /usr/local/TEST/Django/Django> <Files wsgi.py> Require all granted </Files> </Directory> Alias /static/ /usr/local/TEST/Django/static/ <Directory /usr/local/TEST/Django/static> Require all granted </Directory>
lddコマンドの結果は以下です。
# ldd /root/anaconda3/lib/python3.9/site-packages/mod_wsgi/server/mod_wsgi-py39.cpython-39-x86_64-linux-gnu.so linux-vdso.so.1 => (0x00007ffe69d84000) libpython3.9.so.1.0 => /root/anaconda3/lib/libpython3.9.so.1.0 (0x00007f0d651b0000) libpthread.so.0 => /lib64/libpthread.so.0 (0x00007f0d64f94000) libc.so.6 => /lib64/libc.so.6 (0x00007f0d64bc6000) libdl.so.2 => /lib64/libdl.so.2 (0x00007f0d649c2000) libutil.so.1 => /lib64/libutil.so.1 (0x00007f0d647bf000) libm.so.6 => /lib64/libm.so.6 (0x00007f0d644bd000) /lib64/ld-linux-x86-64.so.2 (0x00007f0d65599000)
問題がないように見えたので、systemctl restart httpd で再起動しました。
しかし、エラーログを確認すると以下のメッセージが出力されていました。
# more /var/log/httpd/error_log [Mon Oct 17 09:58:10.923531 2022] [suexec:notice] [pid 16852:tid 16852] AH01232: suEXEC mechanism enabled (wrapper: /usr/sbin/suexec) [Mon Oct 17 09:58:10.947997 2022] [http2:warn] [pid 16852:tid 16852] AH10034: The mpm module (prefork.c) is not supported by mod_http2. The mpm determines ho w things are processed in your server. HTTP/2 has more demands in this regard and the currently selected mpm will just not do. This is an advisory warning. Y our server will continue to work, but the HTTP/2 protocol will be inactive. [Mon Oct 17 09:58:10.948487 2022] [lbmethod_heartbeat:notice] [pid 16852:tid 16852] AH02282: No slotmem from mod_heartmonitor [Mon Oct 17 09:58:10.971703 2022] [mpm_prefork:notice] [pid 16852:tid 16852] AH00163: Apache/2.4.54 (IUS) OpenSSL/1.0.2k-fips PHP/8.2.0RC4 mod_wsgi/4.9.4 Pyt hon/3.9 configured -- resuming normal operations [Mon Oct 17 09:58:10.971735 2022] [core:notice] [pid 16852:tid 16852] AH00094: Command line: '/usr/sbin/httpd -D FOREGROUND' [Mon Oct 17 09:58:10.973167 2022] [wsgi:warn] [pid 16856:tid 16856] (13)Permission denied: mod_wsgi (pid=16856): Unable to stat Python home /root/anaconda3/. Python interpreter may not be able to be initialized correctly. Verify the supplied path and access permissions for whole of the path. [Mon Oct 17 09:58:10.977234 2022] [wsgi:warn] [pid 16857:tid 16857] (13)Permission denied: mod_wsgi (pid=16857): Unable to stat Python home /root/anaconda3/. Python interpreter may not be able to be initialized correctly. Verify the supplied path and access permissions for whole of the path. [Mon Oct 17 09:58:10.981048 2022] [wsgi:warn] [pid 16855:tid 16855] (13)Permission denied: mod_wsgi (pid=16855): Unable to stat Python home /root/anaconda3/. Python interpreter may not be able to be initialized correctly. Verify the supplied path and access permissions for whole of the path. [Mon Oct 17 09:58:10.985024 2022] [wsgi:warn] [pid 16854:tid 16854] (13)Permission denied: mod_wsgi (pid=16854): Unable to stat Python home /root/anaconda3/. Python interpreter may not be able to be initialized correctly. Verify the supplied path and access permissions for whole of the path. Python path configuration: PYTHONHOME = '/root/anaconda3/' PYTHONPATH = (not set) program name = 'python3' isolated = 0 environment = 1 user site = 1 import site = 1 sys._base_executable = '/usr/bin/python3' sys.base_prefix = '/root/anaconda3' sys.base_exec_prefix = '/root/anaconda3' sys.platlibdir = 'lib' sys.executable = '/usr/bin/python3' sys.prefix = '/root/anaconda3' sys.exec_prefix = '/root/anaconda3' sys.path = [ '/root/anaconda3/lib/python39.zip', '/root/anaconda3/lib/python3.9', '/root/anaconda3/lib/python3.9/lib-dynload', ] 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'
(13)Permission denied: mod_wsgi (pid=16856): Unable to stat Python home /root/anaconda3/
とあることから、mod_wsgiが/root/anaconda3/にアクセスできていない(?)と思えるのですが、具体的にはどういう設定をすればよいのでしょうか。
Anacondaをインストールした場所に問題があるのでしょうか。例えば、apacheユーザーが見れるディレクトリ(/var/www/配下など)にAnacondaをインストールしなければならないのでしょうか。
回答1件
あなたの回答
tips
プレビュー
下記のような回答は推奨されていません。
このような回答には修正を依頼しましょう。
また依頼した内容が修正された場合は、修正依頼を取り消すようにしましょう。