ThinkPhp框架搭建

根据官网说明https://www.kancloud.cn/manual/thinkphp5/118006

只需要下载一个版本,然后解压到服务器web应用的根目录即可

我的nginx配置的根目录是/home/wwwroot/default;

简单路径配置

    	server {
            listen       80;
            server_name 192.168.1.129;
            root  /home/wwwroot/default;


            location / {
                root /home/wwwroot/default;
                index  index.html index.htm index.php;

                if (!-e $request_filename) {
                    rewrite  ^(.*)$  /index.php?s=/$1  last;
                    break;
                }
            }


        }

浏览器中输入192.168.1.129/tp5/pulbic即可访问

包含其他设置的配置,关系不大

    	server {
            listen       80;
            server_name 192.168.1.129;
            root  /home/wwwroot/default;

            location ~ \.php{
                root           /home/wwwroot/default/tp5/public;#tp5是我新建的目录,thinkphp官网下载的zip文件解压到该目录
                fastcgi_pass   unix:/tmp/php-cgi.sock;#这个路径不同安装环境可能不一样,有的是unix:/dev/shm/phpcgi.sock;有的是unix:/run/php/php7.2-fpm.sock;
                fastcgi_index  index.php;
                fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
                include        fastcgi_params;
            }

            location / {
                root /home/wwwroot/default/tp5/public;
                index  index.html index.htm index.php;

                if (!-e $request_filename) {
                    rewrite  ^(.*)$  /index.php?s=/$1  last;
                    break;
                }
            }


        }

浏览器中输入192.168.1.129/tp5/pulbic发现识别不了,应该输入192.168.1.129即可,主要是root路径的不一样,这个看心情,或者看需求

排查问题:

application/config.php中show_error_msg的值设置为true,就可以看到具体的错误信息了,访问192.168.1.129/tp5/pulbic提示模块不存在:tp5就是路径不对,于是才知道是配置的问题

猜你喜欢

转载自blog.csdn.net/youyudexiaowangzi/article/details/87731887