在同一台apache服务器上运行django和flask

vwoqyblh  于 2023-03-03  发布在  Apache
关注(0)|答案(2)|浏览(164)

我正在尝试在同一个apache服务器上运行django和flask。

WSGISocketPrefix /var/www/wsgi
<VirtualHost *:80>
        ServerAdmin name@email.com
        ServerName  domain.com
        ServerAlias www.domain.com
        DocumentRoot /var/www/
        LogLevel warn
        WSGIDaemonProcess apache processes=2 maximum-requests=500 threads=1
        WSGIProcessGroup apache
        Alias /media /var/www/media/

        WSGIScriptAlias / /var/www/djangoapps/django.wsgi
        WSGIScriptAlias /app1 /var/www/flaskapps/app.wsgi
</VirtualHost>

1.第一个WSGIScriptAlias在根目录下运行一个django应用:domain.com.

  1. WSGIScriptAlias的第二个示例需要在子域中运行flask应用:app1.
    但由于主站点位于django之上,当我尝试点击:domain.com/app1,django的urls.py试图处理这个url命令,但是www.example.com不应该处理它,因为它是一个独立的flask应用。urls.py should not handle it, since its an independent flask app.
    你知道我该怎么做吗?
qojgxg4l

qojgxg4l1#

我不确定这是否能解决问题,但是您是否尝试过更改脚本别名的顺序,以便在/之前找到/app1

WSGISocketPrefix /var/www/wsgi
<VirtualHost *:80>
        ServerAdmin name@email.com
        ServerName  domain.com
        ServerAlias www.domain.com
        DocumentRoot /var/www/
        LogLevel warn
        WSGIDaemonProcess apache processes=2 maximum-requests=500 threads=1
        WSGIProcessGroup apache
        Alias /media /var/www/media/
        WSGIScriptAlias /app1 /var/www/flaskapps/app.wsgi
        WSGIScriptAlias / /var/www/djangoapps/django.wsgi

</VirtualHost>
uplii1fm

uplii1fm2#

对于任何想在2018年实现同样目标的人来说,这真的帮助了我:
https://www.phusionpassenger.com/library/deploy/apache/deploy/python/
我知道这是题外话,但我发现这个问题像20搜索之前,我找到了链接的描述从乘客...。
How ev's here是本教程的摘录:

<VirtualHost *:80>
    ServerName www.phusion.nl
    DocumentRoot /websites/phusion/public
<Directory /websites/phusion>
    Allow from all
    Options -MultiViews
    # Uncomment this if you're on Apache >= 2.4:
    #Require all granted
</Directory>

Alias /subapp /websites/secondapp/public
<Location /subapp>
    PassengerBaseURI /subapp
    PassengerAppRoot /websites/secondapp

    PassengerAppType wsgi
    PassengerStartupFile passenger_wsgi.py
</Location>
<Directory /websites/secondapp/public>
    Allow from all
    Options -MultiViews
    # Uncomment this if you're on Apache >= 2.4:
    #Require all granted
</Directory>

相关问题