zoukankan      html  css  js  c++  java
  • nginx+php的配置

    nginx+php的配置比较简单,核心就一句话----

    把请求的信息转发给9000端口的PHP进程,

    让PHP进程处理 指定目录下的PHP文件.

    如下例子:

    location ~ .php$ {
                //根目录
                root html;
                fastcgi_pass   127.0.0.1:9000;
                fastcgi_index  index.php;
                fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
                include        fastcgi_params;
            }

    1:碰到php文件,

    2: 把根目录定位到 html,

    3: 把请求上下文转交给9000端口PHP进程,

    4: 并告诉PHP进程,当前的脚本是 $document_root$fastcgi_scriptname

     

    配置nginx支持pathinfo,这样便能支持TP框架的/news/1这种请求

    location ~ .php(.*)$ {
                //根目录
                root html;
                fastcgi_pass   127.0.0.1:9000;
                fastcgi_index  index.php;
                fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
                fastcgi_param  PATH_INFO $1;
                include        fastcgi_params;
            }

     

     

    配置nginx重写(运用正则表达式)

    try_files方法实现重写

    是指,

    先试试 有没有 /goods/1/ 这个目录

    再试试 有没有 /goods/1 这个文件

    最后试试 /index.php?goods/1 这个URL

     

  • 相关阅读:
    1. 两数之和
    RabbitMQ主题交换机
    RabbitMQ路由
    RabbitMQ发布订阅
    RabbitMQ简介和安装
    55. 跳跃游戏
    63. 不同路径 II
    62. 不同路径
    6. Z 字形变换
    sql注入攻击与防御第一章(笔记)
  • 原文地址:https://www.cnblogs.com/lamp01/p/7400183.html
Copyright © 2011-2022 走看看