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

Time:03-22

I have a WAMP Server 3.2 (Apache 2.4.46) installed on Windows 10 (64-bits), it is exposed to the local company network. I use it to host ordinary php/js applications. My httpd-vhosts.conf is used to look like this:

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

Now I got a Django app which preferably needs to be hosted with the same server (since I don't have any other) along with other php applications. I tried to follow the example to configure my virtual hosts, but it uses daemon process which is not available on Windows.

My httpd-vhosts.conf after applied changes makes Django app work correctly but dumps php/js apps.

<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>

Is there any way to run both php and Django apps on Windows?

CodePudding user response:

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

will also catch calls to "d:/projects" - so if you want to avoid that, you need to change to something like

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

If you want to avoid that the user can see that, you can use a rewrite rule for certain paths.

  • Related