Linux系统下安装PCRE及配置共享库教程
PCRE是一个用C语言编写的正则表达式函数库,比较轻量级,PCRE十分易用,同时功能也很强大,本文我们来看看在Linux如何安装PCRE及及配置共享库.
PCRE(Perl Compatible Regular Expressions)是一个轻量级的Perl函数库,包括 perl 兼容的正则表达式库,它比Boost之类的正则表达式库小得多,PCRE十分易用,同时功能也很强大,性能超过了POSIX正则表达式库和一些经典的正则表达式库.
安装PCRE:
1.PCRE目前最新版本为8.36,可以点这里进行下载.
2.使用tar -zxvf pcre-8.36.tar.gz进行解压.
3.运行 chmod -R 777 /pcre-8.36 对当前文件夹授予全部读写权限.
4.切换到/pcre-8.36目录下,运行 ./configure 进行pcre初始化配置,会在控制台打印出一大堆的输出信息.
5.执行make操作,进行编译.
- [root@server06 pcre-8.36]# make
- rm -f pcre_chartables.c
- ln -s ./pcre_chartables.c.dist pcre_chartables.c
- make all-am
- make[1]: Entering directory `/opt/nginx/pcre-8.36'
- CC libpcre_la-pcre_byte_order.lo
- CC libpcre_la-pcre_compile.lo
- CC libpcre_la-pcre_config.lo
- CC libpcre_la-pcre_dfa_exec.lo
- CC libpcre_la-pcre_exec.lo
- CC libpcre_la-pcre_fullinfo.lo
- CC libpcre_la-pcre_get.lo
- CC libpcre_la-pcre_globals.lo
- CC libpcre_la-pcre_jit_compile.lo
- CC libpcre_la-pcre_maketables.lo
- CC libpcre_la-pcre_newline.lo
- CC libpcre_la-pcre_ord2utf8.lo
- CC libpcre_la-pcre_refcount.lo
- CC libpcre_la-pcre_string_utils.lo
- CC libpcre_la-pcre_study.lo
- CC libpcre_la-pcre_tables.lo
- CC libpcre_la-pcre_ucd.lo
- CC libpcre_la-pcre_valid_utf8.lo
- CC libpcre_la-pcre_version.lo
- CC libpcre_la-pcre_xclass.lo
- CC libpcre_la-pcre_chartables.lo
- CCLD libpcre.la
- CC libpcreposix_la-pcreposix.lo
- CCLD libpcreposix.la
- CXX libpcrecpp_la-pcrecpp.lo
- CXX libpcrecpp_la-pcre_scanner.lo
- CXX libpcrecpp_la-pcre_stringpiece.lo
- CXXLD libpcrecpp.la
- CC pcretest-pcretest.o
- CC pcretest-pcre_printint.o
- CCLD pcretest //phpfensi.com
- CC pcregrep-pcregrep.o
- CCLD pcregrep
- CXX pcrecpp_unittest-pcrecpp_unittest.o
- CXXLD pcrecpp_unittest
- CXX pcre_scanner_unittest-pcre_scanner_unittest.o
- CXXLD pcre_scanner_unittest
- CXX pcre_stringpiece_unittest-pcre_stringpiece_unittest.o
- CXXLD pcre_stringpiece_unittest
- make[1]: Leaving directory `/opt/nginx/pcre-8.36'
6.运行 [root@server06 pcre-8.36]# make install,进行安装,至此PCRE安装完成.
[root@server06 pcre-8.36]# make install
PCRE配置共享库.
问题信息:./nginx:error while loading shared libraries:libpcre.so.1: cannot open shared object file: No such file or directory
问题原因:没有安装PCRE库,或安装了PCRE库而没有配置PCRE共享库.
解决方案:配置PCRE共享库.
1.查找pcre库的位置.
- [root@server06 ~]# cd /lib
- [root@server06 lib]# find / -type f -name *libpcre.so.*
- /lib64/libpcre.so.0.0.1
- /usr/local/lib/libpcre.so.1.2.4
- /opt/nginx/pcre-8.36/.libs/libpcre.so.1.2.4
2.将PCRE库进行软连接.
RedHat 64位机器读取的pcre文件为/lib64/libpcre.so.0.0.1文件.
- [root@server06 ~]# ln -s /usr/local/lib/libpcre.so.1 /lib64/
- [root@server06 ~]# cd /usr/local/nginx/sbin/
- [root@server06 sbin]# ./nginx
如32位机器操作方式类型,可能软连接的地址为:
ln -s /lib/libpcre.so.0.0.1 /lib/libpcre.so.1。