• 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  访问不通目录下的数据

    好记性不如烂笔头-_-
  • 相关阅读:
    JVM字节码-字节码进阶
    JVM字节码-Class文件结构
    CT03 Contest#10 equation 大力打表+讨论
    2021CT03 Contest#9 降智场
    妙妙题 noi.ac 2323 Connecting
    洛谷 P4774 [NOI2018] 屠龙勇士
    [模板] 扩展中国剩余定理
    洛谷 P1082 [NOIP2012 提高组] 同余方程
    洛谷 P1516 青蛙的约会
    2021牛客暑期多校训练营3 Kuriyama Mirai and Exclusive Or
  • 原文地址:https://www.cnblogs.com/liuquan/p/7228790.html
Copyright © 2020-2023  润新知