学无先后,达者为师

网站首页 PHP其他 正文

tp5 base.php,宝塔面板中ThinkPHP5报错/public/../thinkphp/base.php

作者:PAN YAO 更新时间: 2022-02-03 PHP其他

今天在部署一个ThinkPHP5开发的网站时,把网站根目录指向到public目录下,结果运行后产生以下错误

Warning: require(): open_basedir restriction in effect. File(/www/wwwroot/xxx/thinkphp/start.php) is not within the allowed path(s): (/www/wwwroot/xxx/public/:/tmp/:/proc/) in /www/wwwroot/xxx/public/index.php on line 18

Warning: require(/www/wwwroot/xxx/thinkphp/start.php): failed to open stream: Operation not permitted in /www/wwwroot/xxx/public/index.php on line 18

Fatal error: require(): Failed opening required '/www/wwwroot/xxx/public/../thinkphp/start.php' (include_path='.:/www/server/php/70/lib/php') in /www/wwwroot/xxx/public/index.php on line 18

到宝塔面板的网站配置页面,发现有一个“防跨站攻击(open_basedir) 的选项”把该选项关闭即可。

51975fa06a8984eaf066386a682dbb76.png

原因如下:open_basedir 将PHP所能打开的文件限制在指定的目录树中,包括文件本身。当程序要使用例如fopen()或file_get_contents()打开一个文件时,这个文件的位置将会被检查。当文件在指定的目录树之外,程序将拒绝打开。

如果首页能打开了,内页打不开,设置一下伪静态为thinkphp试试

c573ecd1a59e4e29fcf3f1068cb95a06.png

原文链接:https://blog.csdn.net/weixin_42373103/article/details/116434340

栏目分类
最近更新