这是一个简单的Nginx模块的例子。
源码部分从
http://www.162cm.com/p/ngx_ext.html
得到。
原来的config文件有问题。
现在我刚刚在
nginx-0.7.65
nginx-0.8.34
编译通过
config文件
ngx_addon_name=ngx_http_hi_module
HTTP_MODULES="$HTTP_MODULES ngx_http_hi_module"
NGX_ADDON_SRCS="$NGX_ADDON_SRCS $ngx_addon_dir/ngx_http_hi_module.c"
nginx.conf配置
worker_processes 1;
daemon off;
master_process off;
error_log /tmp/error.log debug;
pid /tmp/nginx_demo.pid;
events {
worker_connections 1024;
}
http {
#include /etc/nginx/mime.types;
sendfile on;
keepalive_timeout 65;
tcp_nodelay on;
server {
listen 8100;
server_name localhost;
access_log /tmp/access.log;
error_log /tmp/error.log debug;
location /hello {
echo "测试";
}
}
}
-------------------------------------------------------------------------
1、解压缩Nginx源码
2、解压缩例子程序
3、./configure --add-module=/root/nginx-0.7.65/src/http/modules/nginx-hi
4、make
5、make install
6、覆盖 /usr/local/nginx/conf/nginx.conf
7、/usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf
8、浏览器看看。
第一个Nginx模块的例子
猜你喜欢
转载自openplatform-sohu-com.iteye.com/blog/628375
今日推荐
周排行