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 访问不通目录下的数据
nginx虚拟目录实现两个后台使用的更多相关文章
- Nginx 虚拟目录和虚拟主机的配置
nginx.conf 配置文件的几个常用命令 nginx 配置文件主要分为六个区域: main: 全局设置 events: nginx工作模式 http: http设置 sever: 主机设置 loc ...
- Nginx虚拟目录alias和root目录
nginx是通过alias设置虚拟目录,在nginx的配置中,alias目录和root目录是有区别的:1)alias指定的目录是准确的,即location匹配访问的path目录下的文件直接是在alia ...
- nginx“虚拟目录”不支持php的解决办法
这几天在配置Nginx,PHP用FastCGI,想装一个phpMyAdmin管理数据库,phpMyAdmin不想放在网站根目录 下,这样不容易和网站应用混在一起,这样phpMyAdmin的目录就放在别 ...
- Nginx虚拟目录设置
location ~ .*\.html$ 匹配所有以.html结尾的链接 --------------------------------------------------------- 关于a ...
- Nginx虚拟目录(alias)和根目录(root)
功能要求: 假设nginx配置的域名是www.kazihuo.com,现有静态资源/home/www/oye目录需要通过nginx访问. 功能实现: 前提要求: 1.在nginx.conf中到处第二行 ...
- [转]nginx虚拟目录(alias与root的区别)
今天配置awstats,awstats创建出的文件目录在/home/awstats下,在nginx中加入配置后狂报404,发现还是忽略了root和alias的区别,特将修改配置记录如下: 1.失败:s ...
- Nginx虚拟目录支持PHP配置
感谢作者:http://blog.csdn.net/fangaoxin/article/details/7030139 location ~ ^/test/.+\.php$ { alias /var/ ...
- nginx虚拟目录配置
参考文章:https://blog.csdn.net/whatday/article/details/50649461 1. location ~ ^/awstats/ { root /home/aw ...
- 配置nginx虚拟目录配置文件支持tp的pathinfo
lnmp自带的包不好用, 经测试,在相应的conf文件加入这句话即可: location / { if (!-e $request_filename) { rewrite ^(.*)$ /index. ...
随机推荐
- 『C++』Temp_2018_12_26
#include <iostream> #include <string> #include <array> using namespace std; class ...
- Linux系统结构 详解(转)
Linux系统一般有4个主要部分: 内核.shell.文件系统和应用程序.内核.shell和文件系统一起形成了基本的操作系统结构,它们使得用户可以运行程序.管理文件并使用系统.部分层次结构如图1-1所 ...
- 剑指Offer-迭代
1.大家都知道斐波那契数列,现在要求输入一个整数n,请你输出斐波那契数列的第n项(从0开始,第0项为0) 备注:斐波那契数列指的是这样一个数列从第3项开始,每一项都等于前两项之和. public st ...
- HDFS重要特性
首先,它是一个文件系统,用于存储文件,通过统一的命名空间目录树来定位文件: 其次,它是分布式的,由很多服务器联合起来实现其功能,集群中的服务器有各自的角色. 1. master/slave 架构 HD ...
- Python学习:7.文件操作
文件操作 我们曾将听过一个问题,将大象放入冰箱分为三步:1.打开冰箱门,2.将大象放进去,3.关上冰箱门.今天我们要讲的Python文件操作的步骤就像将大象放入冰箱的步骤一样. 使用Python操作文 ...
- 《TCP/IP详解 卷1:协议》系列分享专栏
<TCP/IP详解卷1:协议>是一本详细的TCP/IP协议指南,计算机网络历久不衰的经典著作之一. 作者理论联系实际,使读者可以轻松掌握TCP/IP的知识.阅读对象为计算机专业学生.教师以 ...
- E. Almost Regular Bracket Sequence
题目链接:http://codeforces.com/contest/1095/problem/E 解题心得: 刚开始拿到这个题的时候还真的没什么思路,后来仔细想想还是比较简单的.首先题目要求翻转一个 ...
- [SGU223]Little Kings(状压DP)
随便DP一下 Code #include <cstdio> int sta[150],cnt[150],tp,n,k; long long dp[12][144][150],Ans; in ...
- Prism for WPF 搭建一个简单的模块化开发框架(一)
原文:Prism for WPF 搭建一个简单的模块化开发框架(一) 最近闲来无事又想搞搞WPF..... 做个框架吧,可能又是半途而废....总是坚持不下来 不废话了, 先看一下工程结构 布局大概是 ...
- CC3200-LAUNCHXL驱动不能正常识别的问题
1. 本次使用利尔达的CC3200底板,完全兼容官方CC3200-LAUNCHXL,如果上电之后驱动识别为2路串口,是有问题的.原因是FT2232外接的EEPROM没有烧写固件. 2. 安装FT_Pr ...