【问题标题】:Deploy different version of django application in same server在同一台服务器上部署不同版本的 django 应用程序
【发布时间】:2019-09-18 10:49:19
【问题描述】:

我正在使用 Apache 和 mod_wsgi 在我的服务器上部署一个 django 应用程序。我正在使用 wsgi 的守护程序模式在服务器上运行 django 应用程序。

现在我的目标是我可以在同一台服务器上拥有两个或多个版本的 django 应用程序(每个都有自己的设置、数据库等)。例如:

https://test-server.com/
https://test-server.com/dev

我已更新位于 /etc/apache2/sites-available 的 apache 配置文件。 这是我的配置文件:-

<IfModule mod_ssl.c>
<VirtualHost *:443>
        ServerAdmin xyz@gmail.com
    ServerName test-server.com
    ServerAlias www.test-server.com
    #DocumentRoot /var/www/html

    Alias /static /var/www/html/Smart_chat_share/smart_chat_share/static  // This should accesible via https://test-server.com/ which is working
    <Directory /var/www/html/Smart_chat_share/smart_chat_share/static>
            Require all granted
    </Directory>

    WSGIDaemonProcess smart_chat_share python-home=/var/www/html/Smart_chat_share/smart_chat_share/virtual_env python-path=/var/www/html/Smart_chat_share/smart_chat_share
    WSGIProcessGroup smart_chat_share
    WSGIScriptAlias / /var/www/html/Smart_chat_share/smart_chat_share/smart_chat_share/wsgi.py process-group=smart_chat_share application-group=%{GLOBAL}

    <Directory /var/www/html/Smart_chat_share/smart_chat_share/smart_chat_share>
            <Files wsgi.py>
                 Require all granted
            </Files>
    </Directory>

    Alias /dev/static /var/www/html/dev/smart_chat_share/static // This should accesible via https://test-server.com/dev which is not working.
    <Directory /var/www/html/dev/smart_chat_share/static>
            Require all granted
    </Directory>

    WSGIDaemonProcess dev python-home=/var/www/html/dev/smart_chat_share/virtual_env python-path=/var/www/html/dev/smart_chat_share
    WSGIProcessGroup dev
    WSGIScriptAlias /dev /var/www/html/dev/smart_chat_share/smart_chat_share/wsgi.py process-group=smart_chat_share application-group=%{GLOBAL}

    <Directory /var/www/html/dev/smart_chat_share/smart_chat_share>
            <Files wsgi.py>
                 Require all granted
            </Files>
    </Directory>

    ErrorLog ${APACHE_LOG_DIR}/error.log
    CustomLog ${APACHE_LOG_DIR}/access.log combined

SSLCertificateFile /etc/letsencrypt/live/scss.identixweb.com/fullchain.pem
SSLCertificateKeyFile 
/etc/letsencrypt/live/scss.identixweb.com/privkey.pem
Include /etc/letsencrypt/options-ssl-apache.conf
</VirtualHost>
</IfModule>

https://test-server.com/ 这是工作版本,但https://test-server.com/dev 这是第二个版本,我无法访问和测试。当谈到 Apache 配置时,我经常迷失方向。非常感谢您的帮助。 非常感谢!

【问题讨论】:

    标签: django apache mod-wsgi


    【解决方案1】:

    以防万一有人遇到这个问题,这是我的答案。我只是通过重新排序文件中 django 应用程序的配置来解决它。确保首先出现子目录,然后是应用程序配置的根目录。

    这个文档非常有帮助:- http://blog.dscpl.com.au/2012/10/requests-running-in-wrong-django.html

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2016-09-05
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-02-18
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多