码迷,mamicode.com
首页 > Web开发 > 详细

thinkphp5和nginx不得不说的故事

时间:2018-06-21 13:34:46      阅读:234      评论:0      收藏:0      [点我收藏+]

标签:系统   server   部署   include   autoindex   article   fast   ast   inux   

由于之前学习用的都是apsche,所以对ngnix一窍不通,在这里写给正在学习的同行,希望可以帮助到你们:

如果你不会用apache部署tp5的可以查看我之前发布的文章,里面有提到

phpstudy

参考:https://blog.csdn.net/qq_33862644/article/details/78174041

你切换ngnix之后,你只能访问tp5的首页,这时候点击其他事不能访问的到的,会报403错误,是因为你的pathinfo没有设置,这时候就需要伪静态了。

在“打开配置文件”中找到vhsts.conf,打开,然后配置伪静态的代码:

server {
        listen       80;
        server_name  www.bicktp.com bicktp.com;
        root   "E:\wamp\www\bick\public";
        location / {
            index  index.html index.htm index.php;
            autoindex  on;
            #伪静态配置
            if (!-e $request_filename){
           rewrite  ^(.*)$  /index.php?s=$1  last;  
                break;
         }
        }
        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;
        }
}

我有写注释的,你自己看着写吧。

 技术分享图片

 

 

 

 

 

然后在linux系统上部署也是一样的。

参考:https://www.cnblogs.com/fangziffff123/p/7588782.html

我用最原始的方法自己写不知道为什么运行不了,可能是某些代码缺失了吧,所以我是了第三方工具帮我配置->宝塔面板

技术分享图片

 

 

技术分享图片

技术分享图片

 那个配置文件基本不用谢,只写伪静态就可以了!!!

thinkphp5和nginx不得不说的故事

标签:系统   server   部署   include   autoindex   article   fast   ast   inux   

原文地址:https://www.cnblogs.com/laijinquan/p/9208166.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!