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

Nginx的配置

时间:2016-10-06 17:36:11      阅读:122      评论:0      收藏:0      [点我收藏+]

标签:

在/usr/local/nginx/conf目录下nginx.conf文件是nginx的配置文件。

技术分享

1使用nginx配置虚拟机

1.1通过端口区分虚拟机

在nginx.conf文件中添加一个Server节点,修改端口号就可以

server {
    listen       81;
    server_name  localhost;

    #charset koi8-r;
    #
    #        #access_log  logs/host.access.log  main;
    #
    location / {
          root   html81;
          index  index.html index.htm;
     }                                              
}

http://192.168.81.128:81/

访问的是html81文件夹下的index.html文件

1.2通过域名区分虚拟机

技术分享

这里我们可以通过修改host文件指定域名的ip地址完成域名解析的任务

Host文件的位置:C:\Windows\System32\drivers\etc

技术分享

需要修改nginx.conf配置文件。

技术分享

修改配置后需要重新加载配置文件。

 此时访问

www.taobao.com/

访问的就是html-taobao文件夹下的index.html

Nginx的配置

标签:

原文地址:http://www.cnblogs.com/winner-0715/p/5933994.html

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