【发布时间】:2021-08-03 14:04:57
【问题描述】:
在过去的几天里,我一直在参考 Stackoverflow 来解决我的问题。 我在 Amazon Linux 2 上使用 WSGI 托管 Django 应用程序。我在这里将 pyenv 用于多个 python 版本。而python版本是3.7.10。下面是我的 Apache Conf 和 wsgi.py。
# WSGI config for mysite 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.2/howto/deployment/wsgi/ """
import os
from django.core.wsgi import get_wsgi_application
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'mysite.settings')
application = get_wsgi_application()
<VirtualHost *:80>
ServerName wsgi.iamvishnu.xyz
#DocumentRoot /var/www/html
#for django
LoadModule wsgi_module modules/mod_wsgi_python3.so
Alias /static/ /home/mod-wsgi/mysite/static/
<Directory /home/mod-wsgi/mysite>
Require all granted
</Directory>
<Directory /home/mod-wsgi/mysite/mysite>
<Files wsgi.py>
Require all granted
</Files>
</Directory>
WSGIDaemonProcess mysite user=mod-wsgi2 group=mod-wsgi2
python-path=/home/mod-wsgi2:/home/mod-wsgi2/mysite:/home/mod-wsgi2/mysite/mysite:/home/mod-wsgi2/.pyenv/versions/3.6.8/envs/virtual/lib/python3.6/site-packages
WSGIProcessGroup mysite
WSGIScriptAlias / /home/mod-wsgi2/mysite/mysite/wsgi.py
下面是我从 apache 错误日志中得到的错误
Current thread 0x00007fd4b2087240 (most recent call first): [Tue Aug
03 05:27:15.145298 2021] [core:notice] [pid 24159] AH00052: child pid
24229 exit signal Aborted (6) Fatal Python error: initfsencoding:
unable to load the file system codec ModuleNotFoundError: No module
named 'encodings'
Current thread 0x00007fd4b2087240 (most recent call first): [Tue Aug
03 05:27:16.147167 2021] [core:notice] [pid 24159] AH00052: child pid
24230 exit signal Aborted (6) Fatal Python error: initfsencoding:
unable to load the file system codec ModuleNotFoundError: No module
named 'encodings'
Current thread 0x00007fd4b2087240 (most recent call first): [Tue Aug
03 05:27:17.149010 2021] [core:notice] [pid 24159] AH00052: child pid
24231 exit signal Aborted (6) Fatal Python error: initfsencoding:
unable to load the file system codec ModuleNotFoundError: No module
named 'encodings'
谁能告诉我我在这里错过了什么。如果需要,我将提供有关相同的更多信息。您能提供的任何帮助将不胜感激。
【问题讨论】:
-
看看这些链接是否有帮助:Possible ans 1Possible ans 2