pcre(pcre安装)

http://www.itjxue.com  2023-02-19 00:31  来源:未知  点击次数: 

安装 Nginx 前 必须安装 PCRE

Nginx是高度自由化的Web服务器,它的功能是由许多模块来支持。如果使用了某个模块,这个模块使用了一些类似zlib或OpenSSL等的第三方库,那么就必须先安装这些软件。Ubuntu下不像在centOS中使用yum直接在线安装,可以使用以下方法。

(1)PCRE库

PCRE库支持正则表达式。如果我们在配置文件nginx.conf中使用了正则表达式,那么在编译Nginx时就必须把PCRE库编译进Nginx,因为Nginx的HTTP模块需要靠它来解析正则表达式。另外,pcre-devel是使用PCRE做二次开发时所需要的开发库,包括头文件等,这也是编译Nginx所必须使用的。可以这样安装:

(2)zlib库

zlib库用于对HTTP包的内容做gzip格式的压缩,如果我们在nginx.conf中配置了gzip on,并指定对于某些类型(content-type)的HTTP响应使用gzip来进行压缩以减少网络传输量,则在编译时就必须把zlib编译进Nginx。zlib-devel是二次开发所需要的库。可以这样安装:

(3)OpenSSL库

如果服务器不只是要支持HTTP,还需要在更安全的SSL协议上传输HTTP,那么需要拥有OpenSSL。另外,如果我们想使用MD5、SHA1等散列函数,那么也需要安装它。可以这样安装:

网址:

最好在更新一下 openssl

但是升级了 openssl nginx 安装 --with-http_ssl_module 会报错 (所以我 为了开启 --with-http_ssl_module 没有升级 openssl 不升级也没什么关系 哈哈哈)

升级 openssl 教程:

怎么检查 linux是否安装 pcre

1、连接上相应的linux主机,进入到等待输入shell指令的linux命令行状态下。

2、在linux命令行下输入shell指令:rpm -qa pcre。

3、键盘按“回车键”运行shell指令,此时会看到pcre的版本,说明已安装,否则未安装。

Linux里面pcre库是什么?

是一个正则表达式库,里面提供了很多正则函数,但是使用的语法是perl5

The PCRE library is a set of functions that implement regular expression pattern matching using the same syntax and semantics as Perl 5.

如何在线安装pcre

PCRE的安装及使用  

 1、主页地址:www pcre org 下载pcre-8.13 tar bz2  

 2、解压缩: tar xjpf pcre-8.13 tar bz2

3、配置: cd pcre-8.13 ./configure --prefix=/usr/local/pcre-8.13 --libdir=/usr/local/lib/pcre --includedir=/usr/local/include/pcre configure有许多参数可配,具体参见./configure --help及手册  

 4、编译: make

5、安装: make install  

 6、将库文件导入cache: 方法1:在/etc/ld.so.conf中加入: /usr/local/lib/pcre,然后运行ldconfig 方法2:在/etc/ld.so.conf.d/下新生成一个文件(或在其中的文件中加入同样内容),文件内容为: /usr/local/lib/pcre,然后运行ldconfig

7、编译自带的demo程序 gcc -Wall pcredemo.c -I/usr/local/include/pcre -L/usr/local/lib/pcre -lpcre -o pcredemo

8、执行 ./pcredemo -g 'cat|dog' 'the dog sat on the cat' ./pcredemo 'cat|dog' 'the cat sat on the mat' 安装过程遇到的问题,在ubuntu 10.04下,如果直接./configure;make;make intall的话,默认安装的目录是/usr/local/,但是,即使用 gcc -Wall pcredemo.c -I/usr/local/include -L/usr/local/lib -lpcre -o pcredemo 编译,执行时会出现./pcredemo: error while loading shared libraries: libpcre.so.0: cannot open shared object file: No such file or directory 错误的原因是没用用ldconfig加载库文件到cache。只需按第6步将库文件加载到cache就行

(责任编辑:IT教学网)

更多

推荐网站策划文章