简体   繁体   中英

Error in Django Deployment with Apache centos 7

I deployed my application in apache but Getting 500 internal server error due to some issues need assistance to get this resolved

Restarted the service didn't helped me to resolved this.

virtualenvironment name=djangoprojectenv path=/opt/djangoproject/djangoprojectenv/lib/python3.6/site-packages

projectname - final & Application name - "final_app" project path - /opt/djangoproject/myproject/final

Error Log of Apache (throwing 500 internal server error)

[:error] [pid 26320] Traceback (most recent call last):
[:error] [pid 26320]    File "/opt/djangoproject/myproject/final/wsgi.py", line 16, in <module>
[:error] [pid 26320] [application = get_wsgi_application()
[:error] [pid 26320]  File "/opt/djangoproject/djangoprojectenv/lib/python3.6/site-packages/django/core/wsgi.py", line 13, in get_wsgi_application
[:error] [pid 26320]  django.setup(set_prefix=False)
[:error] [pid 26320]  File "/opt/djangoproject/djangoprojectenv/lib/python3.6/site-packages/django/__init__.py", line 27, in setup
[:error] [pid 26320]  apps.populate(settings.INSTALLED_APPS)
[:error] [pid 26320] File "/opt/djangoproject/djangoprojectenv/lib/python3.6/site-packages/django/apps/registry.py", line 78, in populate
[:error] [pid 26320]  raise RuntimeError("populate() isn't reentrant")
[:error] [pid 26320]  RuntimeError: populate() isn't reentrant

WSGI.py file [Project name - "final"]

"""
WSGI config for final 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/1.11/howto/deployment/wsgi/
"""

import os
from django.core.wsgi import get_wsgi_application
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "final.settings")
application = get_wsgi_application()

Finally my /etc/httpd/conf.d/django.conf as

Alias /static /opt/djangoproject/myproject/static
<Directory /opt/djangoproject/myproject/static>
 Require all granted
</Directory>

<Directory /opt/djangoproject/myproject/final>
<Files wsgi.py>
    Require all granted
 </Files>
</Directory>

WSGIDaemonProcess final python-path=/opt/djangoproject/myproject:/opt/djangoproject/djangoprojectenv/lib/python3.6/site-packages
WSGIProcessGroup final
WSGIScriptAlias / /opt/djangoproject/myproject/final/wsgi.py

Missed to install mod_wsgi for corresponding python, though i installed mod_wsgi using below

  yum install httpd mod_wsgi -y

it needs libraries for running python version. by installing the below package

  yum install python36u-mod_wsgi -y 

Issue got fixed for me. please use corresponding python version and install mod_wsgi libraries for that version as well

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM