码迷,mamicode.com
首页 > 其他好文 > 详细

(三)企业部分之nginx(未完)

时间:2016-06-12 23:43:33      阅读:415      评论:0      收藏:0      [点我收藏+]

标签:安装   负载   nginx   

1.nginx安装

所需软件包:nginx-1.8.0.tar.gz  

 

tar zxf nginx-1.8.0.tar.gz

 

cd nginx-1.8.0

yum install pcre-devel  openssl-devel  -y

./configure --prefix=/usr/local/lnmp/nginx --with-http_ssl_module --with-http_stub_status_module

 

make

make install

 

vim /root/.bash_profile

source /root/.bash_profile

 

cd /usr/local/lnmp/nginx/sbin/

./nginx -t##检测

./nginx##服务开启脚本

 

 

curl -I localhost##检测http协议提供程序

 

2.屏蔽nginx版本

rm  -rf  /root/nginx-1.8.0  /usr/local/lnmp/nginx

tar zxf nginx-1.8.0.tar.gz##重新解压nginx源码包

 

vim /root/nginx-1.8.0/src/core/nginx.h##伪装版本

 

vim /root/nginx-1.8.0/auto/cc/gcc##关闭debug调式

 

cd nginx-1.8.0

./configure --prefix=/usr/local/lnmp/nginx --with-http_ssl_module --with-http_stub_status_module

make

make install

 

nginx -t ##检测nginx配置

nginx -s reload ##加载配置

 

useradd -s /sbin/nologin -d /usr/local/lnmp/nginx nginx

 

vim /usr/local/lnmp/nginx/conf/nginx.conf

user  nginx nginx;##用户和组,可以只写用户

worker_processes  2;##cpu个数,不能超过lscup

 

events {

        use epoll;##nginx epoll 采用异步非阻塞模式 apache --select 同步阻塞机制 io复用模型类型

        worker_connections  4096;##连接数

}

 

 

3.开启https

server这一段注释去掉,cert.key改为cert.pem

 

cd /etc/pki/tls/certs/

make cert.pem

cp cert.pem /usr/local/lnmp/nginx/conf/

 

nginx -t

nginx -s reload

 

 

4.nginx 监控小插件

vim /usr/local/lnmp/nginx/conf/nginx.conf

增加以下内容:

49         location /status {###/status 名字自定义

50                 stub_status on;

51                 access_log off;

52         }

 

 

nginx -t

nginx -s reload

 

访问 ip/status

 

5.nginx 虚拟主机

/usr/local/lnmp/nginx/conf/nginx.conf最后加上以下部分(注意后面那个括号):

 

mkdir /web{1..2}

echo www.linux.org > /web1/index.html

echo www.unix.org > /web2/index.html

nginx -t

nginx -s reload

 

6.nginx 负载均衡套件

server2server3做以下工作:

yum install httpd -y

cd /var/www/html/

echo server2/3.example.com > index.html

 

/usr/local/lnmp/nginx/conf/nginx.conf最后加上以下部分(注意后面那个括号):

 

 

 

nginx -t 

nginx -s reload 

访问www.linux.org 测试

 


(三)企业部分之nginx(未完)

标签:安装   负载   nginx   

原文地址:http://wjl19940429.blog.51cto.com/11354210/1788412

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!