1. 切换到root用户或者sudo 安装依赖组件
yum -y install wget vim gcc gd-devel gd-devel GeoIP-devel zlib-devel pcre-devel openssl-devel gd-devel libxslt-devel
2. 进入执行安装编译的工作目录,从官网下载nginx-1.14.2.tar.gz
wget http://nginx.org/download/nginx-1.14.2.tar.gztar zxvf nginx-1.14.2.tar.gzcd nginx-1.14.2
3. 执行编译并安装
./configure --prefix=../nginx --sbin-path=../nginx/sbin --conf-path=../nginx/conf/nginx.conf --http-log-path=../logs/nginx/access.log --error-log-path=../logs/nginx/error.log --pid-path=../nginx/var/run/nginx.pid --lock-path=../nginx/var/lock/subsys/nginx --user=work --group=work --with-poll_module --with-threads --with-file-aio --with-http_ssl_module --with-http_v2_module --with-http_realip_module --with-http_addition_module --with-http_xslt_module --with-http_image_filter_module --with-http_geoip_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_auth_request_module --with-http_random_index_module --with-http_secure_link_module --with-http_degradation_module --with-http_slice_module --with-http_stub_status_module
make && make install
说明一下,我这里安装编译参数路径部分用的都是相对路径,你在参考编译的时候,可根据实际情况进行替换。