在Apache服务器上同时运行多个Django程序的方法
作者:goldensun 时间:2022-05-16 11:16:09
在同一个 Apache 实例中运行多个 Django 程序是完全可能的。 当你是一个独立的 Web 开发人员并有多个不同的客户时,你可能会想这么做。
只要像下面这样使用 VirtualHost 你可以实现:
NameVirtualHost *
<VirtualHost *>
ServerName www.example.com
# ...
SetEnv DJANGO_SETTINGS_MODULE mysite.settings
</VirtualHost>
<VirtualHost *>
ServerName www2.example.com
# ...
SetEnv DJANGO_SETTINGS_MODULE mysite.other_settings
</VirtualHost>
如果你需要在同一个 VirtualHost 中运行两个 Django 程序,你需要特别留意一下以 确保 mod_python 的代码缓存不被弄得乱七八糟。 使用 PythonInterpreter 指令来将不 同的 <Location> 指令分别解释:
<VirtualHost *>
ServerName www.example.com
# ...
<Location "/something">
SetEnv DJANGO_SETTINGS_MODULE mysite.settings
PythonInterpreter mysite
</Location>
<Location "/otherthing">
SetEnv DJANGO_SETTINGS_MODULE mysite.other_settings
PythonInterpreter mysite_other
</Location>
</VirtualHost>
这个 PythonInterpreter 中的值不重要,只要它们在两个 Location 块中不同。
标签:Apache,Django
![](/images/zang.png)
![](/images/jiucuo.png)
猜你喜欢
使用tensorflow框架在Colab上跑通猫狗识别代码
2022-04-27 04:43:39
![](https://img.aspxhome.com/file/2023/1/104821_0s.png)
Python实现读写INI配置文件的方法示例
2021-03-16 08:10:08
python 如何对Series中的每一个数据做运算
2023-11-19 23:33:07
![](https://img.aspxhome.com/file/2023/7/82517_0s.png)
彻底理解Python list切片原理
2023-10-19 03:34:43
PHP登录验证功能示例【用户名、密码、验证码、数据库、已登陆验证、自动登录和注销登录等】
2023-11-14 23:24:02
![](https://img.aspxhome.com/file/2023/5/86925_0s.png)
Python使用xpath实现图片爬取
2023-07-10 16:45:42
Python 日期的转换及计算的具体使用详解
2023-01-06 11:31:27
js控制div弹出层实现方法
2023-10-15 05:53:28
python基础之元组
2021-06-28 08:06:24
![](https://img.aspxhome.com/file/2023/7/112567_0s.png)
python pandas中的agg函数用法
2023-07-20 09:40:08
![](https://img.aspxhome.com/file/2023/8/61178_0s.png)
python+tifffile之tiff文件读写方式
2022-03-16 13:17:41
解决tensorflow训练时内存持续增加并占满的问题
2021-09-24 02:48:05
Python3中FuzzyWuzzy库实例用法
2022-01-30 18:49:49
python最长回文串算法
2023-03-05 02:27:37
Python实例详解递归算法
2023-05-17 02:25:06
![](https://img.aspxhome.com/file/2023/0/121760_0s.png)
Python中使用haystack实现django全文检索搜索引擎功能
2023-06-30 07:21:03
selenium+python 去除启动的黑色cmd窗口方法
2023-06-07 10:56:27
python目标检测SSD算法训练部分源码详解
2021-08-01 02:23:15
![](https://img.aspxhome.com/file/2023/7/79787_0s.png)
Fibonacci数,Θ(log n)
2010-03-28 13:28:00
使用Python标准库中的wave模块绘制乐谱的简单教程
2023-11-20 14:21:35
![](https://img.aspxhome.com/file/2023/5/63525_0s.jpg)