zoukankan      html  css  js  c++  java
  • nginx虚拟目录实现两个后台使用

    购买了阿里云机器,准备搭建一套备份的后台,由于资源有限所以将两个后台搭建到一组SLB下的两台WEB上。

    使用软件:NGINX+PHP

    root@xx conf.d]# yum install php-fpm nginx

    更改nginx.conf文件,我将server信息全部注释,http下include到/etc/nginx/conf.d/*.conf下,这样清晰一些~

    root@xx conf.d]# cat /etc/nginx/nginx.conf
    # For more information on configuration, see:
    #   * Official English Documentation: http://nginx.org/en/docs/
    #   * Official Russian Documentation: http://nginx.org/ru/docs/
    
    user nginx;
    worker_processes auto;
    error_log /var/log/nginx/error.log;
    pid /run/nginx.pid;
    
    # Load dynamic modules. See /usr/share/nginx/README.dynamic.
    include /usr/share/nginx/modules/*.conf;
    
    events {
        worker_connections 1024;
    }
    
    http {
        log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
                          '$status $body_bytes_sent "$http_referer" '
                          '"$http_user_agent" "$http_x_forwarded_for"';
    
        access_log  /var/log/nginx/access.log  main;
    
        sendfile            on;
        tcp_nopush          on;
        tcp_nodelay         on;
        keepalive_timeout   65;
        types_hash_max_size 2048;
    
        include             /etc/nginx/mime.types;
        default_type        application/octet-stream;
    
        # Load modular configuration files from the /etc/nginx/conf.d directory.
        # See http://nginx.org/en/docs/ngx_core_module.html#include
        # for more information.
        include /etc/nginx/conf.d/*.conf;    #包含了我配置虚拟目录的文件
    
    
    }
    
    [root@xx conf.d]# 

    在虚拟目录下创建了两个后台的.conf文件

    [root@xx conf.d]# ll /etc/nginx/conf.d/
    total 8
    -rw-r--r-- 1 root root 516 Jul 24 13:54 aaa.com.conf
    -rw-r--r-- 1 root root 556 Jul 24 13:55 bbb.com.conf
    [root@xx conf.d]# 
    

    两个配置文件分别如下:

    [root@xx conf.d]# cat bbb.com.conf 
    server {
        listen       80;                        
        server_name bbb.com;    
        root  /letv/www/bbbz;             
        index index.html index.htm index.php;   
        location /abc/ {
    	index index.php;
    	if (!-e $request_filename){
    		rewrite ^/abc/(.*)$ /hotel/index.php?s=$1 last;
    		break;
        	}
        }
        location ~ .php$ {
                fastcgi_pass   127.0.0.1:9000;
                fastcgi_index  index.php;
                fastcgi_param  SCRIPT_FILENAME $document_root$fastcgi_script_name;
                include        fastcgi_params;
            }
    }
    [root@xx conf.d]# 
    

      

    [root@xx conf.d]# cat aaa.com.conf 
    server {
        listen       80;                        
        server_name aaa.com;    
        root  /letv/www/aaa;             
        index index.html index.htm index.php;   
        location /abc/ {                         #数据目录的匹配
    	index index.php;
    	if (!-e $request_filename){
    		rewrite ^/abc/(.*)$ /hotel/index.php?s=$1 last;
    		break;
        	}
        }
        location ~ .php$ {            #正则表达php文件用fastcgi解析
                fastcgi_pass   127.0.0.1:9000;
                fastcgi_index  index.php;
                fastcgi_param  SCRIPT_FILENAME $document_root$fastcgi_script_name;
                include        fastcgi_params;
            }
    }
    [root@xx conf.d]# 
    

      

    测试 aaa.com  bbb.com  访问不通目录下的数据

    好记性不如烂笔头-_-
  • 相关阅读:
    (七)微信小程序:收藏功能
    (六)微信小程序:制作新闻详情页
    (五)微信小程序:模板template
    (四)微信小程序:新闻列表渲染
    (三)微信小程序:焦点轮播图功能
    (二)微信小程序:实现页面跳转
    Docker和jenkins实现springboot自动部署
    (桥接)完美解决linux设置静态ip。
    一个简单的对任意list分页的工具-----PageUtil
    java8实战二------lambda表达式和函数式接口,简单就好
  • 原文地址:https://www.cnblogs.com/liuquan/p/7228790.html
Copyright © 2011-2022 走看看