编译安装nginx 1.9与nginx-clojure

nginx-clojure的官方发行版(0.3.0)有proxy_cache_path bug, 于是只好自己动手下载源码安装。本文简要地介绍如何在Centos上编译安装。

本文假设JDK路径为/usr/lib/jvm/jdk8, nginx安装目标路径为/opt/apps/nginx。

安装编译工具

yum install mercurial 
yum install gcc gcc-c++ autoconf automake make

下载nginx与nginx-clojure最新源码

hg clone http://hg.nginx.org/nginx  
git clone --depth=1 https://github.com/nginx-clojure/nginx-clojure

配置nginx-clojureJDK路径

cd nginx-clojure; vi src/c/config

将文件中的JNI_HEADER_1指向相应JDK的路径,如下

JNI_HEADER_1="/usr/lib/jvm/jdk8/include"

JNI_HEADER_2="${JNI_HEADER_1}/linux"

获取zlib包,并解压

cd .. wget http://zlib.net/zlib-1.2.8.tar.gz tar -xzvf zlib-1.2.8.tar.gz


开始配置并编译nginx,

cd ../nginx ; 
ln -s auto/configure ./ 
./configure  --prefix=/opt/apps/nginx --sbin-path=nginx --conf-path=conf/nginx.conf --error-log-path=logs/error.log --http-log-path=logs/access.log --pid-path=logs/nginx.pid --lock-path=logs/nginx.lock --http-client-body-temp-path=temp/client_temp --http-proxy-temp-path=temp/proxy_temp --http-fastcgi-temp-path=temp/fastcgi_temp --http-uwsgi-temp-path=temp/uwsgi_temp --http-scgi-temp-path=temp/scgi_temp --with-http_ssl_module --with-pcre-jit --with-debug --with-http_image_filter_module --with-http_realip_module --with-http_addition_module --with-http_sub_module --with-http_dav_module --with-http_flv_module --with-http_mp4_module --with-http_gunzip_module --with-http_gzip_static_module --with-http_random_index_module --with-http_secure_link_module --with-http_stub_status_module --with-mail --with-mail_ssl_module --with-file-aio --with-ipv6 --with-openssl-opt=enable-tlsext --with-pcre --with-zlib=../zlib-1.2.8 --with-cc-opt='-O2 -pipe -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m64 -mtune=generic' --add-module=../nginx-clojure/src/c

这里可能需要安装gd-devel, (debian上是libgd2-xpm-dev

yum install gd-devel

如果没有报错,则make, make install完成安装。

打包nginx-clojure

cd ../nginx-clojure
lein jar
cp target/nginx-clojure-0.4.0.jar /opt/apps/nginx/jars/

下面是抄袭官方配置修改/opt/apps/nginx/conf/nginx.conf,也就是在http块中添加如下配置(注意路径替换成在你的系统中的相应路径):

jvm_path "/usr/lib/jvm/jdk8/jre/lib/amd64/server/libjvm.so";


### 配置clojure的jar包与第三方的jar包路径。下面的 ng-routes-0.1.0-SNAPSHOT-standalone.jar为第三方包。
jvm_var my_other_jars '/home/myname/.m2/repository/org/clojure/clojure/1.6.0/clojure-1.6.0.jar';

jvm_var ng_routes_jars '/opt/apps/nginx/jars/ng-routes-0.1.0-SNAPSHOT-standalone.jar';

###jvm_options can be repeated once per option.

jvm_options "-Djava.class.path=jars/nginx-clojure-0.4.0.jar:#{my_other_jars}:#{ng_routes_jars}";

###jvm heap memory

# jvm_options "-Xms1024m";

# jvm_options "-Xmx1024m";



#for enable java remote debug uncomment next two lines

#jvm_options "-Xdebug";

#jvm_options "-Xrunjdwp:server=y,transport=dt_socket,address=840#{pno},suspend=n";



###threads number for request handler thread pool on jvm, default is 0.

###check more details from

#jvm_workers 8;







转载于:https://my.oschina.net/u/1772293/blog/418829

你可能感兴趣的:(编译安装nginx 1.9与nginx-clojure)