How should I add WSGIPython path in VirtualHost for Windows server?

后端 未结 1 1203
终归单人心
终归单人心 2021-01-26 22:39

I am trying to add WSGIPythonPath in VirtualHost but it\'s throwing me an error:

Syntax error on line 549 of /etc/httpd/conf/httpd.

相关标签:
1条回答
  • 2021-01-26 23:04

    I had a difficult journey setting up two virt. hosts with Apache mod_wsgi under Windows. So the solution here is for Apache/mod_wsgi and Windows.

    In general I find it quite difficult to seperate Apache/mod_wsgi for windows and unix as in many articles the two are mixed or it is not clearly mentioned at all which one is being talked about.

    1. Here is the important part of virt host definition in httpd-vhosts.conf because in Apache/mod_wsgi for Windows you have no WSGIDaemonProcess/WSGIProcessGroup availible.
       <VirtualHost *:80>
                ServerName name1
                WSGIScriptAlias / "D:/....../wsgi.py" application-group=site1
                ......                                                                            
         </VirtualHost>
     
        <VirtualHost *:80>
                ServerName name2
                WSGIScriptAlias / "D:/....../wsgi.py" application-group=site2
                ......                                                                            
         </VirtualHost>
    

    If you do not add "application-group..." only the virtual host that is first called after Apache restart will initialize with wsgi.py and settings.py and afterwards will get all requests to virt. hosts that have a WSGIScriptAlias or in other words that are handled by mod_wsgi!! To my understanding this is a rather serious bug because a virt host should always get his own "thread" as standard behavior of Apache/mod_wsgi. Btw Site1 and Site2 are just names that must be different.

    1. The WSGIPythonPath can not be assigned inside the virt. Hosts section. You need to put the equivalent path assignment in the wsgi.py file of each of your apps:
        sys.path.append('D:/........../xxxxx_project/xxxxx')
        os.environ['DJANGO_SETTINGS_MODULE'] = 'xxxxx.settings'
        application = get_wsgi_application()
    
    0 讨论(0)
提交回复
热议问题