Complete steps of source code installation of Nginx on centos7 platform

Keywords: Programming Nginx OpenSSL zlib ftp

1. install make

yum install gcc automake autoconf libtool make

2. install gcc

yum install gcc gcc-c++

3. Install pcre Library

Download address: https://pan.baidu.com/s/13Kojg2Xcnp06qiw023uHoQ

Upload the downloaded pcre-8.35.tar.gz through ftp to the directory / usr/local/src of centos7.

cd /usr/local/src
# New pcre directory
mkdir /usr/local/pcre
# Decompress pcre-8.35.tar.gz
tar zxf pcre-8.35.tar.gz
cd pcre-8.35
# Configure pcre, and specify to install to / usr/local/pcre.
./configure --prefix=/usr/local/pcre
# Compilation and installation
make && make install

4. Install zlib Library

Download address: https://pan.baidu.com/s/16f9XnHbz_7EWmQOws1zqMQ

Upload the downloaded zlib-1.2.8.tar.gz through ftp to the directory / usr/local/src of centos7.

cd /usr/local/src
# New zlib directory
mkdir /usr/local/zlib
# Unzip zlib-1.2.8.tar.gz
tar zxf zlib-1.2.8.tar.gz
cd zlib-1.2.8
# Configure zlib and specify to install to / usr/local/zlib
./configure --prefix=/usr/local/zlib
# Compilation and installation
make && make install

5. Install openssl

Download address: https://pan.baidu.com/s/1tsGQGb5fVR9vs1CGPSa37Q

Upload the downloaded openssl-1.0.1h.tar.gz through ftp to the directory / usr/local/src of centos7

cd /usr/local/src
# New openssl directory
mkdir /usr/local/openssl
# Unzip openssl-1.0.1h.tar.gz
tar zxf openssl-1.0.1h.tar.gz
cd openssl-1.0.1h
# Configure openssl, specify to install to / usr/local/openssl
./config --prefix=/usr/local/openssl
# Compilation and installation
make && make install

Add openssl to the environment variable and open the file / etc/profile.

vim /etc/profile

Add the following text to the last line

export PATH=$PATH:/usr/local/openssl/bin

Exit save! Execute the following command to make / etc/profile take effect immediately

source /etc/profile

6. Install Nginx

Download nginx at: http://nginx.org/download/ Here are various versions of nginx. This article downloads nginx-1.9.9.tar.gz

cd /usr/local/src
# download
wget http://nginx.org/download/nginx-1.9.9.tar.gz
# decompression
tar zxf nginx-1.9.9.tar.gz
# Enter nginx-1.9.9 source code
cd nginx-1.9.9
# Configure, specify the nginx installation directory / usr/local/nginx, and open the corresponding module
# --With OpenSSL = / usr / local / SRC / openssl-1.0.1h refers to the source path of openssl-1.0.1h
# --With zlib = / usr / local / SRC / zlib-1.2.8 refers to the source path of zlib-1.2.8
# --with-pcre=/usr/local/src/pcre-8.35 refers to the source path of pcre-8.35
./configure --prefix=/usr/local/nginx --without-http_memcached_module --with-http_stub_status_module --with-http_ssl_module --with-http_gzip_static_module --with-openssl=/usr/local/src/openssl-1.0.1h --with-zlib=/usr/local/src/zlib-1.2.8 --with-pcre=/usr/local/src/pcre-8.35
# Compilation and installation
make && make install

7. Start test Nginx

# start-up
/usr/local/nginx/sbin/nginx
# Close
killall nginx
# graceful restart
/usr/nginx/sbin/nginx -s reload

Posted by xux on Fri, 25 Oct 2019 09:40:19 -0700