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

nginx基于IP

时间:2017-04-30 00:57:43      阅读:246      评论:0      收藏:0      [点我收藏+]

标签:linux服务

基于IP的虚拟主机

首先添加3个IP


[root@localhost extra]# ifconfig

ifconfig eth0:133 172.20.100.133 netmask 255.255.252.0 up

ifconfig eth0:132 172.20.100.132 netmask 255.255.252.0 up

ifconfig eth0:131 172.20.100.131 netmask 255.255.252.0 up


eth0:131  Link encap:Ethernet  HWaddr 00:0C:29:74:18:24  

          inet addr:172.20.100.131  Bcast:172.20.103.255  Mask:255.255.252.0

          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1


eth0:132  Link encap:Ethernet  HWaddr 00:0C:29:74:18:24  

          inet addr:172.20.100.132  Bcast:172.20.103.255  Mask:255.255.252.0

          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1


eth0:133  Link encap:Ethernet  HWaddr 00:0C:29:74:18:24  

          inet addr:172.20.100.133  Bcast:172.20.103.255  Mask:255.255.252.0

          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1


[root@localhost nginx]# vim extra/nginx_vhosts.conf

    server {

        listen       172.20.100.133:8060;

        server_name  172.20.100.133;

        location / {

            root   /data0/www/www;

            index  index.html index.htm;

            access_log /app/logs/www_access.log  commonlog;

        }

    }

######

server {

        listen       172.20.100.132:8070;

        server_name  172.10.100.132;

        location / {

            root   /data0/www/bbs;

            index  index.html index.htm;

            access_log /app/logs/bbs_access.log  commonlog;

        }

    }

######

server {

        listen       172.20.100.131:8080;

        server_name  172.10.100.131;

        location / {

            root   /data0/www/blog;

            index  index.html index.html;

            access_log /app/logs/blog_access.log  commonlog;

        }

    }

server {

        listen       80;

        server_name  status.you.com;

        location / {

          stub_status on;

          access_log off;

        }

    }



[root@localhost extra]# ../sbin/nginx -t

nginx: the configuration file /usr/local/nginx/conf/nginx.conf syntax is ok

nginx: configuration file /usr/local/nginx/conf/nginx.conf test is successful

[root@localhost extra]# ../sbin/nginx -s reload


nginx基于IP

标签:linux服务

原文地址:http://12187655.blog.51cto.com/12177655/1920710

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