以下操作均在当前用户目录操作(root的目录,截止2016.11.2最新版本)
1、安装常用工具及基础包:
yum -y install wget git vim make gcc gcc-c++ openssl-devel
mkdir -p /nginx/module
2、安装pcre模块:
wget -P/src/ http://nchc.dl.sourceforge.net/project/pcre/pcre/8.39/pcre-8.39.tar.gz
tar -xzvf /src/pcre-8.39.tar.gz -C /nginx/module/
3、安装OpenSSL模块:
wget -P /src/ https://www.openssl.org/source/openssl-1.0.2j.tar.gz
tar -xzvf /src/openssl-1.0.2j.tar.gz -C /nginx/module/
4、安装zlib模块:
wget -P /src/ http://zlib.net/zlib-1.2.8.tar.gz
tar -xzvf /src/zlib-1.2.8.tar.gz -C /nginx/module/
5、安装LuaJIT模块:
wget -P /src/ http://luajit.org/download/LuaJIT-2.0.4.tar.gz
tar -xzvf /src/LuaJIT-2.0.4.tar.gz -C /src/
cd /src/LuaJIT-2.0.4
make
make install
6、安装lua-nginx-module模块:
wget -P /src/ https://github.com/openresty/lua-nginx-module/archive/v0.10.6.tar.gz
tar -xzvf /src/v0.10.6.tar.gz -C /nginx/module/
7、安装nginx sticky模块:
wget -P /src/ https://bitbucket.org/nginx-goodies/nginx-sticky-module-ng/get/1.2.6.zip
mv 1.2.6.zip nginx-sticky-module-1.2.6.zip
unzip -x nginx-sticky-module-1.2.6.zip
mv nginx-sticky-module-1.2.6 /nginx/module/nginx-sticky-module-1.2.6
8、安装echo-nginx模块:
wget -P /src/ https://github.com/openresty/echo-nginx-module/archive/v0.60.tar.gz
mv /src/v0.60.tar.gz /src/echo-nginx-module-0.60.tar.gz
tar -xzvf /src/echo-nginx-module-0.60.tar.gz -C /nginx/module/
9、安装ngx_cache_purge模块:
wget -P /src/ https://github.com/FRiCKLE/ngx_cache_purge/archive/2.3.tar.gz
mv /src/2.3.tar.gz /src/ngx_cache_purge-2.3.tar.gz
tar -xzvf /src/ngx_cache_purge-2.3.tar.gz -C /nginx/module/
10、安装ngx_http_lower_upper_case:
wget -P /src/ https://github.com/replay/ngx_http_lower_upper_case/archive/master.zip
mv /src/master.zip /src/ngx_http_lower_upper_case-master.zip
unzip -x ngx_http_lower_upper_case-master.zip
mv ngx_http_lower_upper_case-master /nginx/module/ngx_http_lower_upper_case
11、安装、配置Nginx:
wget -P /src/ http://nginx.org/download/nginx-1.10.2.tar.gz
tar -xzvf /src/nginx-1.10.2.tar.gz -C /src/
cd /src/nginx-1.10.2
[[email protected] nginx-1.10.2]#./configure --prefix=/nginx \
--with-http_v2_module \
--with-http_ssl_module \
--with-http_realip_module \
--with-http_gzip_static_module \
--with-http_stub_status_module \
--with-pcre=/nginx/module/pcre-8.39 \
--with-zlib=/nginx/module/zlib-1.2.8 \
--with-openssl=/nginx/module/openssl-1.0.2j \
--add-module=/nginx/module/lua-nginx-module-0.10.6 \
--add-module=/nginx/module/nginx-sticky-module-1.2.6 \
--add-module=/nginx/module/echo-nginx-module-0.60 \
--add-module=/nginx/module/ngx_cache_purge-2.3 \
--add-module=/nginx/module/ngx_http_lower_upper_case
[[email protected] nginx-1.10.2]# make
[[email protected] nginx-1.10.2]# make install
=========================================================================
ssl_dhparam /nginx/ssl/dhparam.pem;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
/nginx/sbin/nginx -c /nginx/conf/nginx.conf
[[email protected] sbin]# /nginx/sbin/nginx -c /nginx/conf/nginx.conf
/nginx/sbin/nginx: error while loading shared libraries: libluajit-5.1.so.2: cannot open shared object file: No such file or directory
# cat /etc/ld.so.conf
include ld.so.conf.d/*.conf
# echo "/usr/local/lib" >> /etc/ld.so.conf
# ldconfig
[[email protected] sbin]# /nginx/sbin/nginx -c /nginx/conf/nginx.conf
1、关闭firewall:
[[email protected] ~]# systemctl stop firewalld.service
#停止firewall
[[email protected] ~]# systemctl disable firewalld.service 或 systemctl mask firewalld.service
#禁止firewall开机启动
2、安装iptables防火墙
[[email protected] ~]# yum install iptables-services -y
[[email protected] ~]# systemctl enable iptables
开放80的Web访问规则
[[email protected] ~]# vi /etc/sysconfig/iptables
添加一条配置规则,如要想开放8080的端口,如下所示:
-A RH-Firewall-1-INPUT -m state --state NEW -m tcp -p tcp --dport 8080 –j ACCEPT
重启iptables
[[email protected] ~]# systemctl restart iptables.service