一、有的服務器上沒有安裝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=./,然后把這幾個文件放到同一個目錄,就可以執行了。