Installation steps of nginx in Centos

One, online installation

1. Preparations before installing nginx:

First confirm whether gcc, pcre-devel, zlib-devel, openssl-devel are installed in the system .

1. For rpm package installation, you can use rpm -qa to see. If you want to find out whether a certain package is installed, use  rpm -qa | grep "name of software or package"

2. Installed with deb package, you can use dpkg -l to see it. If you are looking for a specific software package, use  dpkg -l | grep "The name of the software or package"

3. If it is installed by yum method, you can use yum list installed to search, if it is to find a specified package, use  yum list installed | grep "software name or package name"

Example: Check whether gcc is installed

yum list installed | grep "gcc"

    

Here you can confirm that we do not have gcc installed.

yum -y install gcc

Execute the find command again

    

It has been installed.

If not installed, you can use the command: yum -y install gcc pcre-devel zlib-devel openssl openssl-devel

2. Download the nginx installation package, use nginx-1.9.9.tar.gz here

2.1. Put the installation package under /usr/local:

##Unzip:

tar -zxvf nginx-1.9.9.tar.gz

Enter the nginx-1.9.9 directory

##Configuration:

./configure --prefix=/usr/local/nginx

##Compile and install:

make && make install

After the completion of the nginx installation package path: /usr/local/nginx

 

Two, source installation

Module dependency Nginx needs to depend on the following 3 packages

  1. The ssl function requires the openssl library (  click to download  )
  2. The gzip module requires the zlib library (  click to download  )
  3. The rewrite module requires pcre library (  click to download  )

The order of installation of dependent packages is: openssl, zlib, pcre, and finally the Nginx package.

 step 1: Download the required package

openssl-fips-2.0.2.tar.gz
zlib-1.2.7.tar.gz
pcre-8.21.tar.gz
nginx-1.12.2.tar.gz

step 2: Install OpenSSL

[root@localhost wcw]# tar -zxvf openssl-fips-2.0.2.tar.gz 
[root@localhost wcw]# cd openssl-fips-2.0.2
[root@localhost openssl-fips-2.0.2]# ./config 
[root@localhost openssl-fips-2.0.2]# make
[root@localhost openssl-fips-2.0.2]# make install

step 3: Install zlib

[root@localhost wcw]# tar -zxvf zlib-1.2.7.tar.gz
[root@localhost wcw]# cd zlib-1.2.7
[root@localhost zlib-1.2.7]# ./configure 
[root@localhost zlib-1.2.7]# make
[root@localhost zlib-1.2.7]# make install

step 4: install pcre

[root@localhost wcw]# tar -zxvf pcre-8.21.tar.gz
[root@localhost wcw]# cd pcre-8.21
[root@localhost pcre-8.21]# ./configure 
[root@localhost pcre-8.21]# make
[root@localhost pcre-8.21]# make install

step 5: Install Nginx

[root@localhost wcw]# tar -zxvf nginx-1.12.2.tar.gz 
[root@localhost wcw]# cd nginx-1.12.2
[root@localhost nginx-1.12.2]# ./configure --prefix=/usr/install/nginx --with-pcre=../pcre-8.21 --with-zlib=../zlib-1.2.7 --with-openssl=../openssl-fips-2.0.2
[root@localhost nginx-1.12.2]# make
[root@localhost nginx-1.12.2]# make install

Please note: The value of "--with-xxx=" is the decompression directory, not the installation directory!

 

Nginx Linux basic operating instructions

启动服务:nginx
退出服务:nginx -s quit
强制关闭服务:nginx -s stop
重载服务:nginx -s reload  (重载服务配置文件,类似于重启,但服务不会中止)
验证配置文件:nginx -t
使用配置文件:nginx -c "配置文件路径"
使用帮助:nginx -h

 

Additional: nginx configuration options try_files detailed explanation ( https://www.cnblogs.com/jedi1995/p/10900224.html )

Guess you like

Origin blog.csdn.net/D_J1224/article/details/110818313
Recommended