tiger-sms ChatGPT 账号/ChatGPT 代注册 OpenAI API 代充值

ThinkPHP 显示 Failed opening required ‘/home/wwwroot/xxxxxx/public/../thinkphp/start.php’ (include_path=’.:/usr/local/php/lib/php’) in /home/wwwroot/xxxxxx/public/index.php on line 17 错误的解决办法

OpenAI API key

今天在添加一个基于 ThinkPHP5 的网站程序时,访问首页时遇到了一个错误:

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

Warning: require(/home/wwwroot/xxxxxx/thinkphp/start.php): failed to open stream: Operation not permitted in /home/wwwroot/xxxxxx/public/index.php on line 17

Fatal error: require(): Failed opening required ‘/home/wwwroot/xxxxxx/public/../thinkphp/start.php’ (include_path=’.:/usr/local/php/lib/php’) in /home/wwwroot/xxxxxx/public/index.php on line 17

开发环境:

  1. PHP 版本:PHP7
  2. 安装方式:LNMP 一键包:Linux 一键安装 Nginx + MySQL + PHP 环境

问题原因:open_basedir 里没有包含到 public 这个路径。

解决办法:在 /usr/local/nginx/conf/ 目录在找到 fastcgi.conf,关于 open_basedir 默认的配置应该是:

fastcgi_param PHP_ADMIN_VALUE "open_basedir=$document_root/:/tmp/:/proc/";

修改成:

fastcgi_param PHP_ADMIN_VALUE "open_basedir=/home/wwwroot/:/tmp/:/proc/";

之后重启 LNMP,再访问网站就没有这个问题了,最后记得将 PHP 调试模式关闭。

赞(7)
关注我们
未经允许不得转载:老王博客 » ThinkPHP 显示 Failed opening required ‘/home/wwwroot/xxxxxx/public/../thinkphp/start.php’ (include_path=’.:/usr/local/php/lib/php’) in /home/wwwroot/xxxxxx/public/index.php on line 17 错误的解决办法