Software Used
- Nginx
- Uwsgi 2
- Django
Procedure
yum install uwsgi-router-rewriteAdd route-uri to uwsgi configuration /etc/uwsgi.d/example.ini
[uwsgi]Nginx configuration
# Python
plugin = python36, router_rewrite
# Django
chdir = /srv/sites/example
module = example.wsgi
home = /srv/.virtualenvs/example
route-uri = ^/second-site(.*) rewrite:$1
# Process
master = true
processes = 5
socket = /run/uwsgi/example.sock
vacuum = true
procname-prefix-spaced = example
server {Configure Django to prefix the subdirectory name to redirects. In settings.py:
...
location /second-site/static {
access_log off;
alias /var/www/second-site/static;
}
location /second-site/ {
include uwsgi_params;
uwsgi_pass unix:/run/uwsgi/example.sock;
}
FORCE_SCRIPT_NAME = '/second-site'Reference: https://stackoverflow.com/questions/44987110/django-in-subdirectory-admin-site-is-not-working
STATIC_URL = FORCE_SCRIPT_NAME + '/static/'
STATIC_ROOT = '/var/www/second-site/static'
MEDIA_URL = FORCE_SCRIPT_NAME + '/media/'
ADMIN_MEDIA_PREFIX = FORCE_SCRIPT_NAME + '/admin_media/'
SESSION_COOKIE_PATH = FORCE_SCRIPT_NAME
(TODO)
0 comments:
Post a Comment