A: the environment
centos7
Two: Installation preparations
Make sure g++, GCC, openssl-devel, pcl-devel, and zlib-devel are installed
Three: Install dependencies
[root@zyyy]# yum install gcc-c++
[root@zyyy]# yum -y install zlib zlib-devel openssl openssl--devel pcre pcre-devel// If installed, remove [root@zyyy]# yum remove nginx
Copy the code
Four: Download nginx
[root@zyyy]Wget # https://nginx.org/download/nginx-1.16.0.tar.gz
Copy the code
Install nginx
1: Decompress and compile
// unzip [root@zyyy nginx]# tar - ZXVF nginx - 1.11.3. Tar. Gz// is usually placed in /usr/localGo down to // and move to /usr/local/nginx-1.11.3 directory [root@zyyy nginx]# mv nginx - 1.11.3 / usr/local/nginx - 1.11.3/ / user /localCreate an nginx directory [root@zyyy]local]# mkdir nginx// Build and install [root@zyyy nginx-1.16.0]# ./configure --prefix=/usr/local/nginx[root @ zyyy nginx - 1.16.0]# make[root @ zyyy nginx - 1.16.0]# make install
Copy the code
Nginx has been installed successfully
2: Start, stop, and restart
Go to the sbin directory and run the command
Nginx installation directory address -c nginx configuration file address [root@zyyy sbin]# /usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf
Copy the code
[root@zyyy sbin]# ps -ef|grep nginx
Copy the code
// Then kill the process [root@zyyy sbin]# kill -term 18848
Copy the code
// Restart the sbin directory and enter./nginx-sReload [root@zyyy sbin]# ./nginx -s reload
Copy the code
3: Verify that the nginx configuration file is correct
Enter the sbin directory and use it. The following figure shows that it is correct
[root@zyyy sbin]# ./nginx -t
Copy the code
[root@zyyy sbin]# /usr/local/nginx/sbin/nginx -t -c /usr/local/nginx/conf/nginx.conf
Copy the code
Various commands nginx -h # help
Nginx -v # displays the version
Nginx -v # displays version and configuration information
Nginx -t # test configuration
Nginx -q # outputs only error messages when testing the configuration
Nginx -s stop # Stop the server
Nginx -s reload # reload configuration