1、安装准备
# yum install gcc-c++
# yum -y install zlib zlib-devel openssl openssl--devel pcre pcre-devel
# yum -y install zlib zlib-devel openssl openssl--devel pcre pcre-devel
标红的三个模块如果yum安装不了,也可以下载安装包安装
tar zxvf openssl-fips.tar.gz
cd openssl-fips
./config && make && make install
2、检查是否安装过nginx
# find -name nginx
./nginx
./nginx/sbin/nginx
./nginx-1.2.6/objs/nginx
3、卸载原有的Nginx
4、安装
上传文件
# cd /opt/local
# mkdir nginx
# tar -zxvf ../software/nginx-1.6.2.tar.gz
# cd nginx-1.6.2
# ./configure --prefix=/opt/local/nginx/sbin/nginx--with-http_stub_status_module --with-http_ssl_module --with-file-aio --with-http_realip_module 注:红色部分表示安装的路径
# make 编译
# make install 安装
# mkdir nginx
# tar -zxvf ../software/nginx-1.6.2.tar.gz
# cd nginx-1.6.2
# ./configure --prefix=/opt/local/nginx/sbin/nginx--with-http_stub_status_module --with-http_ssl_module --with-file-aio --with-http_realip_module 注:红色部分表示安装的路径
# make 编译
# make install 安装
5、启动
#方法1
# /opt/local/nginx/sbin/nginx -c /opt/local/nginx/sbin/nginx/conf/nginx.conf
#方法2
# /opt/local/nginx/sbin/nginx
6、停止
#查询nginx主进程号
ps -ef | grep nginx
#强制停止
pkill -9 nginx
7、重启(一半建议使用这个命令,如果配置错了。就不会更新)
# /opt/local/nginx/sbin/nginx -s reload
8、配置:Nginx.conf
location /mp_web/ {
proxy_pass http://192.168.51.209:9083/mp_web/;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr; #一般的web服务器用这个 X-Real-IP 来获取源IP
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_pass http://192.168.51.209:9083/mp_web/;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr; #一般的web服务器用这个 X-Real-IP 来获取源IP
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
#如果nginx 服务器是作为反向代理服务器的,则这个配置项是必须的;否则看不到源IP
client_max_body_size 1024m;
}
client_max_body_size 1024m;
}