1

I've spent the whole day trying to find an answer to my issue, yet I failed and decided to post my problem here instead. So I have develop a Django Application and now I'm having problems in deploying it to an apache (httpd) server. I'm currently running CentOS 7.2 if it is relevant.

I have been following that tutorial in order to do what I wanted: https://www.digitalocean.com/community/tutorials/how-to-serve-django-applications-with-apache-and-mod_wsgi-on-centos-7

Obviously I did not create a new project from scratch as I've already had one and only adjusted it to fit the tutorial. Once I was done and restarted the httpd service, I got the following error message when tried to access the site:

Forbidden
You don't have permission to access / on this server.

It's not a firewall issue as when I remove django.conf (i.e. revert the changes) the default apache site is displayed.

My django.conf file looks as follows:

Alias /static /home/dudu/DjangoProject/mysite/static
<Directory /home/dudu/DjangoProject/mysite/static>
  Require all granted
</Directory>

<Directory /home/dudu/DjangoProject/mysite>
  <Files wsgi.py>
    Require all granted
  </Files>
</Directory>

WSGIDaemonProcess DjangoProject python-path=/home/dudu/DjangoProject:/home/dudu/DjangoProject/DjangoProjectEnv/lib/python2.7/site-packages
WSGIProcessGroup DjangoProject
WSGIScriptAlias / /home/dudu/DjangoProject/mysite/wsgi.py

The relevant folder structure:

/home/dudu/
|--DjangoProject
|      |--manage.py
|      |--db.sqlite3
|      |--DjangoProjectEnv (with python environment)
|      |--mysite
|      |   |--settings.py
|      |   |--wsgi.py
|      |   |--other related django files

Furthermore at the bottom of my settings.py I've got the following:

STATIC_URL = '/static/'
STATIC_ROOT = os.path.join(BASE_DIR, '/static/')

And my wsgi.py file is as follows:

import os
from django.core.wsgi import get_wsgi_application
os.environ["DJANGO_SETTINGS_MODULE"] = "mysite.settings" # had os.environ.setdefault before
application = get_wsgi_application()

I hope that I've included all necessary information and that you will be able to help! Thank you in advance!

Dudu
  • 11
  • 3

0 Answers0