开发者

django deployment apache

开发者 https://www.devze.com 2022-12-22 18:07 出处:网络
I would like to create a python script, which will: Create a django project in the current directory. Fix settings.py, urls.py.

I would like to create a python script, which will:

  1. Create a django project in the current directory. Fix settings.py, urls.py.
  2. Do syncdb
  3. Install new apache instance listening on specific port (command line argument), with WSGI configured to serve my project.

I can't figure out how to do point 3.

EDIT:

Peter Rowell:

  • I need the s开发者_如何转开发olution for both Linux and Windows
  • I have root access
  • This is a dedicated host
  • Apache only


Jacob Kaplan Moss' Django Deployment Workshop assets have some nice examples. You'll probably still need to do some legwork on your end to automate things to your taste but there may be some stuff in there you can use as a starting point.

http://github.com/jacobian/django-deployment-workshop


One way is to use Apache's mod_wsgi. After installing, you create a wsgi file and point Apache's config to it.

Sample wsgi file:

import os
import sys

sys.path.append('/path/to/settings.py')
os.environ['DJANGO_SETTINGS_MODULE'] = 'mydjangoapp.settings'

import django.core.handlers.wsgi
application = django.core.handlers.wsgi.WSGIHandler()

Add this to your apache config (on Linux it is in /etc/apache2/sites-available/default):

<VirtualHost *:1234>
        ServerName my.host.name.com
        WSGIScriptAlias / /path/to/wsgi/file/django.wsgi
</VirtualHost>

(assuming the port is 1234)

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号