在 apache https 服务器中运行多个 django 应用程序,一个在 / 中,另一个在 /app2 中

发布于 2025-01-10 19:13:03 字数 2423 浏览 0 评论 0原文

我正在尝试在同一服务器 ssl 端口 443 中部署两个 django 应用程序。当我在第一个块中评论以下三行时,app2 正在运行,而在第二个块中注释时,app1 正在运行,并且当在两个块中取消注释时,两个应用程序都没有运行并显示内部服务器显示错误和 apache 错误日志

mod_wsgi (pid=48352): 无法执行 Python 脚本文件“/var/www/html/app1/app1/wsgi.py”。

WSGIDaemonProcess ......
WSGIProcessGroup ...... 
WSGIScriptAlias ......

我的 default.conf 文件 VirtualHost *:443 块如下,

    Alias /static /var/www/html/app1/static
    <Directory /var/www/html/app1/static>
            Require all granted
    </Directory>

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


    WSGIDaemonProcess app1 python-path=/var/www/html/app1
    WSGIProcessGroup app1
    WSGIScriptAlias / /var/www/html/app1/app1/wsgi.py
    Alias /museum/static /var/www/html/app2/static
    <Directory /var/www/html/app2/static>
           Require all granted
    </Directory>

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

    #WSGIDaemonProcess app2 python-path=/var/www/html/app2
    #WSGIProcessGroup app2
    #WSGIScriptAlias /app2 /var/www/html/app2/app2/wsgi.py

对于上面的代码 app1 运行完美,

    Alias /static /var/www/html/app1/static
    <Directory /var/www/html/app1/static>
            Require all granted
    </Directory>

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


    #WSGIDaemonProcess app1 python-path=/var/www/html/app1
    #WSGIProcessGroup app1
    #WSGIScriptAlias / /var/www/html/app1/app1/wsgi.py
    Alias /museum/static /var/www/html/app2/static
    <Directory /var/www/html/app2/static>
           Require all granted
    </Directory>

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

    WSGIDaemonProcess app2 python-path=/var/www/html/app2
    WSGIProcessGroup app2
    WSGIScriptAlias /app2 /var/www/html/app2/app2/wsgi.py

对于上面的代码 app2 运行完美,

我想同时运行两台服务器。

I am trying to deploy two django apps in same server ssl port 443. While I comment following three lines in first block app2 is running while commenting in second block app1 is running and when uncommenting in both block both apps is not running and showing Internal Server Error and apache error log showing

mod_wsgi (pid=48352): Failed to exec Python script file '/var/www/html/app1/app1/wsgi.py'.

WSGIDaemonProcess ......
WSGIProcessGroup ...... 
WSGIScriptAlias ......

my default.conf file VirtualHost *:443 block is as follows

    Alias /static /var/www/html/app1/static
    <Directory /var/www/html/app1/static>
            Require all granted
    </Directory>

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


    WSGIDaemonProcess app1 python-path=/var/www/html/app1
    WSGIProcessGroup app1
    WSGIScriptAlias / /var/www/html/app1/app1/wsgi.py
    Alias /museum/static /var/www/html/app2/static
    <Directory /var/www/html/app2/static>
           Require all granted
    </Directory>

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

    #WSGIDaemonProcess app2 python-path=/var/www/html/app2
    #WSGIProcessGroup app2
    #WSGIScriptAlias /app2 /var/www/html/app2/app2/wsgi.py

for the above code app1 is running perfectly

    Alias /static /var/www/html/app1/static
    <Directory /var/www/html/app1/static>
            Require all granted
    </Directory>

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


    #WSGIDaemonProcess app1 python-path=/var/www/html/app1
    #WSGIProcessGroup app1
    #WSGIScriptAlias / /var/www/html/app1/app1/wsgi.py
    Alias /museum/static /var/www/html/app2/static
    <Directory /var/www/html/app2/static>
           Require all granted
    </Directory>

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

    WSGIDaemonProcess app2 python-path=/var/www/html/app2
    WSGIProcessGroup app2
    WSGIScriptAlias /app2 /var/www/html/app2/app2/wsgi.py

for the above code app2 is running perfectly

I want to run both servers together.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

幽梦紫曦~ 2025-01-17 19:13:03

我建议您将每个应用程序放在 Apache 中的单独虚拟主机中,并进行重写以区分将哪个请求路由到哪个应用程序。

I would suggest you to put each app in an individual virtual host in Apache and do a rewrite to distinguish to which one to route which request.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文