解决在ubuntu/debian上Warning: file_get_contents(): open_basedir restriction in effect报错

最近刚刚将服务器从CentOS切换到debian上,因为用的配置环境一模一样,代码也都是从原服务器上直接打包复制,但是突然遇到了程序在处理文件下载时,PHP报错:
Warning: file_get_contents(): open_basedir restriction in effect

在网上查了很多资料,都是说要更改php.ini文件的open_basedir,或者是将宝塔站点的防跨站攻击勾选项去掉。但是每一样都试过了,都不起作用,该报错仍然报错,后面仔细查看了报错信息,发现有这么一条:

file_get_contents(): open_basedir restriction in effect. File(/etc/pki/tls/certs/ca-bundle.crt) is not within the allowed path(s):

其中提示说 /etc/pki/tls/certs/ca-bundle.crt 没在可允许的路径下,赶紧找找看,这个文件到底是啥,结果一查,文件不存在,连路径都没有。

接着查资料,原来在ubantu、debian上,文件路径是 /etc/ssl/certs/ca-certificates.crt

马上先创建路径

mkdir -p /etc/pki/tls/certs/

再建立一个软链接

ln -s /etc/ssl/certs/ca-certificates.crt /etc/pki/tls/certs/ca-bundle.crt

查看一下,是不是成功

ls -l /etc/pki/tls/certs/ca-bundle.crt

显示结果:

/etc/pki/tls/certs/ca-bundle.crt -> /etc/ssl/certs/ca-certificates.crt

再试试程序,emmm....正常了~

你可能感兴趣的:(解决在ubuntu/debian上Warning: file_get_contents(): open_basedir restriction in effect报错)