Я успешно развернул приложение Django на AWS EC2, используя gunicorn и NGINX сервер. Но файлы stati c даже после настройки файла django .conf в / etc / nginx / sites-available / не загружаются в шаблоны.
django .conf файл:
server{
listen 80;
server_name my_server_name;
location / {
include proxy_params;
proxy_pass http://unix:/home/ubuntu/learning-aws/app.sock;
}
location /static/ {
autoindex on;
alias /home/ubuntu/learning-aws/myprofile/core/static/;
}
}
файл gunicorn.conf:
[program:gunicorn]
directory=/home/ubuntu/learning-aws/myprofile
command=/home/ubuntu/env/bin/gunicorn --workers 3 --bind unix:/home/ubuntu/learning-aws/app.sock myprofile.wsgi:application
autostart=true
autorestart=true
stderr_logfile=/var/log/gunicorn/gunicorn.err.log
stdout_logfile=/var/log/gunicorn/gunicorn.out.log
[group:guni]
programs:gunicorn
файл settings.py:
STATIC_URL = '/static/'
STATIC_ROOT = os.path.join(BASE_DIR, 'core/static/')
Используемые теги шаблона (например, base. html):
{% static 'plugins/bootstrap/bootstrap.min.css' %}