NGinx编译安装

1.1 官网下载
wget -c http://nginx.org/download/nginx-1.18.0.tar.gz
1.2 安装依赖
yum -y install gcc gcc-c++ make pcre-devel openssl-devel zlib-devel
1.3 编译安装
tar xf nginx-1.18.0.tar.gz
cd nginx-1.18.0/
./configure --prefix=/usr/local/nginx \
--user=nginx \
--group=nginx \
--with-compat \
--with-file-aio \
--with-threads \
--with-http_addition_module \
--with-http_auth_request_module \
--with-http_dav_module \
--with-http_flv_module \
--with-http_gunzip_module \
--with-http_gzip_static_module \
--with-http_mp4_module \
--with-http_random_index_module \
--with-http_realip_module \
--with-http_secure_link_module \
--with-http_slice_module \
--with-http_ssl_module \
--with-http_stub_status_module \
--with-http_sub_module \
--with-http_v2_module \
--with-mail \
--with-mail_ssl_module \
--with-stream \
--with-stream_realip_module \
--with-stream_ssl_module \
--with-stream_ssl_preread_module \
--with-cc-opt='-O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -m64 -mtune=generic -fPIC' --with-ld-opt='-Wl,-z,relro -Wl,-z,now -pie'
make
make install
1.4 扩展模块
--add-module=/tmp/fastdfs-nginx-module-1.22/src
1.4 安全运行
# 将nginx master进程设置为普通用户运行
chown nginx.root -R /usr/local/nginx
chown nginx.nginx /usr/local/nginx/sbin/nginx
setcap cap_net_bind_service=+ep /usr/local/nginx/sbin/nginx
chmod u+s /usr/local/nginx/sbin/nginx
/usr/local/nginx -t
/usr/local/nginx -s reload