由于之前学习用的都是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不得不说的故事
原文地址:https://www.cnblogs.com/laijinquan/p/9208166.html