Hi, I want to host multiple Flask apps through Apache in the same Windows 
10 server. I want each app to be running on different ports. I figured that 
each app must have its own Python configuration, otherwise Apache will only 
run one of the two web apps. I have seen that in Linux you are supposed to 
use WSGIDaemonProcess command in the VirtualHost file, but this does not 
work on Windows.

I tried using

import sys
activate_this = 'C:/CRM4_Flask/venv/Scripts/activate_this.py'
with open(activate_this) as file_:
exec(file_.read(), dict(__file__=activate_this))

#Expand Python classes path with your app’s path
# The string inputted as the parameter corresponds to the web app's path in 
C
sys.path.insert(0, "C:/CRM4_Flask")

from run import app as application

in my run.wsgi file for each app. However, I always get the following error:

Fatal Python error: initfsencoding: unable to load the file system codec
ModuleNotFoundError: No module named 'encodings'

What alternative do I have instead of using WSGIDaemonProcess, given that 
it does not work on Windows? Im using Apache 2.4, Python 3.7.7, Windows 10 
and mod_wsgi 4.7.1

My VirtualHost configuration for one of the web apps I want to host is:


<VirtualHost *:80>

    ServerName localhost:80
    ServerAlias localhost:80
    ServerAdmin [email protected]

    DocumentRoot c:/CRM4_Flask

    <Directory c:/CRM4_Flask>
        Require all granted
    </Directory>

    WSGIScriptAlias / c:/CRM4_Flask/run.wsgi
    WSGIApplicationGroup %{GLOBAL}

    <Directory c:/CRM4_Flask>
        Options +FollowSymLinks
        Require all granted
    </Directory>

    ErrorLog "logs/crm4-error.log" 
    CustomLog "logs/crm4-access.log" common 

</VirtualHost>

In the httpd.conf I added the following lines:

LoadFile 
"c:/users/administrator/appdata/local/programs/python/python37/python37.dll"
LoadModule wsgi_module 
"c:/crm4_flask/venv/lib/site-packages/mod_wsgi/server/mod_wsgi.cp37-win_amd64.pyd"
#WSGIPythonHome "c:/crm4_flask/venv"

I commented WSGIPythonHome because in theory I need Apache to load two 
versions of Python, not only one.

Please let me know if I am doing something wrong or if I should try 
something else.

Thanks guys!




-- 
You received this message because you are subscribed to the Google Groups 
"modwsgi" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/modwsgi/56ebe6cf-7d8d-467c-b6af-de9d97cf91b9n%40googlegroups.com.

Reply via email to