Deploying old Django site to new server

喜你入骨 提交于 2019-11-29 18:14:46

you can try like this

import os

from django.core.wsgi import get_wsgi_application

import sys   
sys.path.append('/home/naturligvis/naturligvis-bzr/modules/')
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "your_project.settings")
application = get_wsgi_application()

if you use python2

sudo apt-get install python-pip apache2 libapache2-mod-wsgi

if you use python3

sudo apt-get install python3-pip apache2 libapache2-mod-wsgi-py3

your apache virtual host config should be like that

<VirtualHost *:80>
    ServerName dev.example.com #your server name
    ServerAlias dev.example.com #your server alias

    DocumentRoot #your document root
    WSGIProcessGroup dev.example.com
    WSGIPassAuthorization On
    WSGIDaemonProcess dev.example.com python-home=/home/robert/django/robertenv python-path=/home/robert/django/
    WSGIScriptAlias / /home/robert/django/project/wsgi.py process-group=dev.example.com

    Alias "/uploads" "/home/robert/django/uploads" #uploads directory

    <Directory #your document root>
            Require all granted

            RewriteEngine on
            RewriteCond %{REQUEST_FILENAME} -s [OR]
            RewriteCond %{REQUEST_FILENAME} -l [OR]
            RewriteCond %{REQUEST_FILENAME} -d
            RewriteRule ^.*$ - [NC,L]

            RewriteRule ^(.*) /index.html [NC,L]
    </Directory>

    <Directory /home/robert/django/uploads>
        Require all granted
    </Directory>

    <Directory /home/robert/django/project>
            <Files wsgi.py>
                    Require all granted
            </Files>
    </Directory>

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!