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. As such, i have given apache all the neccessary permissions and ownership over /var/www and its contents (error log , custom log). I have also created a virtual host conf file in /etc/httpd/conf.d/django.conf where the code below is present.
< VirtualHost *:80 >
ServerAdmin root@localhost
ServerName InternationalStudentHelp.com
DocumentRoot /var/www/
Alias /static /var/www/django_project/src/static_root
<Directory "/var/www/django_project/src/static_root">
Options FollowSymLinks
Order allow,deny
Allow from all
Require all granted
</Directory>
ErrorLog /etc/httpd/logs/error_log
CustomLog /etc/httpd/logs/access_log combined
WSGIPassAuthorization On
WSGIDaemonProcess django_proj python-path=/var/www/django_project/src python-home=/var/www/django_project/venv
WSGIProcessGroup django_proj
WSGIScriptAlias / /var/www/django_project/src/mysite/wsgi.py
<Directory /var/www/django_project/src/mysite>
<Files wsgi.py>
Require all granted
</Files>
</Directory>
< /VirtualHost >
'''
However i am not sure how to allow HTTPD (apache) to properly accept this configuration as i just receive the errors stated below. Any help would be appreciated greatly appreciated.
EDIT: ls -al /var/www
- drwxr-xr-x. 5 apache apache 53 Apr 30 19:02 .
- drwxr-xr-x. 21 root root 4096 Apr 28 17:31 ..
- drwxr-xr-x. 6 apache apache 88 Apr 30 17:34 django_project
- drwxr-xr-x. 2 apache apache 6 Dec 3 01:19 cgi-bin
- drwxr-xr-x. 2 apache apache 51 Apr 30 19:07 html
EDIT: errors with ErrorLog and CustomLog commented out
mod_wsgi (pid=36037): Failed to exec Python script file '/var/www/django_project/src/mysite/wsgi.py'.
mod_wsgi (pid=36037): Exception occurred processing WSGI script '/var/www/django_project/src/mysite/wsgi.py'.
ModuleNotFoundError: No module named 'mysite'
These errors are repeated several times
EDIT: ls -al /var/www/django_project/src/mysite/
- drwxr-xr-x. 3 apache apache 89 Apr 30 17:33 .
- drwxr-xr-x. 8 apache apache 182 Apr 30 17:33 ..
- -rw-r--r--. 1 apache apache 405 Apr 30 17:33 asgi.py
- drwxr-xr-x. 2 apache apache 4096 Apr 30 17:33 pycache
- -rw-r--r--. 1 apache apache 3694 Apr 30 17:33 settings.py
- -rw-r--r--. 1 apache apache 1853 Apr 30 17:33 urls.py
- -rw-r--r--. 1 apache apache 405 Apr 30 17:33 wsgi.py
EDIT: errors produced by the config file above:
AH00492: caught SIGWINCH, shutting down gracefully
Exception ignored in: del of <_UnixSelectorEventLoop running=False closed=False debug=False>> Traceback (most recent call last): File "/usr/lib64/python3.6/asyncio/base_events.py", line 526, in del NameError: name 'ResourceWarning' is not defined
SELinux policy enabled; httpd running as context system_u:system_r:httpd_t:s0
AH01232: suEXEC mechanism enabled (wrapper: /usr/sbin/suexec)
AH02282: No slotmem from mod_heartmonitor
AH02951: mod_ssl does not seem to be enabled
Apache/2.4.37 (Red Hat Enterprise Linux) mod_wsgi/4.6.4 Python/3.6 configured-- resuming normal operations
AH00094: Command line: '/usr/sbin/httpd -D FOREGROUND'
EDIT: ls -al /var/www/django_projects
drwxr-xr-x. 6 apache apache 88 Apr 30 17:34 .
drwxr-xr-x. 5 apache apache 53 Apr 30 19:02 ..
drwxr-xr-x. 7 apache apache 169 Apr 30 17:33 .git
drw-rw-rw-. 2 apache apache 29 May 1 00:29 logs
-rw-r--r--. 1 apache apache 404 Apr 30 17:33 pyvenv.cfg
-rw-r--r--. 1 apache apache 26 Apr 30 17:33 README.md
drwxr-xr-x. 8 apache apache 182 Apr 30 17:33 src
drwxr-xr-x. 5 apache apache 100 Apr 30 17:33 venv