nginx

1:运用场景: 

     a:是一个http服务可以单独提供http服务,可以做网页静态服务器。

    b:虚拟主机:两台域名对应同一台服务器并且公用80端口。

    c:反向代理,负载均衡:当网站的访问量达到一定程度后,单台服务器不能满足用户请求,可以用nginx反向代理,集群多台服务器。并且平均分担请求。

 

 

2:nginx安装:

      前置环境: a:安装gcc   yum install -y gcc-c++

                        b:安装pcre   yum install -y pcre pcre-devel   (正则表达式库,nginx中http模块使用pcre来解析正则表达式)

                      c:安装zlib   yum install -y zlib zlib-devel (zlib提供很多压缩方式,nginx使用zlib对http包进行zlib)

                    d:安装openssl:  openssl是一个密码库,包括主要密码算法、常用的密钥和证书封装管理功能及ssl协议。nginx不仅支持http,还支持https(及在ssl协议上传输http)

 

 

安装nginx:

a:将安装包拷贝  /usr/local

b:解压  tar -zxf  xxxx.tar.gz

           cd nginx-1.8.1

 c:配置 ./configure

 d:编译  make

e:编译安装  make install

f:开通80端口

     vim  /etc/sysconfig/iptables

     service iptables restart

i:启动nginx   cd /usr/local/nginx/sbin

                   ./nginx

                   ps -aux | grep nginx

 

通过端口区分不同的主机: 

    主要是修改niginx下的niginx.conf文件配置

 

server {
listen 80;
server_name localhost;

#charset koi8-r;

#access_log logs/host.access.log main;

location / {
root html;
index index.html index.htm;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
}
server {
listen 88;
server_name localhost;
location / {
root html;
index index_88.html index.htm;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}

 

windows修改域名解析文件: c:\Windows\System32\drivers\hosts

   加:  192.168.174.129   www.baidu.com

linux修改域名解析文件  /etc/hosts

 

 

 

 

        

   

 

posted @ 2018-07-10 23:39  java奋斗  阅读(162)  评论(0编辑  收藏  举报