I am trying to deploy a developed django project in AWS ec2 instance ( Windows instance server) with https. I have installed apache and configured the httpd.conf file. After configuration of public ip of ec2 instance in both django settings.py file and httpd.conf file, I tried to run the browser with public IP address of ec2 instance, it shows Internal server error.
httpd.conf file:
LoadFile "c:/users/sanmugapriyab/appdata/local/programs/python/python37/python37.dll"
LoadModule wsgi_module "c:/users/sanmugapriyab/appdata/local/programs/python/python37/lib/site-packages/mod_wsgi/server/mod_wsgi.cp37-win_amd64.pyd"
WSGIPythonHome "c:/users/sanmugapriyab/appdata/local/programs/python/python37";"
<VirtualHost *:80>
ServerName localhost
WSGIPassAutho`enter code here`rization On
ErrorLog "C:/users/sanmugapriyab/Desktop/hawk_web_version1/hawkproj/logs/hawkproj.error.log"
CustomLog "C:/users/sanmugapriyab/Desktop/hawk_web_version1/hawkproj/logs/hawkproj.access.log" combined
WSGIScriptAlias / "C:/users/sanmugapriyab/Desktop/hawk_web_version1/hawkproj/hawkproj/wsgi.py"
<Directory "C:/users/sanmugapriyab/Desktop/hawk_web_version1/hawkproj/hawkproj/">
<Files wsgi.py>
Require all granted
</Files>
</Directory>
Alias /static "C:/users/sanmugapriyab/Desktop/hawk_web_version1/hawkproj/static"
<Directory "C:/users/sanmugapriyab/Desktop/hawk_web_version1/hawkproj/static">
Require all granted
</Directory>
Alias /media "C:/users/sanmugapriyab/Desktop/hawk_web_version1/hawkproj/media"
<Directory "C:/users/sanmugapriyab/Desktop/hawk_web_version1/hawkproj/media">
Require all granted
</Directory>
</VirtualHost>
Errror.log:
tid 1312] [client ::1:49854] mod_wsgi (pid=4712): Failed to exec Python script file 'C:/Users/sanmugapriyab/Desktop/hawk_web_version1/hawkproj/hawkproj/wsgi.py'., referer: http://localhost/
[Mon Feb 01 17:38:24.003169 2021] [wsgi:error] [pid 4712:tid 1312] [client ::1:49854] mod_wsgi (pid=4712): Exception occurred processing WSGI script 'C:/Users/sanmugapriyab/Desktop/hawk_web_version1/hawkproj/hawkproj/wsgi.py'., referer: http://localhost/
[Mon Feb 01 17:38:24.003169 2021] [wsgi:error] [pid 4712:tid 1312] [client ::1:49854] Traceback (most recent call last): , referer: http://localhost/
[Mon Feb 01 17:38:24.003169 2021] [wsgi:error] [pid 4712:tid 1312] [client ::1:49854] File "C:/Users/sanmugapriyab/Desktop/hawk_web_version1/hawkproj/hawkproj/wsgi.py", line 10, in , referer: http://localhost/
[Mon Feb 01 17:38:24.003169 2021] [wsgi:error] [pid 4712:tid 1312] [client ::1:49854] from django.core.wsgi import get_wsgi_application , referer: http://localhost/
[Mon Feb 01 17:38:24.003169 2021] [wsgi:error] [pid 4712:tid 1312] [client ::1:49854] ModuleNotFoundError: No module named 'django' , referer: http://localhost/
Wsgi.py:
import sys
import site
from django.core.wsgi import get_wsgi_application
#activate_this = 'C:/Users/sanmugapriyab/Desktop/hawk_env/Scripts/activate_this.py'
# execfile(activate_this, dict(__file__=activate_this))
#exec(open(activate_this).read(),dict(__file__=activate_this))
# add python site packages, you can use virtualenvs also
#site.addsitedir("C:/Users/sanmugapriyab/AppData/Local/Programs/Python/Python37/Lib/site-packages")
# Add the app's directory to the PYTHONPATH
sys.path.append('C:/Users/sanmugapriyab/Desktop/hawk_web_version1/hawkproj')
sys.path.append('C:/Users/sanmugapriyab/Desktop/hawk_env/Lib/site-packages')
os.environ['DJANGO_SETTINGS_MODULE'] = 'hawkproj.settings'
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "hawkproj.settings")
application = get_wsgi_application()
question from:
https://stackoverflow.com/questions/65923442/deployment-of-django-project-with-apache-on-windows-aws-instance-environment 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…