zoukankan      html  css  js  c++  java
  • nginx上部署PHP

    环境:centos7  nginx1.16.1

    (1)先将tp源代码下载到nginx的站点目录下

    注意:存放tp的目录要有可执行权限,否则无法进入目录,访问报403

    (2)servr配置:

    server {
    listen 80;
    server_name www.fanshehu.xyz localhost;

    charset utf8;  

    access_log logs/host.access.log;

    root www/tp5/public;
    index index.php index.html index.htm; #如果请求是站点根目录,则显示这些页面

    location / {              #根目录,所有请求都能匹配到
      if (!-e $request_filename) {    #如果请求的不是一个文件或目录,则重写。否则请求是站点根目录或静态资源,nginx将静态资源以二进制流返回
        rewrite ^/(.*)$ /index.php/$1 last;
        break;
      }
    }
    location ~ .php {        #如果请求有.php
      root www/tp5/public;       
      fastcgi_pass 127.0.0.1:9000;    #交给php-fpm处理
      #fastcgi_index index.php;    #如果请求是网站根目录,则加上index.php在url后,此时$fastcgi_script_name等于index.php。在这里并不需要,可注释掉
      include fastcgi.conf;        #引入fastcgi.conf,里面有php-fpm需要的参数
      set $real_script_name $fastcgi_script_name;   # 
      if ($fastcgi_script_name ~ "^(.+?.php)(/.+)$") {
      set $real_script_name $1;
      set $path_info $2;
      }
      fastcgi_param SCRIPT_FILENAME $document_root$real_script_name;  #此时脚本
      fastcgi_param SCRIPT_NAME $real_script_name;
      fastcgi_param PATH_INFO $path_info;

    }

  • 相关阅读:
    webservice接口示例(spring+xfire+webservice)
    SoapUI 测试接口演示
    XML 文档结构必须从头至尾包含在同一个实体内
    Oracle url编码与解码
    【中山市选2010】【BZOJ2467】生成树
    synchronized与static synchronized 的差别、synchronized在JVM底层的实现原理及Java多线程锁理解
    自己动手写搜索引擎
    PopupWindow底部弹出
    JAVA集合类型(二)
    双卡手机发送短信
  • 原文地址:https://www.cnblogs.com/fanshehu/p/11904475.html
Copyright © 2011-2022 走看看