CentOS7.4纯净版系统编译安装nginx

cd /www
wget http://nginx.org/download/nginx-1.9.6.tar.gz

           tar -zxvf   nginx-1.9.6.tar.gz

           cd nginx-1.9.6

          ./configure

 

出现报错   the HTTP rewrite module requires the PCRE library

原因是没有安装 PCRE库 

ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/  下载

安装 PCRE库

wget   ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre2-10.32.tar.gz

tar -zxvf   pcre2-10.32.tar.gz

cd pcre2-10.32

./configure

make

make install

继续安装nginx  

cd /www/nginx-1.9.6

./configure –with-pcre=/www/pcre2-10.32

出现报错 error: the HTTP gzip module requires the zlib library.

需要安装zlib

wget  http://zlib.net/zlib-1.2.11.tar.gz

cd  zlib-1.2.11

./configure

make

make install

 

继续安装   ./configure –with-pcre=/www/pcre2-10.32 –with-zlib=/www/zlib-1.2.11

提示no openssl

安装openssl

yum -y install openssl openssl-devel


继续安装 ./configure --with-pcre=/www/pcre2-10.32 --with-zlib=/www/zlib-1.2.11

出现报错
&& make libpcre.la
make[2]: Entering directory `/www/pcre2-10.32'
make[2]: *** No rule to make target `libpcre.la'. Stop.
make[2]: Leaving directory `/www/pcre2-10.32'

分析来看可能是pcre问题

rpm -qa | grep pcre 查看系统已有pcre包

pcre-8.32-17.el7.x86_64
pcre-devel-8.32-17.el7.x86_64

 

./configure –with-zlib=/www/zlib-1.2.11 –with-http_ssl_module –prefix=/www/nginx –conf-path=/www/nginx/conf/nginx.conf

make

make  install 

 

成功!

 

 

 

总结

 

nginx需要安装的包可以使用yum安装更快捷并且不会出现版本问题:

yum -y install gcc

yum -y install openssl openssl-devel

yum -y install zlib zlib-devel

yum -y install pcre pcre-devel

./configure 时可以指定参数比如–prefix=/www/nginx  –conf-path=/www/nginx/conf/nginx.conf

 

rpm包

rpm -qa | grep  查看安装的包

rpm -e  卸载包

如果有依赖 卸载使用  rpm -e –nodeps 

 

 

Ubuntu安装包命令apt-get install   比如:

apt-get install gcc

 

 

 

 

 

 

 

 

 

 

About sun 83 Articles
85后青年,自诩为伪文艺青年

Be the first to comment

Leave a Reply

Your email address will not be published.


*