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;

    }

  • 相关阅读:
    Working with the RadioButton and CheclBox controls
    Simple Data Binding in Silverlight 4.0
    Data Binding in Silverlight 4.0
    Building a Simple DataGrid in Silverlight 4.0
    EXCEL数据导入SQL Server数据库中
    正则表达式必知必会
    Eclipse插件一次copy多个文件的相对路径路径
    走出软件作坊
    写在前面的话
    [转载]有经验的Java开发者和架构师容易犯的10个错误
  • 原文地址:https://www.cnblogs.com/fanshehu/p/11904475.html
Copyright © 2011-2022 走看看