Laravel 9安装报错

在CentOS7上使用Composer安装Laravel9后,遇到PHPopen_basedir限制错误,导致文件无法正常加载。在nginx配置中增加PHP_ADMIN_VALUE以解除限制,并重启nginx服务可解决问题。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

Laravel9 在centOS 7服务器中,通过composer安装后报错。
PHP版本:

PHP 8.0.28 (cli) (built: Jun 28 2023 14:20:44) ( NTS )
Copyright © The PHP Group
Zend Engine v4.0.28, Copyright © Zend Technologies

输入完命令

composer create-project laravel/laravel=9.* 项目名

配置完nginx配置之后,访问首页,报错了。报错内容如下

Warning: file_exists(): open_basedir restriction in effect. File(/www/wwwroot/default/aaaa/public/../storage/framework/maintenance.php) is not within the allowed path(s): (/www/wwwroot/default/aaaa/public/:/tmp/:/proc/) in /www/wwwroot/default/aaaa/public/index.php on line 19

Warning: require(): open_basedir restriction in effect. File(/www/wwwroot/default/aaaa/vendor/autoload.php) is not within the allowed path(s): (/www/wwwroot/default/aaaa/public/:/tmp/:/proc/) in /www/wwwroot/default/aaaa/public/index.php on line 34

Warning: require(/www/wwwroot/default/aaaa/vendor/autoload.php): Failed to open stream: Operation not permitted in /www/wwwroot/default/aaaa/public/index.php on line 34

Fatal error: Uncaught Error: Failed opening required '/www/wwwroot/default/aaaa/public/../vendor/autoload.php' (include_path='.:/usr/local/php/lib/php') in /www/wwwroot/default/aaaa/public/index.php:34 Stack trace: #0 {main} thrown in /www/wwwroot/default/aaaa/public/index.php on line 34

解决方案

1.查看php.ini中的open_basedir是否已经注释,没有注释就加个“;”注释一下
2.vim fastcgi.conf

fastcgi_param PHP_ADMIN_VALUE "open_basedir=$document_root/:/tmp/:/proc/:/www/wwwroot/default/项目地址不用写到public";

重启nginx生效。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值