WSGI (Web Server Gateway Interface) — стандарт взаимодействия между Python-программой, выполняющейся на стороне сервера, и самим веб-сервером, например Apache.

1. Установка mod_wsgi

    [[email protected] ~]# yum -y install mod_wsgi

2. Кофигурируем mod_wsgi для доступа /user_wsgi в  backend /var/www/html/user_wsgi.py.

   [[email protected] ~]# vi /etc/httpd/conf.d/wsgi.conf

WSGIScriptAlias /test_wsgi /var/www/html/user_wsgi.py

3. Создаем тестовый скрипт

   [[email protected] ~]# 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]

4. Отрываем сайт для проверки

Теги: