zoukankan      html  css  js  c++  java
  • nginx配置虚拟机

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

    一、通过端口号区分虚拟机

    在nginx.conf文件中添加一个Service节点,修改端口号:
    
    server {
            listen       80;
            server_name  localhost;
    
            #charset koi8-r;
    
            #access_log  logs/host.access.log  main;
    
            location / {
                root   html80;
                index  index.html index.htm;
            }
       }
    
    server {
            listen       81;
            server_name  localhost;
    
            #charset koi8-r;
    
            #access_log  logs/host.access.log  main;
    
            location / {
                root   html81;
                index  index.html index.htm;
            }
       } 

    二、通过域名区分虚拟机

    ①:需要修改nginx.conf配置文件
    server {
            listen       80;
            server_name  test1.nginx.com;
    
            #charset koi8-r;
    
            #access_log  logs/host.access.log  main;
    
            location / {
                root   html-test3;
                index  index.html index.htm;
            }
       }
    
    server {
            listen       80;
            server_name  test2.nginx.com;
    
            #charset koi8-r;
    
            #access_log  logs/host.access.log  main;
    
            location / {
                root   html-test3;
                index  index.html index.htm;
            }
       }
    
    ②:修改后重新加载配置文件
    [root@localhost sbin]# ./nginx -s reload

    至此结束……

    关注我的公众号,精彩内容不能错过

  • 相关阅读:
    Python shutil模块
    Flask 上传文件
    Flask DBUtils
    flash-session
    Flash 上下文管理
    python 栈
    python 偏函数
    threding.local
    next() 与 nextLine() 区别
    Thread.sleep(1000*3); // 休眠3秒
  • 原文地址:https://www.cnblogs.com/huanchupkblog/p/5560535.html
Copyright © 2011-2022 走看看