How to deploy a Django application to sub-url?

I need to set up a django development environment that is publicly viewable on the Internet (I do this for school, and my projects must be viewable by my professor, this is not a setup that requires a lot of security). I have a virtual server with Ubuntu 8.04 LTS.

I need to have several django applications running in subdirectories of my main site. That is, I need mysite.com to be a static page, mysite.com/wordpress to be my Wordpress blog, and mysite.com/django1 mysite.com/django2 etc. to be django projects.

I am using apache and I will use sqlite or mysql.

There seem to be many ways to install and configure django, as there are sites offering tips, and they all assume that one project will become the root of the website. I would really appreciate help, thanks.

+3
source share
3 answers

you can use

WSGIScriptAlias /django1 /home/keratacon/www/django1/wsgi.py
WSGIScriptAlias /django2 /home/keratacon/www/django2/wsgi.py

in apache + mod_wsgi config , assuming that wsgi.pyis the name of your wsgi script.

+3
source

The Django documentation has a page describing deployment to Apache . There is also a section on running multiple installations on the same server .

0
source

( mod_wsgi, nginx/uwsgi, , nginx/uwsgi ).

WSGIScriptAlias ​​- /sub-url URL- , django. URL- Django /sub-url ( mod_wsgi), URL-, "" /sub-url .

import django.core.handlers.wsgi

_application = django.core.handlers.wsgi.WSGIHandler()
def application(environ, start_response):
    #the line below will re-append the sub-url to all urls
    environ['PATH_INFO'] = environ['SCRIPT_NAME'] + environ['PATH_INFO']
    #this one will make django think that it the only thing running on the server
    environ['SCRIPT_NAME'] = '' # my little addition to make it work
    return _application(environ, start_response)

urls.py URL- .

, WSGIScriptAlias ​​ , -url:

#the below line will "take-out" the sub-url and pass the rest
#to your wsgi script
WSGIScriptAlias /sub-url /path/to/wsgi_script

/path/to/wsgi_script application, .

"sub-url" Django, Django .

0

Source: https://habr.com/ru/post/1727880/


All Articles