Installation Environment: Centos7
Create a directory and switch to the directory
# mkdir /usr/local/nginx
# cd /usr/local/nginx/
Download nginx package, visit http://nginx.org download or http://nginx.org/download or use the command to download
wget http://nginx.org/download/nginx-1.17.3.tar.gz
Nginx unzip the package and move the extracted directory
# Tar -zxvf nginx- 1.17 . 3 tarballs # cd nginx - 1.17 . 3 /
Set the installation path
# ./configure --prefix=/usr/local/nginx
If an error occurs [checking for C compiler ... not found] you need to execute the following command
# yum -y install gcc gcc-c++ autoconf automake make
If the following error occurs, you need to install openssl
./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 openssl command
# yum -y install openssl openssl-devel
Compiler is used to compile --make that reads instructions from the Makefile, then compiled.
# make
--Make install installation is used to install, it also reads instructions from the Makefile, mounted to the specified location.
# make install
So far, nginx has been successfully installed, you can execute the following command to operate nginx nginx
command
Start - # / usr / local / nginx / sbin / nginx -c /usr/local/nginx/conf/nginx.conf
Restart - # nginx -s reload
Reopen the log files - # nginx -s reopen
Test nginx configuration file is correct - # nginx -t -c /usr/local/nginx/conf/nginx.conf
Fast Stop - # nginx -s stop
Complete and orderly stop - # nginx -s quit
The process can be stopped by nginx
Nginx main query process number - # ps -ef | grep nginx
Ordered to stop - # kill -QUIT main process ID
Fast Stop - # kill -TERM main process ID
Forced to stop - # pkill -9 nginx
Smooth start - # kill -HUP main process ID