Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

122
Vistas
How to configure django to run on apache

I have been struggling with this problem for the last 3 days. I was able to install and run Apache on a CentOS machine. I can also run simple html or wsgi files. The problem is when I try to run Django. The Django project works fine with manage.py runserver, but when configuring the wsgi.py file and the .config file I start having problems (500 error).

I have already tried this approach and I have also researched similar questions on stack overflow but I wasn't able to find the solution to my problem.

I included more details below. I hope you can help me, thanks!

error_log;

[Mon Apr 20 09:59:59.532476 2020] [:error] [pid 31466] [client 10.5.230.111:59479]   File "/srv/www/example/mysite/mysite/wsgi.py", line 14, in <module>
[Mon Apr 20 09:59:59.532591 2020] [:error] [pid 31466] [client 10.5.230.111:59479]     from django.core.wsgi import get_wsgi_application
[Mon Apr 20 09:59:59.532627 2020] [:error] [pid 31466] [client 10.5.230.111:59479] ImportError: No module named django.core.wsgi

example.config;

<VirtualHost *:80>
    WSGIDaemonProcess python-home=/var/www/django/env/ python-path=/srv/www/example/mysite:/var/www/django/env/lib/python3.6/site-packages

    WSGIProcessGroup %{GLOBAL}
    WSGIScriptAlias /exam /srv/www/example/mysite/mysite/wsgi.py

    <Directory /srv/www/example/mysite/mysite>
        <Files wsgi.py>
            Require all granted
        </Files>
    </Directory>

    # Django static files, here you must specify your own path's
    Alias /static/ /srv/www/example/mysite/static/
    <Directory "/srv/www/example/mysite/static">
      Require all granted
    </Directory>
</VirtualHost>

wsgi;

import os
import sys
import site

for root, _, files in os.walk('/usr/local/lib/python3.4/site-packages/django'):
    for f in files:
        os.system('dos2unix %s' % abspath(join(root, f)))

from django.core.wsgi import get_wsgi_application

site.addsitedir("/var/www/django/env/lib/python3.6/site-packages")

sys.path.append("/srv/www/example/mysite")
sys.path.append("/srv/www/example/mysite/mysite")

activate_this = "/var/www/django/env/bin/activate_this.py"

with open(activate_this) as f:
    code = compile(f.read(), activate_this, "exec")
    exec(code, dict(__file__=activate_this))

os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'mysite.settings')

application = get_wsgi_application()
over 4 years ago · Santiago Trujillo
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda