1、防止 make: command not found,提前安裝一些插件,取決於當前環境是否已安裝,如果已經安裝就不需要執行此命令
yum -y install gcc automake autoconf libtool make
防止 make: command not found
2、下載源碼進行安裝
wget http://nginx.org/download/nginx-1.18.0.tar.gz
3、安裝需要的插件
yum -y install gcc pcre pcre-devel zlib zlib-devel openssl openssl-devel
4、解壓壓縮包
tar -zxvf nginx-1.18.0.tar.gz
5、指定安裝路徑
./configure --prefix=/root/nginx/nginx-1.18.0
6、編譯並安裝
make && make install
7、啟動服務(進入到安裝目錄的sbin)
./nginx
8、重啟服務(進入到安裝目錄的sbin)
./nginx -s reload
9、停止服務(進入到安裝目錄的sbin)
./nginx -s stop 或者 ./nginx -s quit