How to configure Apache server with Django for deployment on Virtual Machine

im currently trying to deploy my django project to a web server hosted by a RHEL-8 VM. Im trying to set up the VM to utilize HTTPD (apache). However, i can’t seem to get the Virtual Host configuration files right. I am pretty new to django and web servers as this is my first time deploying a web server. As such, i have been trying to do this for quite some time now and nothing online seems to work. As of recently i have tried more or less following this tutorial on getting it deployed. As such, here is the code i have added into /etc/httpd/conf.d/django.conf:

<VirtualHost *:80>
        DocumentRoot /var/www/

        Alias /static /var/www/awesomedjango/static
        <Directory "/var/www/awesomedjango/static">
                Options FollowSymLinks
                Order allow,deny
                Allow from all
                Require all granted

        ErrorLog /var/www/awesomedjango/logs/apis_error.log
        CustomLog /var/www/awesomedjango/logs/apis_access.log combined

        WSGIPassAuthorization On
        WSGIDaemonProcess awesomedjango python-path=/var/www/awesomedjango:/var/www/awesomedjango/venv/lib/python3.6/site-packages
        WSGIProcessGroup awesomedjango
        WSGIScriptAlias / /var/www/awesomedjango/v/

        <Directory /var/www/awesomedjango/awesomedjango>
                        Require all granted

But when i try to restart apache to apply this via ‘’’ apachectl restart ‘’', i just receive these errors:

  • httpd.service: Main process exited, code=exited, status=1/FAILURE
  • httpd.service: Failed with result ‘exit-code’.
  • Failed to start The Apache HTTP Server.

Any help would be greatly appreciated as i cant seem to find a solution to my problem online. Thanks


EDIT: new config file under /etc/httpd/conf.d/django.conf:

Alias /static /home/rh/django_apache/src/static_root
<Directory /home/rh/django_apache/src/static_root>
    Require all granted

<Directory /home/rh/django_apache/src/mysite>
        Require all granted

WSGIDaemonProcess django_apache python-path=/home/rh/django_apache/src:/home/rh/django_apache/src/venv/lib/python3.6/site-packages
WSGIProcessGroup django_apache
WSGIScriptAlias / /home/rh/django_apache/src/mysite/

Output of “apachectl -t”


Output of “apachectl configtest”

Syntax OK

Error logs under /etc/httpd/logs/error_log:

[Mon May 04 17:21:13.114508 2020] [mpm_event:notice] [pid 83087:tid 139745409411392] AH00492: caught SIGWINCH, shutting down gracefully
[Mon May 04 17:21:14.238225 2020] [core:notice] [pid 83673:tid 140701031287104] SELinux policy enabled; httpd running as context system_u:system_r:httpd_t:s0
[Mon May 04 17:21:14.239135 2020] [suexec:notice] [pid 83673:tid 140701031287104] AH01232: suEXEC mechanism enabled (wrapper: /usr/sbin/suexec)
[Mon May 04 17:21:14.257061 2020] [lbmethod_heartbeat:notice] [pid 83673:tid 140701031287104] AH02282: No slotmem from mod_heartmonitor
[Mon May 04 17:21:14.262183 2020] [mpm_event:notice] [pid 83673:tid 140701031287104] AH00489: Apache/2.4.37 (Red Hat Enterprise Linux) OpenSSL/1.1.1c mod_wsgi/4.6.4 Python/3.6 configured -- resuming normal operations[Mon May 04 17:21:14.262213 2020] [core:notice] [pid 83673:tid 140701031287104] AH00094: Command line: '/usr/sbin/httpd -D FOREGROUND'

Submit an answer
You can type!ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Accepted Answer

SOLVED: Errors lied within SELinux. I had to give fix up selinux policies for my project. Have a look at this thread for more detail:

Hi there @abartlett1206,

Usually, after making any changes to your Apache config, I would recommend first running Apache config test before restarting the service:

  1. apachectl -t

And then only if you get Syntax OK proceed with the Apache restart.

I think that the problem might be that the mod_wsgi enabled is not enabled.

I would recommend following the steps from this tutorial here on how to configure your Apache service:

If this still does not work, feel free to share the output of the config test command and the last few lines from your Apache error log.

Hope that this helps! Regards, Bobby