使用 mod_wsgi 在 Apache 上使用 Django 时必须重新启动 Apache

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/2353012/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-13 18:50:37  来源:igfitidea点击:

Have to Restart Apache When Using Django On Apache with mod_wsgi

pythondjangoapachemod-wsgirestart

提问by macinjosh

I'm creating a web app with Django. Since I'm very familiar with Apache I setup my development environment to have Django run through Apache using mod_wsgi. The only annoyance I have with this is that I have to restart Apache everytime I change my code. Is there a way around this?

我正在用 Django 创建一个网络应用程序。因为我对 Apache 非常熟悉,所以我设置了我的开发环境,让 Django 使用 mod_wsgi 通过 Apache 运行。我对此唯一的烦恼是每次更改代码时都必须重新启动 Apache。有没有解决的办法?

回答by Desintegr

mod_wsgi is great for production but I think the included server is better for development.

mod_wsgi 非常适合生产,但我认为包含的服务器更适合开发。

Anyway you should read thisabout automatic reloading of source code.

反正你应该阅读有关的源代码自动重新加载。

回答by b3ng0

I feel like this is really just one of those things most people deal with. It's really not that big of a deal. I made a bash script to make this as easy as possible. I name it 'ra' (reload apache) so it's short and quick. The following works for most apache installs (on UNIX-based systems):

我觉得这真的只是大多数人处理的事情之一。这真的没什么大不了的。我制作了一个 bash 脚本来使这尽可能简单。我将其命名为“ra”(重新加载 apache),因此它既简短又快速。以下适用于大多数 apache 安装(在基于 UNIX 的系统上):

#!/bin/bash
sudo /etc/init.d/apache2 reload

You could probably use some kind of tool to bind this to a key shortcut/foot pedeal/cron.

您可能可以使用某种工具将其绑定到快捷键/脚踏板/cron。