php的解析别名,配置nginx下别名alias支持PHP fastcgi解析

1)参看如下连篇文章:

Nginx设置alias实现虚拟目录 alias与root的用法区别

http://down.chinaz.com/server/201111/1382_1.htm

Nginx下alias支持PHP的问题

http://i.laoer.com/nginx-alias-php.html

2)我的环境是:web根目录在 /var/www/html/中,但是我要加上一个类似于apache的别名目录 /bbs ,此目录不在 web根目录中。

我的配置文件如下:

server {

listen       80;

server_name    localhost;

default_type text/plain;

location / {

root    /var/www/html;

index    index.php index.htm index.html;

}

location = /extension/sub {

set $push_channel_id $arg_exten;

push_subscriber long-poll;

push_subscriber_concurrency broadcast;

push_channel_group broadcast;

default_type text/plain;

#default_type text/html;

}

location = /extension/pub {

set $push_channel_id $arg_exten;

push_publisher;

push_min_message_buffer_length 0;

push_max_message_buffer_length 0;

push_message_timeout 1h;

push_channel_group broadcast;

default_type text/plain;

#default_type text/html;

}

location /bbs {

alias /opt/bbs/;

index index.html index.htm index.php;

}

location ~ ^/bbs/.+\.php$ {

fastcgi_pass   127.0.0.1:9000;

fastcgi_index  index.php;

fastcgi_param SCRIPT_FILENAME /opt$fastcgi_script_name;

include        fastcgi_params;

#include fastcgi.conf;

}

location ~ \.php$ {

fastcgi_pass   127.0.0.1:9000;

fastcgi_index  index.php;

fastcgi_param  SCRIPT_FILENAME  /var/www/html$fastcgi_script_name;

include        fastcgi_params;

#include fastcgi.conf;

}

}

说明: 上面这个就是成功的例子。但是又如下几点需要注意:

1)location ~ \.php$ {}  段,必须放在 location ~ ^/bbs/.+\.php$ {} 段后面,否则/bbs/的url打不开

2) location ~ ^/bbs/.+\.php$ {} 里面也可以写成如下:

location ~ ^/bbs/.+\.php$ {

root /opt;

fastcgi_pass   127.0.0.1:9000;

fastcgi_index  index.php;

fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;

include        fastcgi_params;

}

也就是用 变量名 $document_root 代替 /opt; 其实每个 location {}中的 $document_root 都是局部变量,都是在本段配置 root指令指定的路径。

以上配置完全可以通过nginx的第3放插件 echo 模块来得到验证,方法如下:

location /echo {

root /etc/asterisk;

#echo "$document_root";

echo "$fastcgi_script_name";

}

Nginx目录别名(Alias)支持PHP的配置

需求:通过 example.com 访问 /var/data/www,但通过 example.com/pa 访问的却是 /var/data/phpmyadmin,即保护phpmyadmin不暴露在ww ...

Ubuntu配置Nginx虚拟主机和支持ThinkPHP

[Nginx配置虚拟主机] 每一个 server { listen       80;         server_name  www.a.com; ..... } 就表示一台虚拟域名, 然后对应的 ...

CentOS 下用的是lnmp 的包配置Nginx 下的CI伪静态(搞爽了)

server { listen ; server_name cy.com; index index.html index.htm index.php default.html default.htm ...

linux下别名alias的设置

我有一个常用目录/volumes/mac/www’,每次都要输入这么长的路径,麻烦,所以有了以下配置 1.vi ~/.bash_profile 2.按住shift + i进入编辑状态 3.插入 ali ...

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

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

Linux上配置Nginx+PHP5(FastCGI)

原为地址:http://www.laruence.com/2009/07/28/1030.html Nginx是俄罗斯人编写的十分轻量级的HTTP服务器,以事件驱动的方式编写,所以有非常好的性能,同时 ...

【解决】nginx 下$_SERVER['PATH_INFO'] 无法获取到内容

Apache是模块加载文件的,默认支持$_SERVER['PATH_INFO'] : 而对于Nginx下, 是不支持PATH INFO的, 也就是它不会默认设置PATH_INFO. 而因为Nginx默 ...

Nginx下配置ThinkPHP的URL Rewrite模式和pathinfo模式支持

前面有关于lnmp环境的搭建,在此就不在赘述.下面就简述thinkPHP如何在nginx下开启url_rewrite和pathinfo模式支持 主要有两个步骤: 一.更改php.ini将;cgi.fi ...

centos下配置nginx支持php

添加nginx 默认主页index.php vim .../etc/nginx/conf.d/default.conf location / { root   /usr/share/nginx/htm ...

随机推荐

iOS打开百度地图、高德地图导航

1.判断手机里是否已经安装了百度地图或者高德地图: BOOL hasBaiduMap = NO; BOOL hasGaodeMap = NO; if ([[UIApplication sharedAp ...

WPF-TxtBox控件利用KeyDown来控制键盘输入

private void TextBox_PreviewKeyDown(object sender, KeyEventArgs e)        {            TextBox txt = ...

原生javascript添加引用js文件

function addScriptTag(src) {                         var script = document.createElement(&qu ...

UESTC_One Step Two Steps CDOJ 1027

As we all know,the handsome boy, Zcat, has a fever of flat shoes. He sings it on the class, in the d ...

集群下Cookie共享,必须要设置machineKey

这个节允许你设置用于加密数据和创建数字签名的服务器特定的密钥.ASP.NET自动使用它来保护表单验证Cookie,你也可以将它用于受保护的视图状态数据.同时,这个密钥还用于验证进程外的会话状态提供程序 ...

kindeditor修改图片上传路径-使用webapi上传图片到图片服务器

kindeditor是一个非常好用的富文本编辑器,它的简单使用我就不再介绍了. 在这里我着重介绍一些使用kindeditor修改图片上传路径并通过webapi上传图片到图片服务器的方案. 因为我使用的 ...

Jmeter察看结果树的响应数据中的中文显示乱码问题处理

1.Jmeter的察看结果树的响应数据有中文时会显示乱码,如图,我访问百度HTTP请求,响应数据中的title处是一串乱码 2.我们需要改一个设置,打开jmeter\bin\jmeter.proper ...

ROS探索总结(十六)——HRMRP机器人的设计

1. HRMRP简介         HRMRP(Hybrid Real-time Mobile Robot Platform,混合实时移动机器人平台)机器人是我在校期间和实验室的其他小伙伴一起从零开 ...

前端异步技术之Promise

前言 从事前端的朋友或多或少的接触过Promise,当代码中回调函数层级过多你就会发现Promise异步编程的魅力,相信此文一定能帮你排忧解惑! Promise概念 Promise是JS异步编程中的重 ...

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值