最近在學習nginx,nginx rewrite依賴於PCRE庫,因此須要在linux系統中編譯安裝PCRE庫。具體步驟以下:linux
1.下載PCRE包nginx
首先去官網下載pcre的安裝包服務器
若是經過FTP的方式,下載地址爲:ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/學習
若是經過http的方式,下載地址爲:http://sourceforge.net/projects/pcre/files/pcre/測試
目前最新的版本爲8.32,linux對應的安裝包名稱爲:pcre-8.32.tar.gz。ui
2.把安裝包上傳到服務器,而後解壓spa
[root@localhost local]# tar -zxvf pcre-8.32.tar.gz code
解壓以後在當前目錄下生成了一個文件夾:pcre-8.32ip
drwxr-xr-x 7 1169 1169 4096 Nov 30 18:50 pcre-8.32
3.配置
[root@localhost pcre-8.32]# ./configure
配置完以後控制檯會打印出pcre配置的摘要信息
pcre-8.32 configuration summary:
Install prefix .................. : /usr/local
C preprocessor .................. : gcc -E
C compiler ...................... : gcc
C++ preprocessor ................ : g++ -E
C++ compiler .................... : g++
Linker .......................... : /usr/bin/ld
C preprocessor flags ............ :
C compiler flags ................ : -O2 -fvisibility=hidden
C++ compiler flags .............. : -O2 -fvisibility=hidden -fvisibility-inlines-hidden
Linker flags .................... :
Extra libraries ................. :
Build 8 bit pcre library ........ : yes
Build 16 bit pcre library ....... : no
Build 32 bit pcre library ....... : no
Build C++ library ............... : yes
Enable JIT compiling support .... : no
Enable UTF-8/16/32 support ...... : no
Unicode properties .............. : no
Newline char/sequence ........... : lf
\R matches only ANYCRLF ......... : no
EBCDIC coding ................... : no
EBCDIC code for NL .............. : n/a
Rebuild char tables ............. : no
Use stack recursion ............. : yes
POSIX mem threshold ............. : 10
Internal link size .............. : 2
Match limit ..................... : 10000000
Match limit recursion ........... : MATCH_LIMIT
Build shared libs ............... : yes
Build static libs ............... : yes
Use JIT in pcregrep ............. : no
Buffer size for pcregrep ........ : 20480
Link pcregrep with libz ......... : no
Link pcregrep with libbz2 ....... : no
Link pcretest with libedit ...... : no
Link pcretest with libreadline .. : no
Valgrind support ................ : no
Code coverage ................... : no
4.編譯
執行make操做:
[root@localhost pcre-8.32]# make
編譯完後能夠執行make check進行測試(這一步非必須)
Testing pcregrep version 8.32 2012-11-30
Testing pcregrep main features
Skipping pcregrep UTF-8 tests: no UTF-8 support in PCRE library
Testing pcregrep newline settings
PASS: RunGrepTest
==================
All 5 tests passed
==================
make[2]: Leaving directory `/usr/local/pcre-8.32'
make[1]: Leaving directory `/usr/local/pcre-8.32'
[root@localhost pcre-8.32]#
上面的make check結果中有一句:
Skipping pcregrep UTF-8 tests: no UTF-8 support in PCRE library
這是由於在前面步驟中執行./configuration配置時沒有加上對utf-8的支持
若是要加上對utf-8的支持能夠在./configuration時加上參數:
[root@localhost pcre-8.32]# ./configure --enable-utf8
配置完後再從新make
make完後再次執行make check結果以下:
Testing pcregrep version 8.32 2012-11-30
Testing pcregrep main features
Testing pcregrep UTF-8 features
Testing pcregrep newline settings
PASS: RunGrepTest
==================
All 5 tests passed
==================
make[2]: Leaving directory `/usr/local/pcre-8.32'
make[1]: Leaving directory `/usr/local/pcre-8.32'
[root@localhost pcre-8.32]#
5.安裝
執行make install操做:
[root@localhost pcre-8.32]# make install
make install結束後pcre編譯安裝流程就結束了。