Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

124
Visualizações
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 à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda