CentOS 7.4 source installation nginx 1.14

  • Operating system: CentOS 7.4
  • Nginx version: nginx-1.14.1

The current Stable version is nginx-1.14.1 Reference resources

Different from JRE and Tomcat, nginx is not only decompressed, but also compiled and installed. The specific steps are as follows:

I. preparation environment

If the environment preparation is not complete, it will be executed later. / configure corresponding error will be reported. I tried it, for example, if the 3. zlib library is missing, the error will be reported

./configure: error: the HTTP gzip module requires the zlib library.
You can either disable the module by using --without-http_gzip_module
option, or install the zlib library into the system, or build the zlib library
statically from the source with nginx by using --with-zlib=<path> option.
  1. gcc (GNU compiler suite)

     [root[@xxxxxxxx](https://my.oschina.net/u/1036001) ~]# rpm -q gcc
     gcc-4.8.5-16.el7.x86_64
    

    If no output, install

     [root[@xxxxxxxx](https://my.oschina.net/u/1036001) ~]# yum install -y gcc
    
  2. PCRE(Perl Compatible Regular Expressions) Perl Library

     [root[@xxxxxxxx](https://my.oschina.net/u/1036001) ~]# rpm -qa |grep pcre
     pcre-8.32-17.el7.x86_64
     pcre-devel-8.32-17.el7.x86_64
    

    If there is no corresponding installation, such as pcre-devel-8.32-17.el7.x86_, execute

     [root[@xxxxxxxx](https://my.oschina.net/u/1036001) ~]# yum install -y pcre-devel
    

    If both are missing, execute

     [root[@xxxxxxxx](https://my.oschina.net/u/1036001) ~]# yum install -y pcre pcre-devel
    

    And so on

  3. zlib Library

     [root@xxxxxxxx ~]# rpm -qa |grep zlib
     zlib-devel-1.2.7-17.el7.x86_64
     zlib-1.2.7-17.el7.x86_64
    

    Which installation is missing

     [root@xxxxxxxx ~]# yum install -y zlib zlib-devel
    
  4. openssl

     [root@xxxxxxxx ~]# rpm -qa |grep openssl
     openssl-libs-1.0.2k-12.el7.x86_64
     openssl-devel-1.0.2k-12.el7.x86_64
     openssl-1.0.2k-12.el7.x86_64
    

    Which installation is missing

     [root@xxxxxxxx ~]# yum install -y openssl openssl-devel 
    

II. Decompression and installation

  1. decompression

    In the directory where nginx-1.14.1.tar.gz is located, execute the unzip command. The unzip directory is different from the installation directory. Do not mind the unzip location

     [root@xxxxxxxx ~]# tar -zxvf nginx-1.14.1.tar.gz
    
  2. . / configure generate Makefile

     [root@xxxxxxxx ~]# ./configure --prefix=/usr/local/nginx
     checking for OS
      + Linux 3.10.0-693.2.2.el7.x86_64 x86_64
     checking for C compiler ... found
      + using GNU C compiler
      + gcc version: 4.8.5 20150623 (Red Hat 4.8.5-16) (GCC) 
     checking for gcc -pipe switch ... found
     checking for -Wl,-E switch ... found		Configuration summary
     ----------------
     //More than 100 checking for
     ----------------
     checking for PCRE JIT support ... found
     checking for zlib library ... found
     creating objs/Makefile
    
     Configuration summary
       + using system PCRE library
       + OpenSSL library is not used
       + using system zlib library
    
       nginx path prefix: "/usr/local/nginx"
       nginx binary file: "/usr/local/nginx/sbin/nginx"
       nginx modules path: "/usr/local/nginx/modules"
       nginx configuration prefix: "/usr/local/nginx/conf"
       nginx configuration file: "/usr/local/nginx/conf/nginx.conf"
       nginx pid file: "/usr/local/nginx/logs/nginx.pid"
       nginx error log file: "/usr/local/nginx/logs/error.log"
       nginx http access log file: "/usr/local/nginx/logs/access.log"
       nginx http client request body temporary files: "client_body_temp"
       nginx http proxy temporary files: "proxy_temp"
       nginx http fastcgi temporary files: "fastcgi_temp"
       nginx http uwsgi temporary files: "uwsgi_temp"
       nginx http scgi temporary files: "scgi_temp"
    

    If. / configure: error: to check and solve the corresponding reason, execute. / configure --prefix=/usr/local/nginx again

  3. make && make install

     [root@xxxxxxxx nginx-1.14.1]# make && make install
    

    After the installation, you can see the directory / usr/local/nginx, execute the startup of / usr/local/nginx/sbin/nginx, and you can access it.

     [root@xxxxxxxx nginx]# /usr/local/nginx/sbin/nginx
    

The following configuration will be introduced in the next blog

Keywords: Programming Nginx zlib OpenSSL yum

Added by La Parka on Mon, 09 Dec 2019 19:47:30 +0200