nginx版本: 1.12.2
1. 安装依赖包
Yum install –y gcc gcc-c++ zlib zlib-devel openssl openssl-devel pcre pcre-devel
2. 编译和安装nginx
执行如下命令:
# cd software/nginx-1.12.2
# ./configure --prefix=/data/nginx/ --with-http_ssl_module --with-http_v2_module \
--with-http_stub_status_module --with-pcre
#Make
#Make install
–with-http_stub_status_module:支持nginx状态查询
–with-http_ssl_module:支持https
--with-http_v2_module:支持google的spdy,想了解请百度spdy,这个必须有ssl的支持
–with-pcre:为了支持rewrite重写功能,必须制定pcre
3. 安装完成启动nginx。 (如果用指定用户启动nginx要先修改nginx.conf的用户部分)
[root@localhost conf]#/data/nginx/sbin/nginx (启动nginx提示如下错误)
/data/nginx/sbin/nginx: error while loadingshared libraries: libpcre.so.1: cannot open shared object file: No such file ordirectory
建立软连接或配置环境变量
[hadoop@SCLABHADOOP01 ~]$ ln -s/usr/local/lib/libpcre.so.1 /lib64/
编辑用户目录下的 .bash_profile文件
PATH=$PATH:$HOME/bin:/data/nginx/sbin
/usr/nginx/sbin/nginx –t (判断Nginx配置是否正确)
/data/nginx/sbin/nginx(启动服务)
/data/nginx/sbin/nginx-s stop(停止服务)
/data/nginx/sbin/nginx-s reload(重启服务)