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;

    }

  • 相关阅读:
    那些年搞不懂的多线程、同步异步及阻塞和非阻塞(一)---多线程简介
    java中IO流详细解释
    Java IO流学习总结
    MySQL数据库中索引的数据结构是什么?(B树和B+树的区别)
    使用Redis存储Nginx+Tomcat负载均衡集群的Session
    Redis 3.2.4集群搭建
    JDK1.8源码分析之HashMap
    java HashMap和LinkedHashMap区别
    Java中原子类的实现
    多线程-传统定时任务
  • 原文地址:https://www.cnblogs.com/fanshehu/p/11904475.html
Copyright © 2011-2022 走看看