欢迎访问 生活随笔!

生活随笔

当前位置: 首页 >

pythonlinux加入自己写的模块_利用ngx_python模块嵌入到Python脚本

发布时间:2024/8/5 48 豆豆
生活随笔 收集整理的这篇文章主要介绍了 pythonlinux加入自己写的模块_利用ngx_python模块嵌入到Python脚本 小编觉得挺不错的,现在分享给大家,帮大家做个参考.

导读

Python是一种计算机程序设计语言。是一种动态的、面向对象的脚本语言,最初被设计用于编写自动化脚本(shell),随着版本的不断更新和语言新功能的添加,越来越多被用于独立的、大型项目的开发。

ngx_python 是为 nginx 嵌入 python 脚本的模块。

环境

- python 2.7.*

- nginx-1.6.3+

安装

git clone https://github.com/rryqszq4/ngx_python.git

wget 'http://nginx.org/download/nginx-1.6.3.tar.gz'

tar -zxvf nginx-1.6.3.tar.gz

cd nginx-1.6.3

export PYTHON_INC=/path/to/python/include/python2.7

export PYTHON_BIN=/path/to/python/bin

./configure --user=www --group=www \

--prefix=/path/to/nginx \

--add-module=/path/to/ngx_python

摘要

nginx

user www www;

worker_processes 4;

events {

worker_connections 1024;

}

http {

include mime.types;

default_type application/octet-stream;

keepalive_timeout 65;

server {

listen 80;

server_name localhost;

location /content_by_python {

content_by_python "

import ngx

ngx.echo('Hello, ngx_python')

";

}

}

}

}

总结

以上是生活随笔为你收集整理的pythonlinux加入自己写的模块_利用ngx_python模块嵌入到Python脚本的全部内容,希望文章能够帮你解决所遇到的问题。

如果觉得生活随笔网站内容还不错,欢迎将生活随笔推荐给好友。