1

Hello I'm trying to deploy my first Django website using Apache inside of Centos7

Versions: 
Apache: 2.4.6 
Django: 2.2.6
Python: 3.6.8

My Django project is located inside the /srv directory and looks like this:

/srv/
└── MyApp
    ├── apps
    │   └── index
    ├── db.sqlite3
    ├── manage.py
    ├── media
    ├── root
    │   ├── __init__.py
    │   ├── __pycache__
    │   ├── settings.py
    │   ├── urls.py
    │   └── wsgi.py
    ├── static
    │   ├── css
    │   └── images
    └── venv
        ├── bin
        ├── include
        ├── lib
        ├── lib64 -> lib
        ├── pip-selfcheck.json
        └── pyvenv.cfg

Test I have done:

1) I'm able to access my Django website if I do:

python manage.py runserver 0.0.0.0:80

2) When using only Apache I'm able to see the Apache placeholder website.

3) I've also tried using mod_wsgi without Django following this tutorial (https://www.shellhacks.com/modwsgi-hello-world-example/) and I was able to make it work (only had to replace the following to make it work):

Allow from all --> Require all granted 
Order allow,deny --> Satisfy Any

My Apache config file located inside /etc/httpd/conf.d

WSGIScriptAlias / /srv/MyApp/root/wsgi.py
WSGIPythonPath /srv/MyApp

<Directory /srv/MyApp/root>
    <Files wsgi.py>
        Require all granted
    </Files>
</Directory>

WSGIDaemonProcess myapp.com python-home=/srv/MyApp/root/venv python-path=/srv/MyApp
WSGIProcessGroup myapp.com

I'm pretty new to all of this and I'm sure it might be something stupid that I'm not setting up properly but I've been googling and testing for over 10 hours now and I can't seem to figure this out.

I hope someone could give me some guidance. Many thanks in advance.

Alvaro Bataller
  • 163
  • 1
  • 5
  • Have you looked in the Apache error log? – womble Oct 21 '19 at 04:54
  • I've just learned how to setup logs, it seems that the only log I get is: Permission denied: AH00035: access to / denied (filesystem path '/srv/MyApp/root/wsgi.py') because search permissions are missing on a component of the path. But I have chmod 777 all the files inside /srv and I still get the same issue. – Alvaro Bataller Oct 21 '19 at 05:14
  • Seems like the issue I was having was Selinux blocking the access to the files. – Alvaro Bataller Oct 21 '19 at 06:44

0 Answers0