Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

121
Views
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
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!