【问题标题】:apache/mod_wsgi - how to configure mutiple webapps using different python virtual environmentsapache/mod_wsgi - 如何使用不同的 python 虚拟环境配置多个 webapps
【发布时间】:2020-04-02 05:34:52
【问题描述】:

环境:Ubuntu,Apache HTTPD,用python 3.6编译的mod_wsgi,网站(假设):testthisout.com

问题:我有 2 个不同的 webapps,它们将使用 2 个不同的 python 虚拟环境。 它们将托管在 testthisout.com/app1testthisout.com/app2

我正在努力弄清楚如何告诉 apache 使用 2 个不同的虚拟环境。

相关 Apache 配置

LoadModule wsgi_module "/apps/python/lib/python3.6/site-packages/mod_wsgi/server/mod_wsgi-py36.cpython-36m-x86_64-linux-gnu.so"
WSGIPythonHome "/apps/python"



<VirtualHost *:80>
        ServerName testthisout.com
        ServerAdmin testthisout@gmail.com

        WSGIScriptAlias /app1 /var/www/flaskapp/app1/app1.wsgi
        WSGIScriptAlias /app2 /var/www/flaskapp/app2/app2.wsgi

</VirtualHost>

理想情况下,app1 应该使用托管在 /apps/python/python-app1/ 的 python 包 理想情况下,app2 应该使用托管在 /apps/python/python-app2/ 的 python 包

尝试了以下页面,但仍然不明白如何执行此操作...

https://modwsgi.readthedocs.io/en/develop/user-guides/virtual-environments.html https://modwsgi.readthedocs.io/en/develop/user-guides/configuration-guidelines.html

如有任何建议,请告诉我...

【问题讨论】:

    标签: python django flask mod-wsgi httpd.conf


    【解决方案1】:

    经过大量研究后,我终于想出了一些可行的方法......

        ServerName localhost
    
        WSGIDaemonProcess website1 python-home=/apps/python/python-website1-toolkit display-name=website1
        WSGIScriptAlias /website1 /var/www/flaskapp/python-website1-webapp/website1.wsgi
        <Directory /var/www/flaskapp/python-website1-webapp/>
                WSGIApplicationGroup website1
                WSGIProcessGroup website1
                Order deny,allow
                Allow from all
        </Directory>
        Alias /website1/static /var/www/flaskapp/python-website1-webapp/static
        <Directory /var/www/flaskapp/python-website1-webapp/static/>
                Order allow,deny
                Allow from all
        </Directory>
    
        WSGIDaemonProcess website2 python-home=/apps/python/python-website2-toolkit display-name=website2
        WSGIScriptAlias /website2 /var/www/flaskapp/python-website2-webapp/website2.wsgi
        <Directory /var/www/flaskapp/python-website2-webapp>
                WSGIApplicationGroup website2
                WSGIProcessGroup website2
                Order deny,allow
                Allow from all
        </Directory>
        Alias /website2/static /var/www/flaskapp/python-website2-webapp/static
        <Directory /var/www/flaskapp/python-website2-webapp/static/>
                Order allow,deny
                Allow from all
        </Directory>
    
    
        WSGIDaemonProcess website3 python-home=/apps/python/python-website3-toolkit display-name=website3
        WSGIScriptAlias /website3 /var/www/flaskapp/python-website3-webapp/website3.wsgi
        <Directory /var/www/flaskapp/python-website3-webapp/>
                WSGIApplicationGroup website3
                WSGIProcessGroup website3
                Order deny,allow
                Allow from all
        </Directory>
        Alias /website3/static /var/www/flaskapp/python-website3-webapp/static
        <Directory /var/www/flaskapp/python-website3-webapp/static/>
                Order allow,deny
                Allow from all
        </Directory>
    
    
        ErrorLog ${APACHE_LOG_DIR}/error.log
        LogLevel warn
        CustomLog ${APACHE_LOG_DIR}/access.log combined
    

    【讨论】:

      猜你喜欢
      • 2020-01-29
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-11-06
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多