1.编译apache的mod_wsgi 4.X扩展参考 参考 https://modwsgi.readthedocs.io/en/develop/user-guides/quick-installation-guide.html

安装mod_wsgi的时候需要指定python的执行文件路径。这样apache启动的时候就会启动指定版本的mod_wsgi、以及指定的python

版本。

2.windows环境部署参考https://blog.csdn.net/zhangtao0417/article/details/81564444

3.python应用对应的apache虚拟主机配置参考:

<VirtualHost *:80>

    ServerName test.com
    ServerAdmin webmaster@example.com

    DocumentRoot /var/www/html/test_wsgi_doc

    <Directory /var/www/html/test_wsgi_doc>
    <IfVersion < 2.4>
        Order allow,deny
        Allow from all
    </IfVersion>
    <IfVersion >= 2.4>
        Require all granted
    </IfVersion>
    </Directory>

    WSGIDaemonProcess test.com processes=2 threads=15 display-name=%{GROUP}
    WSGIProcessGroup test.com
    LogLevel info

    #WSGIScriptAlias / /var/www/html/test_wsgi/myapp.wsgi
    WSGIScriptAlias / /var/www/html/doc_app/my_application.wsgi

    #<Directory /var/www/html/test_wsgi>
    <Directory /var/www/html/doc_app>
    <IfVersion < 2.4>
        Order allow,deny
        Allow from all
    </IfVersion>
    <IfVersion >= 2.4>
        Require all granted
    </IfVersion>
    </Directory>

</VirtualHost>

 

其中my_application.wsgi的写法参考如下:

import sys
sys.path.insert(0, '/var/www/html/应用路径')

#第一个app是app.py, 这个文件里面引入了flask的一个对象app
from app import app as application 

4.mod_wsgi 快速上手参考https://modwsgi.readthedocs.io/en/develop/user-guides/quick-configuration-guide.html

 

Logo

CSDN联合极客时间,共同打造面向开发者的精品内容学习社区,助力成长!

更多推荐