centos7源码编译安装NGINX

1、 什么是nginx

Nginx是一款高性能的http 服务器/反向代理服务器及电子邮件(IMAP/POP3)代理服务器。官方测试nginx能够支支撑5万并发链接,并且cpu、内存等资源消耗却非常低,运行非常稳定。

2、下载

进入http://nginx.org/en/download.html 下载nginx1.8.0版本(当前最新稳定版本)。

3、nginx安装环境

[root@xinglinglove ~]# yum –y install gcc-c++

[root@xinglinglove ~]# yum install -y pcre pcre-devel

[root@xinglinglove ~]# yum install -y zlib zlib-devel

[root@xinglinglove ~]# yum install -y openssl openssl-devel

4、编译安装

将nginx-1.8.0.tar.gz拷贝至linux服务器。

解压:

[root@xinglinglove ~]# tar -zxvf nginx-1.8.0.tar.gz

[root@xinglinglove ~]# cd nginx-1.8.0

[root@xinglinglove ~]# mkdir -p /var/temp/nginx

[root@xinglinglove ~]# ./configure \

--prefix=/usr/local/nginx \

--pid-path=/var/run/nginx/nginx.pid \

--lock-path=/var/lock/nginx.lock \

--error-log-path=/var/log/nginx/error.log \

--http-log-path=/var/log/nginx/access.log \

--with-http_gzip_static_module \

--http-client-body-temp-path=/var/temp/nginx/client \

--http-proxy-temp-path=/var/temp/nginx/proxy \

--http-fastcgi-temp-path=/var/temp/nginx/fastcgi \

--http-uwsgi-temp-path=/var/temp/nginx/uwsgi \

--http-scgi-temp-path=/var/temp/nginx/scgi

[root@xinglinglove ~]#make -j 4

[root@xinglinglove ~]#make install

5、启动nginx

[root@xinglinglove ~]# cd /usr/local/nginx/sbin/

[root@xinglinglove ~]# ./nginx

6、查询nginx进程

[root@xinglinglove ~]# ps -aux |grep nginx

root 10478 0.0 0.0 24880 800 ? Ss 17:19 0:00 nginx: master process ./sbin/nginx

nobody 10479 0.0 0.0 27320 1816 ? S 17:19 0:00 nginx: worker process

root 12025 0.0 0.0 112704 976 pts/0 R+ 17:37 0:00 grep --color=auto nginx

7、停止nginx

[root@xinglinglove ~]#/usr/local/nginx/sbin/nginx -s stop

8、重新加载配置

[root@xinglinglove ~]#/usr/local/nginx/sbin/nginx -s reload

9、nginx反向代理

通常的代理服务器,只用于代理内部网络对Internet的连接请求,客户机必须指定代理服务器,并将本来要直接发送到Web服务器上的http请求发送到代理服务器中由代理服务器向Internet上的web服务器发起请求,最终达到客户机上网的目的。

而反向代理(Reverse Proxy)方式是指以代理服务器来接受internet上的连接请求,然后将请求转发给内部网络上的服务器,并将从服务器上得到的结果返回给internet上请求连接的客户端,此时代理服务器对外就表现为一个反向代理服务器。

 

如下图:

10、 nginx反向代理配置 (反向代理rabbitmq)

#配置一个代理即rabbitmq服务器

upstream rabbitmq_server {

            server 192.168.101.5:15672;

        }

#配置一个虚拟主机

    server {

        listen 80;

        server_name rabbitmq.xinglinglove.cn;

        location / {

                proxy_pass http://rabbitmq_server ;

        }

11、测试

http://rabbitmq.xinglinglove.cn/#/

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值