如何把Django的本地开发服务器并使其阿帕奇/ modwsgi compatable? [英] how to take django from local dev server and make it apache/modwsgi compatable?

查看:124
本文介绍了如何把Django的本地开发服务器并使其阿帕奇/ modwsgi compatable?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是我的第一个Django的网站,我有阿帕奇/ modwsgi /部署Django的或与此有关的任何网站没有的experiance。我真的很迷茫的,我应该如何使用我的本地Web服务器上有它使用的mod_wsgi / apache中,然后从去把它发送到远程服务器,网上有它去。我真的需要一些一步在哪里/如何获得modwsgi / Apache和安装它们和常见问题一步的方向?真的这可能是问了很多,但这种性质的东西有任何联系将是真棒。


解决方案

基本上mod_wsgi的是Apache与Python接口的方式。 Apache的网站将与WSGIScriptAlias​​指令定义的WSGI文件。这WSGI文件将有一些基本的设置细节和一些路径选项来设置Apache的环境与你的Djanog项目工作。

在Linux中,a2enmod WSGI应使WSGI模块。您可能需要安装该模块。

一旦这样安装/启动创建在/ etc / apache2的/网站可用在它下面的行网站:

  WSGIScriptAlias​​ / /path/to/wsgi/file.wsgi

然后使用 a2ensite&LT;&SITE_NAME GT; 来启用该网站。为Apache网站指令一个很好的参考是rel=\"nofollow\">主机与Apache2的多个站点,它只是简单地创建了Apache的启用站点文件夹的链接<这将让你开始有独立的网站,每个人都有与 a2ensite&LT启用/ p>

该网站指令的Django的WSGI部分一个很好的参考是 Django的 - 如何使用Django与Apache和mod_wsgi的。这将帮助你建立WSGI文件。

this is my first django site and I have no experiance with apache/modwsgi/deploying django or any website for that matter. I'm really confused on how I'm supposed to go from using my local webserver to having it use mod_wsgi/apache and then from that going to sending it to the remote server to have it online. really I need some step by step directions on where/how to get modwsgi/apache and install them and a FAQ? really that's probably asking a lot but any links to things of this nature would be awesome.

解决方案

Basically mod_wsgi is a way for Apache to interface with Python. Your Apache site will have a wsgi file defined with the WSGIScriptAlias directive. This wsgi file will have some basic settings details and some path options to set the Apache environment to work with your Djanog project.

On linux, a2enmod wsgi should enable the wsgi module. You may need to install the module.

Once that's installed/enabled create a site in /etc/apache2/sites-available with the following line in it:

WSGIScriptAlias / /path/to/wsgi/file.wsgi

Then use a2ensite <site_name> to enable the site. A good reference for the Apache site directive is the example in Hosting Multiple Sites with Apache2. This will get you started with separate sites, each one has to be enabled with a2ensite <name>, which simply creates a link in the sites-enabled folder of Apache.

A good reference for Django's WSGI portion of the site directive is at Django - How to use django with Apache and mod_wsgi. This will help you set up the wsgi file.

这篇关于如何把Django的本地开发服务器并使其阿帕奇/ modwsgi compatable?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆