After 2 days of trying multiple tutorials & reading StackOverflow, I'm calling for help!
The setting: The development version is running smoothly on the AWS Lightsail server. It's during the production deployment that I'm running in continuous problems with the static files. The application runs on the appointed subdomain but it's missing all the JS/CSS/images/...
I have followed the official docs but to no avail. 1/ https://docs.bitnami.com/aws/infrastructure/django/get-started/deploy-django-project/ 2/ https://docs.bitnami.com/aws/infrastructure/django/get-started/deploy-django-project/
My Folder Tree with relevant files:
Project
- conf
- httpd-app.conf
- httpd-prefix.conf
- Django2Tutorial
- settings.py
- wsgi.py
- Solar
- static
- static (after running collectstatic function in terminal,-it includes the admin, Solar statics)
My settings:
STATIC_ROOT = os.path.join(BASE_DIR,'static')
STATIC_URL = '/static/'
DEBUG = False
ALLOWED_HOSTS = ['54.169.172.***']
wsgi.py file
import os
import sys
sys.path.append('/opt/bitnami/apps/django/django_projects/Project')
os.environ.setdefault("PYTHON_EGG_CACHE", "/opt/bitnami/apps/django/django_projects/Project/egg_cache")
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'DjangoTutorial2.settings')
from django.core.wsgi import get_wsgi_application
application = get_wsgi_application()
My conf files :
1. httpd-app.conf file
<IfDefine !IS_DJANGOSTACK_LOADED>
Define IS_DJANGOSTACK_LOADED
WSGIDaemonProcess wsgi-djangostack processes=2 threads=15 display-name=%{GROUP}
</IfDefine>
<Directory "/opt/bitnami/apps/django/django_projects/Project/DjangoTutorial2">
Options +MultiViews
AllowOverride All
<IfVersion >= 2.3>
Require all granted
</IfVersion>
WSGIProcessGroup wsgi-djangostack
WSGIApplicationGroup %{GLOBAL}
</Directory>
Alias /static "/opt/bitnami/apps/django/django_projects/Project/static"
<Directory "/opt/bitnami/apps/django/django_projects/Project/static">
Require all granted
</Directory>
WSGIScriptAlias / '/opt/bitnami/apps/django/django_projects/Project/DjangoTutorial2/wsgi.py'
2. httpd-prefix.conf file
# Include file
RewriteEngine On
RewriteCond "%{HTTP_HOST}" ^ec2-([0-9]{1,3})-([0-9]{1,3})-([0-9]{1,3})-([0-9]{1,3})\..*\.amazonaws.com(:[0-9]*)?$
RewriteRule "^/?(.*)" "%{REQUEST_SCHEME}://%1.%2.%3.%4%5/$1" [L,R=302,NE]
Include "/opt/bitnami/apps/django/django_projects/Project/conf/httpd-app.conf"
Other adjustments made: (/opt/bitnami/apache2/conf/bitnami) 1/ bitnami-apps-prefix.conf file
Include "/opt/bitnami/apps/django/django_projects/Project/conf/httpd-prefix.conf"
2/ bitnami.conf file
VirtualHost _default_:80>
WSGIScriptAlias / /opt/bitnami/apps/django/django_projects/Project/DjangoTutorial2/wsgi.py
<Directory /opt/bitnami/apps/django/django_projects/Project>
AllowOverride all
Require all granted
Options FollowSymlinks
</Directory>
DocumentRoot /opt/bitnami/apps/django/django_projects/Project
</VirtualHost>
Checked as well:
Can anyone advise how to proceed? It's been extremely frustrating 2 days haha.
Note, maybe this can help : double-checked with the findstatic function, it redirects me to the Solar/static folder. I thought since I ran collect static, I should point to the Project level static folder in the apache conf & not the Solar level static folder.
You need to add Alias /static/ /opt/bitnami/apps/django/django_projects/Project/static/
to your virtualhost config so the server knows to map /static/
requests to that folder.