安装依赖模块:
yum install -y pcre-devel
yum -y install openssl openssl-devel
添加nginx组合用户
# groupadd -r nginx
# useradd -g nginx -r nginx
获取nginx源码,此次测试中没有使用较新的版本,为nginx-1.12.2
# wget http://nginx.org/download/nginx-1.12.2.tar.gz
# tar -zxvf nginx-1.12.2.tar.gz
# cd nginx-1.12.2.tar.gz
编译安装nginx
# ./configure --prefix=/usr/local/nginx
--conf-path=/etc/nginx/nginx.conf
--user=nginx --group=nginx
--error-log-path=/var/log/nginx/error.log
--http-log-path=/var/log/nginx/access.log
--pid-path=/var/run/nginx/nginx.pid
--lock-path=/var/lock/nginx.lock
--with-http_ssl_module #支持ssl模块
--with-http_stub_status_module
--with-http_gzip_static_module
--http-client-body-temp-path=/var/tmp/nginx/client
--http-proxy-temp-path=/var/tmp/nginx/proxy
--http-fastcgi-temp-path=/var/tmp/nginx/fastcgi
--http-uwsgi-temp-path=/var/tmp/nginx/uwsgi
``
# make && make install
创建相应的目录
# mkdir -pv /var/tmp/nginx/{client,proxy,fastcgi,uwsgi}
支持nginx安装完成,先测试一下nginx服务是否能正常启动,并提供web服务
# /usr/local/nginx/sbin/nginx
# ss -tnlp
此时若是看到80端口已然被监听,则nginx正常运行```