匿名
未登录
登录
Linux78|wiki
搜索
查看“Nginx 编译第三方模块”的源代码
来自Linux78|wiki
名字空间
页面
讨论
更多
更多
页面选项
查看
查看源代码
历史
←
Nginx 编译第三方模块
因为以下原因,您没有权限编辑本页:
您所请求的操作仅限于该用户组的用户使用:
wiki:用户|用户
您可以查看与复制此页面的源代码。
nginx是分成一个个模块的,比如core模块,gzip模块(ngx_http_gzip_static_module),proxy模块(ngx_http_proxy_module),每个模块负责不同的功能,例如ngx_http_gzip_static_module负责压缩,ngx_http_proxy_module负责反向代理的请求,除了基本的模块,有些模块可以选择编译或不编译进nginx。官网文档中的Modules reference部分列出了nginx源码包的所有模块。我们可以按照自己的需要定制出一个最适合自己的nginx服务器。假如需要gzip模块,那在编译的时候,可以这样指定。 ./configure --with-http_gzip_static_module 假如不需要fastcgi这个模块,可以这样: ./configure —without-http_fastcgi_module 安装 除了源码包提供了各种模块,nginx还有各种各样的第三方模块。官方文档NGINX 3rd Party Modules列出了nginx的很多第三方模块,除此之外,很多很有用的模块也能在github等网站上找到。 这些模块提供着各种各样意想不到的功能,有时候我们在语言层面办不好或不好办的事,交给nginx的第三方模块,可能会有惊喜。 我们以这个模块nginx-module-vts作为例子,来演示一下如果来安装第三方模块和简单的使用。 先把模块的源码下载下来。 git clone git://github.com/vozlt/nginx-module-vts.git 配置各种参数,最主要是—add-module那一行。 ./configure \ --user=nginx \ --group=nginx \ --prefix=/etc/nginx \ --sbin-path=/usr/sbin/nginx \ --conf-path=/etc/nginx/nginx.conf \ --pid-path=/var/run/nginx.pid \ --lock-path=/var/run/nginx.lock \ --error-log-path=/var/log/nginx/error.log \ --http-log-path=/var/log/nginx/access.log \ --with-http_gzip_static_module \ --with-http_stub_status_module \ --with-http_ssl_module \ --with-pcre \ --with-file-aio \ --with-http_realip_module \ --without-http_scgi_module \ --without-http_uwsgi_module \ --without-http_fastcgi_module \ --add-module=/home/yinsigan/nginx-module-vts —add-module是接刚才下载的模块的绝对路径。 编译安装。 make sudo make install 升级可执行文件nginx和重启服务 sudo make upgrade 要检测是否成功安装的话,使用nginx -V命令即可。 $ nginx -V nginx version: nginx/1.8.0 built by gcc 4.8.2 (Ubuntu 4.8.2-19ubuntu1) built with OpenSSL 1.0.1f 6 Jan 2014 TLS SNI support enabled configure arguments: --user=nginx --group=nginx --prefix=/etc/nginx --sbin-path=/usr/sbin/nginx --conf-path=/etc/nginx/nginx.conf --pid-path=/var/run/nginx.pid --lock-path=/var/run/nginx.lock --error-log-path=/var/log/nginx/error.log --http-log-path=/var/log/nginx/access.log --with -http_gzip_static_module --with-http_stub_status_module --with-http_ssl_module --with-pcre --with-file-aio --with-http_realip_module --without -http_scgi_module --without-http_uwsgi_module --without-http_fastcgi_module --add-module=/home/yinsigan/codes/nginx-module-vts --add-module=/home/yinsigan/codes/nginx-module-url 出现了nginx-module-vts,说明安装成功了。 这是添加一种module的情况,假如需要添加很多个module呢,那就再增加一个—add-module就好了。 使用 语法很简单,分别在http和server部分添加几行指令。 http { vhost_traffic_status_zone; ... server { ... location /status { vhost_traffic_status_display; vhost_traffic_status_display_format html; } } } [[category:Nginx]]
返回至
Nginx 编译第三方模块
。
导航
导航
首页
最近更改
随机页面
栏目
Nginx
Kubernetes
Spring Cloud
Wiki工具
Wiki工具
特殊页面
页面工具
页面工具
用户页面工具
更多
链入页面
相关更改
页面信息
页面日志