0

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?

  • What do you mean exactly by "dumps php/js apps"? What request do you send and what is the reaction? – Razenstein Mar 16 '22 at 04:43
  • I mean that Apache doesn't recognize them as php/js applications and wants to treat them as Django apps applying wsgi_windows.py to them either. If I set "DEBUD = True" in my Django app, so I get the following error when I try to open a php app. Using the URLconf defined in dashboard.urls, Django tried these URL patterns, in this order: dashboard/ admin/ The current path, PhPapplication, didn’t match any of these. – Elena Klimenko Mar 16 '22 at 08:14

1 Answers1

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

Razenstein
  • 3,532
  • 2
  • 5
  • 17
  • Thak you for your answer. I have tried what you suggested and still can not make it through. My php apps work nicely now. But I can not get Django at place. The url "http://my_server_name/my_wsgi_app/" returns django error: "Using the URLconf defined in dashboard.urls, Django tried these URL patterns, in this order: dashboard/ admin/ The empty path didn’t match any of these." However, when I try the url "http://my_server_name/my_wsgi_app/dashboard" I get an apache error "The requested URL was not found on this server." – Elena Klimenko Mar 21 '22 at 08:28
  • Ok, I have figure it out! WSGIScriptAlias /my_wsgi_app "d:\projects\dashboard\dashboard\wsgi_windows.py" makes the job! – Elena Klimenko Mar 21 '22 at 08:49