在 Windows 上使用 Apache 托管 PHP/JS 和 Django 应用程序

Host both PHP/JS and Django applications with Apache on Windows

我在 Windows 10(64 位)上安装了 WAMP 服务器 3.2 (Apache 2.4.46),它暴露在本地公司网络中。我用它来托管普通的 php/js 应用程序。我的 httpd-vhosts.conf 习惯是这样的:

<VirtualHost *:80>
    ServerName RealNameOfTheServer
    DocumentRoot "d:/projects"
    <Directory  "d:/projects/">
        Options +Indexes +Includes +FollowSymLinks +MultiViews
        AllowOverride All
        Require all granted
    </Directory>
</VirtualHost>

现在我得到了一个 Django 应用程序,它最好与其他 php 应用程序一起托管在同一台服务器上(因为我没有其他服务器)。我尝试按照 配置我的虚拟主机,但它使用 Windows.

上不可用的守护进程

我的 httpd-vhosts.conf 在应用更改后使 Django 应用程序正常工作但转储 php/js 个应用程序。

<VirtualHost *:80>
    ServerName RealNameOfTheServer
    DocumentRoot "d:/projects"
    <Directory  "d:/projects/">
        Options +Indexes +Includes +FollowSymLinks +MultiViews
        AllowOverride All
        Require all granted
    </Directory>

    WSGIPassAuthorization On
    ErrorLog "logs/dashboard.error.log"
    CustomLog "logs/dashboard.access.log" combined
    WSGIScriptAlias /  "d:\projects\dashboard\dashboard\wsgi_windows.py"
    WSGIApplicationGroup %{GLOBAL}
    <Directory "d:\projects\dashboard\dashboard">
        <Files wsgi_windows.py>
            Options +Indexes +Includes +FollowSymLinks +MultiViews
            AllowOverride All
            Require all granted
        </Files>
    </Directory>

    Alias /static "d:/projects/dashboard/static"
    <Directory "d:/projects/dashboard/static">
        Require all granted
    </Directory>  
</VirtualHost>

有什么方法可以 运行 php 和 Windows 上的 Django 应用程序吗?

WSGIScriptAlias /  "d:\projects\dashboard\dashboard\wsgi_windows.py"

也会捕获对“d:/projects”的调用 - 所以如果你想避免这种情况,你需要更改为

WSGIScriptAlias /my_wsgi_app/  "d:\projects\dashboard\dashboard\wsgi_windows.py"

如果你想避免用户看到,你可以对某些路径使用重写规则。