美文网首页nginx学习笔记
使用nginx配置虚拟机

使用nginx配置虚拟机

作者: Airycode | 来源:发表于2018-05-10 15:16 被阅读3次

1:通过端口区分虚拟机
在nginx.conf文件中添加一个Service节点,修改端口号就可以

server {
        listen       81;
        server_name  localhost;

        #charset koi8-r;

        #access_log  logs/host.access.log  main;

        location / {
            root   html81;
            index  index.html index.htm;
        }
   }

2:通过域名区分虚拟机
域名介绍
PC机输入域名走到DNS服务器(把域名转化成ip)然后通过ip去访问服务器
可以通过修改host文件指定域名的ip地址。
Host文件的位置:C:\Windows\System32\drivers\etc
也可以使用工具:SwitchHosts

3.配置基于域名的虚拟主机
需要修改nginx.conf配置文件

server {
        listen       80;
        server_name  test3.xxx.com;

        #charset koi8-r;

        #access_log  logs/host.access.log  main;

        location / {
            root   html-test3;
            index  index.html index.htm;
        }
   }

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

相关文章

网友评论

    本文标题:使用nginx配置虚拟机

    本文链接:https://www.haomeiwen.com/subject/emnzrftx.html