1、先看看你要安装的模块是否已经存在了
$ /opt/openresty/nginx/sbin/nginx -V (V大写) 结果如下: nginx version: openresty/1.7.10.2 built by gcc 4.4.7 20120313 (Red Hat 4.4.7-16) (GCC) TLS SNI support enabled configure arguments: --prefix=/opt/openresty/nginx --with-cc-opt=-O2 --add-module=../ngx_devel_kit-0.2.19 --add-module=../echo-nginx-module-0.58 --add-module=../xss-nginx-module-0.05 --add-module=../ngx_coolkit-0.2rc3 --add-module=../set-misc-nginx-module-0.29 --add-module=../form-input-nginx-module-0.11 --add-module=../encrypted-session-nginx-module-0.04 --add-module=../srcache-nginx-module-0.30 --add-module=../ngx_lua-0.9.16 --add-module=../ngx_lua_upstream-0.03 --add-module=../headers-more-nginx-module-0.26 --add-module=../array-var-nginx-module-0.04 --add-module=../memc-nginx-module-0.16 --add-module=../redis2-nginx-module-0.12 --add-module=../redis-nginx-module-0.3.7 --add-module=../rds-json-nginx-module-0.14 --add-module=../rds-csv-nginx-module-0.06 --with-ld-opt=-Wl,-rpath,/opt/openresty/luajit/lib --user=nginx --group=nginx --with-http_gzip_static_module --with-http_stub_status_module --with-http_ssl_module
我想安装nginx_concat_module模块,SVN 下载到指定的目录 /usr/local/src/nginx_module
svn checkout http://code.taobao.org/svn/nginx_concat_module/trunk/ $NGINX_CONCAT_MODULE
先进入openresty的源码文件夹下
$ cd /usr/local/src/ngx_openresty-1.7.10.2
添加模块,--add-module=路径
./configure --prefix=/opt/openresty --with-http_gzip_static_module --with-http_stub_status_module --with-http_ssl_module --add-module=/usr/local/src/nginx_module/nginx_concat_module
结果:执行过程省略了
Configuration summary + using system PCRE library + using system OpenSSL library + md5: using OpenSSL library + sha1: using OpenSSL library + using system zlib library
nginx path prefix: "/opt/openresty/nginx" nginx binary file: "/opt/openresty/nginx/sbin/nginx" nginx configuration prefix: "/opt/openresty/nginx/conf" nginx configuration file: "/opt/openresty/nginx/conf/nginx.conf" nginx pid file: "/opt/openresty/nginx/logs/nginx.pid" nginx error log file: "/opt/openresty/nginx/logs/error.log" nginx http access log file: "/opt/openresty/nginx/logs/access.log" nginx http client request body temporary files: "client_body_temp" nginx http proxy temporary files: "proxy_temp" nginx http fastcgi temporary files: "fastcgi_temp" nginx http uwsgi temporary files: "uwsgi_temp" nginx http scgi temporary files: "scgi_temp"
cd ../.. Type the following commands to build and install: gmake gmake install
好了,编译执行完成了,接下来执行make操作(如果是新安装则执行make install):
$ make
如果执行没有报错则进入objs文件夹中
$ cd /usr/local/src/ngx_openresty-1.7.10.2/build/nginx-1.7.10/objs
通过命令可以看到 nginx文件,它是刚刚重新生成的,如果在make之前看过这里就知道这个文件刚刚没有,再尝试用 -V命令看看其配置如何:
./nginx -V
configure arguments: --prefix=/opt/openresty/nginx --with-cc-opt=-O2 --add-module=../ngx_devel_kit-0.2.19 --add-module=../echo-nginx-module-0.58 --add-module=../xss-nginx-module-0.05 --add-module=../ngx_coolkit-0.2rc3 --add-module=../set-misc-nginx-module-0.29 --add-module=../form-input-nginx-module-0.11 --add-module=../encrypted-session-nginx-module-0.04 --add-module=../srcache-nginx-module-0.30 --add-module=../ngx_lua-0.9.16 --add-module=../ngx_lua_upstream-0.03 --add-module=../headers-more-nginx-module-0.26 --add-module=../array-var-nginx-module-0.04 --add-module=../memc-nginx-module-0.16 --add-module=../redis2-nginx-module-0.12 --add-module=../redis-nginx-module-0.3.7 --add-module=../rds-json-nginx-module-0.14 --add-module=../rds-csv-nginx-module-0.06 --with-ld-opt=-Wl,-rpath,/opt/openresty/luajit/lib --user=nginx --group=nginx --with-http_gzip_static_module --with-http_stub_status_module --with-http_ssl_module
将生成的新nginx文件复制到你的安装目录
cp /usr/local/src/ngx_openresty-1.7.10.2/build/nginx-1.7.10/objs/nginx ./openresty/nginx/sbin/