Source code installation of Nginx under CentOS 6.5

Write before:
It is recommended to have a general look first, and then install it according to the actual situation.

1. Download nginx source code

Download address of nginx source code: http://nginx.org/en/download.html

Select the version of the requirement, right-click the copy link, and then download it using the wget command

//My download directory is / usr/local/src/
//I am using the latest stable version nginx-1.12.2
[root@localhost src]# wget http://nginx.org/download/nginx-1.12.2.tar.gz

2. Decompress source code

tar -zxvf nginx-1.12.2.tar.gz

3. Configuration source code

[root@localhost src]# cd nginx-1.12.2
[root@localhost nginx-1.12.2]# ./configure

Here I have an error:

checking for OS
 + Linux 2.6.32-431.el6.x86_64 x86_64
checking for C compiler ... not found

./configure: error: C compiler cc is not found

Solution - > http://blog.csdn.net/xinyflove/article/details/79310996

Reconfigure

[root@localhost nginx-1.12.2]# ./configure

Another error occurred

./configure: error: the HTTP rewrite module requires the PCRE library.
You can either disable the module by using --without-http_rewrite_module
option, or install the PCRE library into the system, or build the PCRE library
statically from the source with nginx by using --with-pcre=<path> option.

Install PCRE devel to solve the problem (the function is to enable the rewrite function of ngnix)

yum -y install pcre-devel

Reconfigure

[root@localhost nginx-1.12.2]# ./configure

Another error occurred

./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.

Install zlib devel to solve the problem

yum -y install zlib-devel

Reconfigure

[root@localhost nginx-1.12.2]# ./configure

There is no error prompt this time. The configuration is successful.
Return to configuration overview:

Configuration summary //Configuration overview
  + using system PCRE library //Using the system PCRE Library
  + OpenSSL library is not used //Do not use OpenSSL Library
  + using system zlib library //Using the system zlib Library

  nginx path prefix: "/usr/local/nginx" //Installation directory
  nginx binary file: "/usr/local/nginx/sbin/nginx" //Binary
  nginx modules path: "/usr/local/nginx/modules" //Module directory
  nginx configuration prefix: "/usr/local/nginx/conf" //Profile directory
  nginx configuration file: "/usr/local/nginx/conf/nginx.conf" //configuration file
  nginx pid file: "/usr/local/nginx/logs/nginx.pid" //pid file
  nginx error log file: "/usr/local/nginx/logs/error.log" //Error log file
  nginx http access log file: "/usr/local/nginx/logs/access.log" //http permission log file
  nginx http client request body temporary files: "client_body_temp" //http client request principal temporary file
  nginx http proxy temporary files: "proxy_temp" //http proxy temporary file
  nginx http fastcgi temporary files: "fastcgi_temp" //http fastcgi temporary file
  nginx http uwsgi temporary files: "uwsgi_temp" //http uwsgi temporary file
  nginx http scgi temporary files: "scgi_temp" //http scgi temporary file

Tip:
If you need to install openssl(https support)

//Install openssl
yum -y install openssl openssl-devel
//Then configure it.
./configure

4. Make & & make install

[root@localhost nginx-1.12.2]# make
[root@localhost nginx-1.12.2]# make install

No error prompt, installation succeeded.

5. Start nginx

/usr/local/nginx/sbin/nginx

Other nginx commands

/usr/local/nginx/sbin/nginx -s reload
/usr/local/nginx/sbin/nginx -s stop

Tags: Nginx zlib OpenSSL yum

Posted on Wed, 01 Apr 2020 08:52:01 -0700 by niekos