WSGI (Web Server Gateway Interface) — стандарт взаимодействия между Python-программой, выполняющейся на стороне сервера, и самим веб-сервером, например Apache.
1. Установка mod_wsgi
[root@unihost ~]# yum -y install mod_wsgi
2. Кофигурируем mod_wsgi для доступа /user_wsgi в backend /var/www/html/user_wsgi.py.
[root@unihost ~]# vi /etc/httpd/conf.d/wsgi.conf
WSGIScriptAlias /test_wsgi /var/www/html/user_wsgi.py
3. Создаем тестовый скрипт
[root@unihost ~]# vi /var/www/html/user_wsgi.py
def application(environ,start_response):
status = '200 OK'
html = '<html>\n' \
'<body>\n' \
'<div style="width: 100%; font-size: 40px; font-weight: bold; text-align: center;">\n' \
'mod_wsgi Test Page\n' \
'</div>\n' \
'</body>\n' \
'</html>\n'
response_header = [('Content-type','text/html')]
start_response(status,response_header)
return [html]
