Nginx compilation and installation

System platform: CentOS 7.4
Nginx version: nginx-1.12.2.tar.gz
PCRE version: pcre-8.42.tar.gz
Required dependency: gcc-c + + libtool
Three party Library: zlib zlib devel OpenSSL OpenSSL devel PCRE

I. installation and compilation tools and library files

> yum install -y make zlib zlib-devel openssl openssl-devel gcc-c++
> libtool

Zlib Library: zlib library is required by NGX ﹣ http ﹣ gzip ﹣ module (gzip compression module)
OpenSSL Library: — with HTTP ﹣ SSL ﹣ module: OpenSSL library must be installed to support HTTPS protocol

II. Install PCRE Library
PRCE Library: – with HTTP Rewrite Module the module must be installed with the prce library to support address redirection, address rewrite function, localization instruction and regular expression

[[email protected] src]# tar xf pcre-8.42.tar.gz
[[email protected] src]# cd pcre-8.42
[[email protected] pcre-8.42]# ./configure && make && make install && echo $?
[[email protected] pcre-8.42]# pcre-config --version


III. installation of nginx

[[email protected] /]# useradd -s /sbin/nolgoin nginx
[[email protected] src]# tar xf nginx-1.12.2.tar.gz
[[email protected] nginx-1.12.2]#./configure --prefix=/usr/local/nginx --with-http_stub_status_module --with-http_ssl_module --with-pcre=/usr/local/src/pcre-8.42 --user=nginx --group=nginx
[[email protected] nginx-1.12.2]# make && make install
[root @ linux-node1 /]? / usr / local / nginx / SBIN / nginx - V view version and compiled modules

[root @ linux-node1 /]; / usr / local / nginx / SBIN / nginx - t check whether the nginx.conf file is configured correctly
nginx: the configuration file /usr/local/nginx/conf/nginx.conf syntax is ok
nginx: configuration file /usr/local/nginx/conf/nginx.conf test is successful



IV. start nginx

[root @ linux-node1 /]; / usr / local / nginx / SBIN / nginx start nginx
/Usr / local / nginx / SBIN / nginx - s reload reload configuration file
/Usr / local / nginx / SBIN / nginx - s reopen restart nginx
/Usr / local / nginx / SBIN / nginx - s stop quick close nginx
/Usr / local / nginx / SBIN / nginx - s quit close nginx

[[email protected] /]# systemctl stop iptables.service
[[email protected] /]# systemctl stop firewalld.service