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. ...
随机推荐
- MySQL数据库修改数据表类型(引擎)的方法
MySQL数据库使用事务,相关数据表必须为InnoDB引擎 查看数据表状态: SHOW TABLE STATUS FROM wawa WHERE NAME='ww_invite_code_temp'; ...
- cut 的用法
cut 文件内容查看 显示行中的指定部分,删除文件中指定字段 显示文件的内容,类似于下的type命令. 说明 该命令有两项功能,其一是用来显示文件的内容,它依次读取由参数file所指明的文件,将它们的 ...
- jquery优化
选择器优化执行的速度 选择器 优先:id>元素>类 使用对象缓存:即使用变量来保存对象名,var $myDiv = $("#myDiv"):$myDiv.show(); ...
- Vue learning experience
一.内置指令[v-ref] Official-document-expression: 父组件在子组件上注册的索引,便于直接访问.不需要表达式,必须提供参数ID,可以通过父组件的$ref对象访问子组件 ...
- 高性能MySQL--innodb中事务的隔离级别与锁的关系
最近买了<高性能MySQL>这本书回来看,从中收益颇多!我来一吐为快! 我们都知道事务,那么在什么情况下我们需要使用事务呢? 银行应用是解释事务的一个经典例子.假设一个银行的数据库有两张表 ...
- operator.itemgetter() 字典列表排序
## 字典列表排序 students = [ {"name": "Stanley", "age": 22, "score" ...
- Hive(7)-基本查询语句
一. 表和数据准备 1. 数据地址 链接:https://pan.baidu.com/s/1crr8B9bD_0Phfm99vLCWjg 提取码:5jzw 2. 建表语句 create table ...
- 使用maven下载cdh版本的大数据jar包
在pom文件中添加 cloudera 配置文件 <repositories> <repository> <id>cloudera</id> <ur ...
- MySQL 5.7.21 免安装版配置教程
MySQL是世界上目前最流行的开源数据库.许多大厂的核心存储往往都是MySQL. 要安装MySQL,可以直接去官方网站下载.本教程将说明对于MySQL的免安装版如何进行配置和安装. 官方下载:http ...
- LCD驱动程序
学习目标:熟悉TFT LCD的概念,分层驱动工作原理和程序编写. 一.LCD 概念 1. 显示器数据组织格式 1)一幅图像成为一帧,每帧由多行组成,每行由多个像素组成.每个像素的颜色由若干位表示,对 ...