Detailed Explanation of nginx Installation and Configuration Tutorial under Centos7

  • 2021-07-06 12:13:34
  • OfStack

Description: Basic Directory Path of Software Installation:/usr/local So when downloading software, switch to this directory to download and unzip it directly

1. Install the gcc gcc-c + + dependency package

yum install -y gcc gcc-c++

2. Download, compile and install the PCRE library

Switch to the usr/local directory to execute commands

Download the installation package

wget http://jaist.dl.sourceforge.net/project/pcre/pcre/8.33/pcre-8.33.tar.gz

Unzip the installation package

tar -zxvf pcre-8.36.tar.gz

Compile and install


cd pcre-8.36
./configure
make && make install

3. Download, compile and install the SSL library

Download the installation package

wget http://www.openssl.org/source/openssl-1.0.1j.tar.gz

Decompress the compressed package

tar -zxvf openssl-1.0.1j.tar.gz

Compile and install


cd openssl-1.0.1j
./config
make && make install

4. Download, compile and install the zlib dependency library

Download the installation package

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

Unzip the installation package

tar -zxvf zlib-1.2.11.tar.gz

Compile and install


cd zlib-1.2.11
./configure
make && make install

After the dependency package and environment are installed and configured, nginx needs to be installed next

5. Installation of nginx

Download the installation package

wget http://nginx.org/download/nginx-1.8.0.tar.gz
Unzip the installation package

tar -zxvf nginx-1.8.0.tar.gz

Compile and install


cd nginx-1.8.0
./configure --user=nobody --group=nobody --prefix=/usr/local/nginx --with-http_stub_status_module --with-http_gzip_static_module --with-http_realip_module --with-http_sub_module --with-http_ssl_module
make && make install

(Note: In the second instruction of compilation: --prefix=/usr/local/nginx specifies the directory of compilation and installation. After successful compilation, the folder after installation of nginx will be displayed in /usr/local directory, and the compilation file of nginx-1. 8.0 can be deleted)

6. nginx related operation commands

Switch to the nginx directory

cd /usr/local/nginx

Execute the following command

Start nginx

./sbin/nginx

Check whether the nginx configuration file is correct

 ./sbin/nginx -t

See that the nginx configuration file is accurate as shown in the figure

Stop nginx

Check the process number occupied by nginx, and finish it


ps -ef|grep nginx
kill -9  Port number 

Summarize


Related articles: