打开php.ini的错误显示:display_error=on
,查看到如下错误
Warning: require(): open_basedir restriction in effect. File(/opt/yii-app/vendor/autoload.php) is not within the allowed path(s): (/opt/yii-app/api/web/:/tmp/:/proc/) in /opt/yii-app/api/web/index.php on line 5
Warning: require(/opt/yii-app/vendor/autoload.php): failed to open stream: Operation not permitted in /opt/yii-app/api/web/index.php on line 5
Fatal error: require(): Failed opening required '/opt/yii-app/api/web/../../vendor/autoload.php' (include_path='.:/usr/local/php/lib/php') in /opt/yii-app/api/web/index.php on line 5
将/usr/local/nginx/conf/fastcgi.cong
下面这段内容注释,否则require无法引入上级目录的文件
# PHP only, required if PHP was built with --enable-force-cgi-redirect
fastcgi_param REDIRECT_STATUS 200;
#fastcgi_param PHP_ADMIN_VALUE "open_basedir=$document_root/:/tmp/:/proc/";
参考:https://blog.csdn.net/weixin_41490929/article/details/79177916