We installed python version 3.6 and apache 2.4 on CentOS 8 and connect with postgresql.
And then installed mod_wsgi for run python code.
After we make some configuration in /etc/httpd/conf.d/wsgi.conf as follows -
--------------------------------------------------------------------------------
LoadModule wsgi_module /etc/httpd/modules/mod_wsgi_python3.so
Alias /map /var/www/map/
<Directory /var/www/orikomap/>
Options ExecCGI MultiViews Indexes
MultiViewsMatch Handlers
AddHandler wsgi-script .py
AddHandler wsgi-script .wsgi
DirectoryIndex index.html index.php index.py app.wsgi
Order allow,deny
Allow from all
</Directory>
----------------------------------------------------------------------------------------
And then we add python code to target directory -> /var/www/map/index.py as follow
-------------------------------------------------------------------------------------------
import sys
def application(environ, start_response):
status = '200 OK'
output = u'mod_wsgi.process_group = %s' % repr(environ['mod_wsgi.process_group'])
response_headers = [('Content-type', 'text/plain'),
('Content-Length', str(len(output)))]
start_response(status, response_headers)
return [output.encode('UTF-8')]
----------------------------------------------------------------------------------------
we got follow result -
After we add a new python file on the same directory -> /var/www/map/map.py .
but we can't call another python file as follow.
http//:ipaddress/polygon.py
----------------------------------------------------------------------------------------------
[Fri Oct 29 03:56:35.064042 2021] [wsgi:error] [pid 2840:tid 140610811930368] [client
192.168.1.8:53246] mod_wsgi (pid=2840): Target WSGI script '/var/www/map/polygon.py' does not contain WSGI application 'application'.
So how can we solve this problem, how to run other Python files on the same directory using wsgi.
Thank you.