zoukankan      html  css  js  c++  java
  • MAMP(MAC php集成环境)thinkphp5 nginx 配置(fastadmin配置)

    thinkphp5的 nginx 配置,官方文档参考: http://static.kancloud.cn/manual/thinkphp5/177576

    fastadmin的 nginx 配置,官方文档参考:https://doc.fastadmin.net/doc/faq.html

    server {
            listen       80;
            server_name  www.fa.com *.fa.com;
            root   "C:/phpstudy/WWW/fastadmin/public";
            location / {
                index  index.html index.htm index.php;
                #主要是这一段一定要确保存在
                if (!-e $request_filename) {
                    rewrite  ^(.*)$  /index.php?s=/$1  last;
                    break;
                }
                #结束
                #autoindex  on;
            }
            location ~ .php(.*)$ {
                fastcgi_pass   127.0.0.1:9000;
                fastcgi_index  index.php;
                fastcgi_split_path_info  ^((?U).+.php)(/?.+)$;
                fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
                fastcgi_param  PATH_INFO  $fastcgi_path_info;
                fastcgi_param  PATH_TRANSLATED  $document_root$fastcgi_path_info;
                include        fastcgi_params;
            }
    }

    使用MAMP PRO配置的时候, 可以将location /规则添加到nginx的第一个文本框。

    #主要是这一段一定要确保存在
                if (!-e $request_filename) {
                    rewrite  ^(.*)$  /index.php?s=/$1  last;
                    break;
                }

    第二段location是匹配的伪静态规则,需要修改对应的nginx配置。

    如果直接添加到nginx配置界面的server部分,则会被追加到末尾,这就造成该规则不起作用

    这里的server 额外添加的规则应该是解析静态资源目录的规则,如下:

    location @rewrite {
            set $static 0;
            if  ($uri ~ .(css|js|jpg|jpeg|png|gif|ico|woff|eot|svg|css.map|min.map|mp3|wav|m4a)$) {
                set $static 1;
            }
            if ($static = 0) {
                rewrite ^/(.*)$ /index.php?s=/$1;
            }
        }

    下面才是真正修改伪静态规则的方法:

    打开MAMP PRO ,菜单栏的 File -> Edit Template -> nginx, 修改大约196行开始,注释掉原来的 php解析规则,更改为:

    location ~ .php(.*)$ {
                fastcgi_pass   127.0.0.1:9000;
                fastcgi_index  index.php;
                fastcgi_split_path_info  ^((?U).+.php)(/?.+)$;
                fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
                fastcgi_param  PATH_INFO  $fastcgi_path_info;
                fastcgi_param  PATH_TRANSLATED  $document_root$fastcgi_path_info;
                include        fastcgi_params;
            }

    保存,并重启nginx即可生效。

  • 相关阅读:
    Elasticsearch 索引文档如何使用自动生成 Id?
    Spring Boot 缓存 知识点
    table的各种用法
    Spring Boot 整合 Elasticsearch
    Spring Boot 集成 Kafka
    Spring Boot 2实现分布式锁——这才是实现分布式锁的正确姿势!
    Spring Cloud 与 Spring Boot 版本兼容关系
    Spring Boot 之:Spring Boot Admin
    JVM 性能调优工具
    Spring Boot 之:Actuator 监控
  • 原文地址:https://www.cnblogs.com/aleafo/p/13402476.html
Copyright © 2011-2022 走看看