天天看點

Nginx 編譯擴充pcre

一、nginx編譯安裝

1、下載下傳源碼包nginx-1.12.1,官網nginx.org

# wget http://nginx.org/download/nginx-1.12.1.tar.gz

2、解壓源碼包

#tar xf nginx-1.12.1.tar.gz

3、下載下傳以下擴充module,儲存到exp目錄

  3.1 module 位址

module name url
echo-nginx-module https://github.com/openresty/echo-nginx-module.git
lua-nginx-module https://github.com/openresty/lua-nginx-module.git
ngx_devel_kit https://github.com/simpl/ngx_devel_kit.git
set-misc-nginx-module https://github.com/openresty/set-misc-nginx-module.git
lua-upstream-nginx-module https://github.com/openresty/lua-upstream-nginx-module.git

3.2 建立module存放目錄

   # cd nginx-1.12.1 && mkdir exp && cd exp 

  3.3 下載下傳moudle

  # git clone https://github.com/openresty/echo-nginx-module.git

  # git clone https://github.com/openresty/lua-nginx-module.git

  # git clone https://github.com/simpl/ngx_devel_kit.git

  # git clone https://github.com/openresty/set-misc-nginx-module.git

  # git clone https://github.com/openresty/lua-upstream-nginx-module.git

4、下載下傳openssl、pcre(pcre 7.9以下版本不支援UTF8,如果用到UTF8,需要下載下傳7.9以上的版本)

4.1 擴充連結

擴充名
openssl https://www.openssl.org/source/old/1.0.2/openssl-1.0.2j.tar.gz
pcre https://sourceforge.net/projects/pcre/files/pcre/8.39/pcre-8.39.tar.bz2

4.2 下載下傳

#wget https://sourceforge.net/projects/pcre/files/pcre/8.39/pcre-8.39.tar.bz2

#wget https://www.openssl.org/source/old/1.0.2/openssl-1.0.2j.tar.gz

4.3 解壓到/usr/local

# tar xf  pcre-8.39.tar.bz2  -C /usr/local/

#tar xf openssl-1.0.2j.tar.gz -C /usr/local/

5、編譯,注意紅色标記資訊,openssl、pcre指定的是源碼目錄,而不是編譯安裝完成後的目錄

# export LUAJIT_LIB=/usr/local/luajit/lib&&export LUAJIT_INC=/usr/local/luajit/include/luajit-2.1&&./configure --prefix=/usr/local/nginx-1.12.1 --with-http_sub_module  --with-http_stub_status_module --with-http_ssl_module --with-http_gzip_static_module --with-http_realip_module --add-module=exp/echo-nginx-module/ --add-module=exp/lua-nginx-module/ --add-module=exp/ngx_devel_kit/ --add-module=exp/set-misc-nginx-module/ --add-module=exp/lua-upstream-nginx-module --with-openssl=/usr/local/openssl-1.0.2j/ --with-http_v2_module --with-cc-opt='-O2' --with-pcre=/usr/local/pcre-8.39/ --with-http_flv_module --with-http_mp4_module --with-threads --with-file-aio --add-module=exp/nginx-ct/ --with-pcre-jit

6、此時不能離開進行make,如果立刻進行make,make install之後,會導緻nginx不能支援UTF8重寫,原因是pcre沒有啟用UTF8,是以要在此處修改pcre,啟用UTF8;configure之後,會在目前目錄生成一個新目錄obj,obj目錄下有一個Makefile檔案,儲存第三方子產品資訊,需要修改此檔案,在pcre處添加--enable-utf8 --enable-unicode-properties 這兩個選項

修改前:obj/Makefile

Nginx 編譯擴充pcre

修改後:obj/Makefile

Nginx 編譯擴充pcre

7、編譯

#make

8、安裝

#make install

二、編譯安裝pcre

1、切換到pcre源代碼目錄

 #cd  /usr/local/pcre-8.39/

2、編譯

#./configure  --enable-utf8 --enable-unicode-properties

3、編譯

4、安裝

繼續閱讀