在Apache伺服器上同時運行多個Django程式的方法

來源:互聯網
上載者:User
在同一個 Apache 執行個體中運行多個 Django 程式是完全可能的。 當你是一個獨立的 Web 開發人員並有多個不同的客戶時,你可能會想這麼做。

只要像下面這樣使用 VirtualHost 你可以實現:

NameVirtualHost *  ServerName www.example.com  # ...  SetEnv DJANGO_SETTINGS_MODULE mysite.settings  ServerName www2.example.com  # ...  SetEnv DJANGO_SETTINGS_MODULE mysite.other_settings

如果你需要在同一個 VirtualHost 中運行兩個 Django 程式,你需要特別留意一下以 確保 mod_python 的代碼緩衝不被弄得亂七八糟。 使用 PythonInterpreter 指令來將不 同的 指令分別解釋:

  ServerName www.example.com  # ...      SetEnv DJANGO_SETTINGS_MODULE mysite.settings    PythonInterpreter mysite        SetEnv DJANGO_SETTINGS_MODULE mysite.other_settings    PythonInterpreter mysite_other  

這個 PythonInterpreter 中的值不重要,只要它們在兩個 Location 塊中不同。

  • 聯繫我們

    該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

    如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.