zoukankan      html  css  js  c++  java
  • nginx配置虚拟机 vhost 端口号 域名 区分虚拟机

    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;
            }
       } 

    二、通过域名区分虚拟机

    server {
            listen       80;
            root         "D:/phpStudy/WWW/xgb/public/";
            server_name  xgb.tt;
    
            location / {
                index  index.html index.htm index.php l.php;
                autoindex  off;
    
                if (!-e $request_filename) {
                    rewrite  ^(.*)$  /index.php?s=/$1  last;
                }
            }
    
            error_page   500 502 503 504  /50x.html;
            location = /50x.html {
                root   html;
            }
    
            location ~ .php(.*)$  {
                fastcgi_pass   127.0.0.1:9000;
                fastcgi_index  index.php;
                fastcgi_split_path_info  ^((?U).+.php)(/?.+)$;
                fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
                fastcgi_param  PATH_INFO  $fastcgi_path_info;
                fastcgi_param  PATH_TRANSLATED  $document_root$fastcgi_path_info;
                include        fastcgi_params;
            }
    }
    
    server {
            listen       80;
            root         "D:/phpStudy/WWW/tp5/public/";
            server_name  tp5.tt;
    
            location / {
                index  index.html index.htm index.php l.php;
                autoindex  off;
    
                if (!-e $request_filename) {
                    rewrite  ^(.*)$  /index.php?s=/$1  last;
                }
            }
    
            error_page   500 502 503 504  /50x.html;
            location = /50x.html {
                root   html;
            }
    
            location ~ .php(.*)$  {
                fastcgi_pass   127.0.0.1:9000;
                fastcgi_index  index.php;
                fastcgi_split_path_info  ^((?U).+.php)(/?.+)$;
                fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
                fastcgi_param  PATH_INFO  $fastcgi_path_info;
                fastcgi_param  PATH_TRANSLATED  $document_root$fastcgi_path_info;
                include        fastcgi_params;
            }
    }
    [root@localhost sbin]# ./nginx -s reload
  • 相关阅读:
    linux下FFmpeg编译生成ffplay
    linux下ffmpeg安装
    linux之x86裁剪移植---字符界面sdl开发入门
    Linux忘记开机密码怎么办?
    linux命令--ldconfig和ldd用法
    linux命令之 ifconfig
    Linuxshell脚本之if条件判断
    redis之django-redis
    深刻理解Python中的元类(metaclass)
    【Django错误】OSError: raw write() returned invalid length 14 (should have been between 0 and 7)
  • 原文地址:https://www.cnblogs.com/shaoing/p/6412643.html
Copyright © 2011-2022 走看看