购买了阿里云机器,准备搭建一套备份的后台,由于资源有限所以将两个后台搭建到一组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  访问不通目录下的数据

nginx虚拟目录实现两个后台使用的更多相关文章

  1. Nginx 虚拟目录和虚拟主机的配置

    nginx.conf 配置文件的几个常用命令 nginx 配置文件主要分为六个区域: main: 全局设置 events: nginx工作模式 http: http设置 sever: 主机设置 loc ...

  2. Nginx虚拟目录alias和root目录

    nginx是通过alias设置虚拟目录,在nginx的配置中,alias目录和root目录是有区别的:1)alias指定的目录是准确的,即location匹配访问的path目录下的文件直接是在alia ...

  3. nginx“虚拟目录”不支持php的解决办法

    这几天在配置Nginx,PHP用FastCGI,想装一个phpMyAdmin管理数据库,phpMyAdmin不想放在网站根目录 下,这样不容易和网站应用混在一起,这样phpMyAdmin的目录就放在别 ...

  4. Nginx虚拟目录设置

    location ~ .*\.html$   匹配所有以.html结尾的链接 --------------------------------------------------------- 关于a ...

  5. Nginx虚拟目录(alias)和根目录(root)

    功能要求: 假设nginx配置的域名是www.kazihuo.com,现有静态资源/home/www/oye目录需要通过nginx访问. 功能实现: 前提要求: 1.在nginx.conf中到处第二行 ...

  6. [转]nginx虚拟目录(alias与root的区别)

    今天配置awstats,awstats创建出的文件目录在/home/awstats下,在nginx中加入配置后狂报404,发现还是忽略了root和alias的区别,特将修改配置记录如下: 1.失败:s ...

  7. Nginx虚拟目录支持PHP配置

    感谢作者:http://blog.csdn.net/fangaoxin/article/details/7030139 location ~ ^/test/.+\.php$ { alias /var/ ...

  8. nginx虚拟目录配置

    参考文章:https://blog.csdn.net/whatday/article/details/50649461 1. location ~ ^/awstats/ { root /home/aw ...

  9. 配置nginx虚拟目录配置文件支持tp的pathinfo

    lnmp自带的包不好用, 经测试,在相应的conf文件加入这句话即可: location / { if (!-e $request_filename) { rewrite ^(.*)$ /index. ...

随机推荐

  1. MYSQL命令简要笔记

    mysqldump "C:\Program Files\MySQL\MySQL Server 5.7\bin\mysqldump.exe"    --host=localhost ...

  2. jQuery DOM/属性/CSS操作

    jQuery DOM 操作 创建元素 只需要把DOM字符串传入$方法即可返回一个 jQuery 对象 var obj = $('<div class="test">&l ...

  3. PHP中如何对二维数组按某个键值进行排序

    $arr=[     array(         'name'=>'张三',         'age'=>28     ),     array(         'name'=> ...

  4. spark启动原理总结

    一般情况下,我们启动spark集群都是start-all.sh或者是先启动master(start-master.sh),然后在启动slave节点(start-slaves.sh),其实翻看start ...

  5. C# 截取屏幕图像

    #region 截取屏幕图像 private static Bitmap GetScreenCapture() { Rectangle tScreenRect = , , Screen.Primary ...

  6. linux之sed基础命令详解

    sed (Stream  EDitor)是一个强大的字符流编辑器,输入一般是来自文件,默认情况下不编辑原文件,仅对模式空间中的数据作处理;而后,将模式空间打印到屏幕显示 sed基础用法 sed [op ...

  7. 状压搜索 洛谷T47092 作业

    TYM 有 nn 本作业,编号为 1,\dots,n1,…,n. 由于 \mathrm{TYM}TYM 很喜欢偷懒,而且不喜欢消耗脑细胞,所以他选择跳着完成这 nn 本作业.此外,如果将做作业的顺序转 ...

  8. python中利用少量代码快速实现从类对象中抽取所需属性的一种实践

    项目中有可能会碰到这样一种场景: 根据一个id,查询得到和id对应的完整数据信息存储对象,比如书籍id到书籍详细信息,用户id到用户详细信息等,详细信息字段可能包括几十甚至上百个数据字段,真正需要返回 ...

  9. Netty示例

    一,服务端 ** * 测试Netty类库:服务端代码 * Created by LiuHuiChao on 2016/10/24. */ public class NettyServerTest { ...

  10. 新买的 SSD 固态硬盘竟然是坏的,我傻了啊!

    1. 今天早上上班路上在网上下单了一个 1 T 的 SSD 固态硬盘,晚上 7 点半左右送到手后迫不及待想替换掉原来的机械硬盘,在这个新硬盘上装系统,玩起来. 2. 拆开包装,先用移动硬盘接口检查下新 ...