We will deploy python 3 flask source code using:
yum install httpd-develpip3 install mod-wsgimod_wsgi-express install-module > /etc/httpd/conf.modules.d/02-wsgi.confvi /etc/httpd/conf.modules.d/02-wsgi.conf# # /etc/httpd/conf.modules.d/02-wsgi.conf
LoadModule wsgi_module "/usr/lib64/httpd/modules/mod_wsgi-py34.cpython-34m.so"For each application (exampe of 'rmd ' application installed on '/opt' ):
WSGIScriptAlias /rmd /opt/rmd/wsgi.pyWSGIRestrictStdout OffWSGIDaemonProcess rmd.srv.devel processes=2 threads=15 display-name=%{GROUP} python-path=/opt/rmd:/usr/lib64/python3.4/site-packagesWSGIProcessGroup rmd.srv.devel<Directory "/opt/rmd"> WSGIScriptReloading On WSGIApplicationGroup %{GLOBAL} AllowOverride All Require all granted</Directory>copy source to server, then set permission:
find . -type f -exec chmod 640 {} \;find . -type d -exec chmod 750 {} \;# # vi wsgi.py
import sysPROJECT_DIR = '/opt/rmd'sys.path.insert(0, PROJECT_DIR)from rmd import app as applicationdel sysif __name__ == "__main__": application.run()sudo systemctl restart httpdtail /var/log/httpd/error_loginstall --> [Server Manager - Role Service -CGI]
pip install wfastcgipip install virtualenvvirtualenv venv3PATH --> C:\Program Files\Python37\Scripts\;C:\Program Files\Python37\;
...
PowerSheel(Admin) --> Set-ExecutionPolicy RemoteSigned
FOLDER Permission --> IIS_IUSRS --> Full
IIS Manager --> Make Site --> STOP --> Handler Mapping --> Add Module Mapping
executable --> "C:\Program Files\Python37\python.exe"|C:\dir_to\application.py
IIS Manager --> FAST CGI Setting --> Add Application
PYTHONPATH C:\dir_to_application\venv3\Lib\site-packages;C:\dir_to_application;c:\Program Files\Python37;c:\Program Files\Python37\Lib\site-packages;
WSGI_HANDLER application_filename.app