nginx安装pcre

一、有的服务器上没有安装pcre那么安装nginx的时候会报错

所以在安装之前我们可以:

yum install pcre-devel

如果很不巧,服务器也没有配yum,也不能连互联网。那么我们只能自己去官网下载了

ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-8.36.zip

二、安装pcre

unzip pcre-8.36.zip
cd pcre-8.36
./configure --prefix=/usr/local/pcre --enable-utf8 --enable-unicode-properties
make
make install

三、安装nginx

(当然前提是获取安装包:http://nginx.org/download/nginx-1.8.0.tar.gz)

tar -zxvf nginx-1.8.0.tar.gz
cd nginx-1.8.0
./configure --prefix=./ --with-pcre=../pcre-8.36  
make

tips:--with-pcre=../pcre-8.36  //这个路径就是你刚才解压pcre源码的路径。

在"./configure --prefix=./ --with-pcre=../pcre-8.36 "之后可以找到如下部分修改,让nginx支持utf-8

1093 ../pcre-8.36/Makefile:  objs/Makefile
1094         cd ../pcre-8.36 
1095         && if [ -f Makefile ]; then $(MAKE) distclean; fi 
1096         && CC="$(CC)" CFLAGS="-O2 -fomit-frame-pointer -pipe " 
1097         ./configure --disable-shared --enable-utf8 --enable-unicode-properties 

四、提取nginx可执行部分

./objs/nginx -->nginx/sbin
./conf/* -->nginx/conf
./html/* --->nginx/html
mkdir log --->nginx/log

tips:其实nginx执行只需要执行文件,日志目录和错误页的html就行了。只要在编译的时候--prefix=./,然后把这几个文件放到同一个目录,就可以执行了。

原文地址:https://www.cnblogs.com/bugutian/p/4523178.html