Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/353.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/django/19.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 如何在Apache Windows上为不同虚拟环境中的2个Django应用程序提供服务?_Python_Django_Apache_Virtualenv_Mod Wsgi - Fatal编程技术网

Python 如何在Apache Windows上为不同虚拟环境中的2个Django应用程序提供服务?

Python 如何在Apache Windows上为不同虚拟环境中的2个Django应用程序提供服务?,python,django,apache,virtualenv,mod-wsgi,Python,Django,Apache,Virtualenv,Mod Wsgi,我目前有两个Django应用程序在没有虚拟环境的服务器上运行(这不是一个好主意——这是一个新手的错误)。由于某些依赖性差异,我现在必须区分它们的环境。由于Windows上不提供WSGIDaemonProcess,我在Wamp中以以下方式管理它: 这是我的httpd.conf的相关部分: WSGIPythonPath "C:/wamp/www" WSGIScriptAlias /im "C:/wamp/www/im/im/wsgi.py" <Directory "C:/wamp/www/

我目前有两个Django应用程序在没有虚拟环境的服务器上运行(这不是一个好主意——这是一个新手的错误)。由于某些依赖性差异,我现在必须区分它们的环境。

由于Windows上不提供WSGIDaemonProcess,我在Wamp中以以下方式管理它:

这是我的httpd.conf的相关部分:

WSGIPythonPath "C:/wamp/www"

WSGIScriptAlias /im "C:/wamp/www/im/im/wsgi.py"

<Directory "C:/wamp/www/im/im">
    <Files wsgi.py>
        Order deny,allow
        Require all granted
    </Files>
</Directory>

Alias /im/static/ "C:/wamp/www/im/im/static_root/"

WSGIScriptAlias /tggs "C:/wamp/www/tggs/tggs/wsgi.py"

<Directory "C:/wamp/www/tggs/tggs">
    <Files wsgi.py>
        Order deny,allow
        Require all granted
    </Files>
</Directory>

Alias /tggs/static/ "C:/wamp/www/tggs/static_root/"
您还应检查:

import os
import sys
import site

ALLDIRS = ["C:\pyenv\tggs18\Lib\site-packages"]

# Add each new site-packages directory.
for directory in ALLDIRS:
    site.addsitedir(directory)

sys.path.append("C:/wamp/www/tggs/tggs")
sys.path.append("C:/wamp/www/tggs")

activate_env_file = "C:\\pyenv\\tggs18\\Scripts\\activate_this.py"
execfile(activate_env_file, dict(__file__=activate_env_file))

os.environ["DJANGO_SETTINGS_MODULE"] = "tggs.settings"

from django.core.wsgi import get_wsgi_application
application = get_wsgi_application()