gpt4 book ai didi

django - 多个域,多个 django 项目,一台服务器

转载 作者:行者123 更新时间:2023-12-01 15:27:09 25 4
gpt4 key购买 nike

您好,我是 apache 和 mod_wsgi 的新手,我正在尝试弄清楚如何配置两者,以便我可以让 www.example1.com 使用 djangoproject1 和 www.example2.com 使用 djangoproject2。

我关注了这个tutorial将 example1.com 连接到 djangoproject1 并且它工作得很好,但是本教程并没有对正在发生的事情以及为什么我需要做某些事情给出最详细的解释。

我目前拥有的:

1) 指向服务器 ip 的 example2.com 的 dns 区域

2) 按照 tutorial 上的说明安装 python 环境和 django 并为 djangoproject2 启动一个新的 django 项目

我很确定我将不得不创建一个新的 wsgi 配置文件并在/etc/apache2/sites-available/中添加一个名为 example2.com 的站点配置,然后启用它,但我没有确定我还需要做什么。

最佳答案

您的 apache 配置中可以有 2 个虚拟主机。

第一个虚拟主机(默认)- 端口 80第二个在 81 端口

在虚拟主机中,可以这样指定:

NameVirtualHost *:80

<VirtualHost *.80>
DocumentRoot django_project_1_path
.... other config
WSGIScriptAlias / path_to_wsgi_config_1
</VirtualHost>

NameVirtualHost *:81

<VirtualHost *.81>
DocumentRoot django_project_2_path
.... other config
WSGIScriptAlias / path_to_wsgi_config_2
</VirtualHost>

关于django - 多个域,多个 django 项目,一台服务器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12332089/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com