hew*_*ewi 5 python apache mod-wsgi
所以我被建议使用wsgi而不是 cgi,所以我尝试使用以下设置来设置它作为一个基本示例,而不使用 Django:
眼镜:
问题:
我如何让这个函数吐出它的结果
这个 wsgi 脚本有什么用?我不需要这个,我也不想要任何 wsgi 扩展
真的迷失在这个 wsgi 想法中,一些澄清可能会有所帮助
所以让我们从我所知道和想要的开始,使用简约的方法:
最有用的信息源自 shellhacks.com和modwsgi.readthedocs.io
LoadModule wsgi_module 模块/mod_wsgi.so
$ sudo a2enmod wsgi
$ sudo 服务 apache2 重新启动
使用您最喜欢的文本编辑器(在本例中是 Kate)将以下“spark.py”脚本放入 apache 的文档根文件夹(对我来说是 root/var/www/html)
$ kate /var/www/html/spark.py
Run Code Online (Sandbox Code Playgroud)
Run Code Online (Sandbox Code Playgroud)def application(environ, start_response): status = '200 OK' output = b'Hello World!\n' response_headers = [('Content-type', 'text/plain'), ('Content-Length', str(len(output)))] start_response(status, response_headers) return [output]
将 WSGI 脚本别名指令添加到 etc/apache2/sites-available/000-default.conf
$ sudo kate etc/apache2/sites-available/000-default.conf
Run Code Online (Sandbox Code Playgroud)
Run Code Online (Sandbox Code Playgroud)<VirtualHost *:80> #lots and lots of comments some actual directives like DocumentRoot /var/www/html # more comments more directives # and all the way at the end # THE ACTUAL DIRECTIVE WSGIScriptAlias / /var/www/html/spark.py <Directory /usr/lib/python3.7> Require all granted </Directory> </VirtualHost>
要做的事情:创建应用程序,将脚本指向该应用程序,...
| 归档时间: |
|
| 查看次数: |
11794 次 |
| 最近记录: |