Python Apache 連携

投稿者:

# dnf install httpd-devel
# dnf -y install python3-mod_wsgi
# pip install mod-wsgi
# pip install mod-wsgi-httpd
# vi /etc/httpd/conf/httpd.conf
AddHandler wsgi-script .py
AddHandler wsgi-script .wsgi
実行ディレクトリは
Options +ExecCGI にしておくこと
# systemctl restart httpd.service
こんなのをアップして確認
test.py

Thank you for reading this post, don't forget to subscribe!
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' \
           'WSGI テストページ\n' \
           '</div>\n' \
           '</body>\n' \
           '</html>\n'.encode("utf-8")
    response_header = [('Content-type','text/html')]
    start_response(status,response_header)
    return [html]