#!/bin/bash
#for one install nginx
#for wangjiadongge
#Add users running the nginx service process
useradd -s /sbin/nologin nginx #創建一個不能登陸系統的用戶nginx
#Installation dependence
yum groupinstall -y "Development tools"
yum install -y gcc wget gcc-c++ automake autoconf libtool libxml2-devel libxslt-devel perl-devel perl-
ExtUtils-Embed pcre-devel openssl-devel #安裝依賴包
#Download source
wget http://nginx.org/download/nginx-1.12.2.tar.gz #安裝包下載
tar -xvf nginx-1.12.2.tar.gz -C /opt #解壓到opt下
#Compile and install
cd /opt/nginx-1.12.2/
./configure \ #檢查編譯環境
--prefix=/opt/nginx/ \ #安裝路徑
--user=nginx \ #用戶
--group=nginx \ #用戶組
--with-pcre \
--with-http_v2_module \
--with-http_ssl_module \ #https模塊
--with-http_realip_module \
--with-http_addition_module \
--with-http_sub_module \
--with-http_dav_module \
--with-http_flv_module \
--with-http_mp4_module \
--with-http_gunzip_module \
--with-http_gzip_static_module \
--with-http_random_index_module \
--with-http_secure_link_module \
--with-http_stub_status_module \
--with-http_auth_request_module \
--with-mail \
--with-mail_ssl_module \
--with-file-aio \
--with-http_v2_module \
--with-threads \
--with-stream \
--with-stream_ssl_module \
make && make install #編譯&&安裝
ln -s /opt/nginx/sbin/nginx /usr/bin/nginx #創建軟連接
Nginx #啓動服務器 重啓 nginx -s reload
ps -aux|grep nginx #查看nginx服務