file_put_contents无法打开流:无此文件或目录,安装

时间:2019-01-08 11:09:18

标签: php laravel

我从bitbuket克隆了一个laravel项目。还运行所有必要的命令以获取所有供应商文件,例如:

composer dump-autoload
composer install
php artisan cache:clear
php artisan clear-compiled

还删除了文件/public_html/bootstrap/cache/config.php

但是尝试启动项目时出现以下错误:

  

file_put_contents(C:\ xampp \ htdocs \ laravelstart \ storage \ framework / sessions / sRPb1A6BKrshhH8HPAR2fXVEcCH4daYCLxgo4b8M):   打开流失败:没有这样的文件或目录

7 个答案:

答案 0 :(得分:0)

请尝试以下命令:php artisan config:cache将清除项目的配置缓存。问题可能是您克隆了它,并且没有为新服务器准备配置:)

答案 1 :(得分:0)

rm -rf bootstrap / cache / config.php(删除)

php artisan config:cache

答案 2 :(得分:0)

如果清理缓存不起作用(例如,当您在docker下运行时可能会发生),请再次尝试chmod 755 storage bootstrap/cache。对我有用

答案 3 :(得分:0)

cd到您的/storage/framework/cache/data/storage/framework/sessionsframework文件夹中的任何目录,然后键入ls -la,您可能会看到类似以下内容的信息:

drwxr-sr-x  3 apache   apache   16 Oct 16 13:00 bd
drwxr-sr-x  3 apache   apache   16 Oct 16 17:38 be
drwxr-sr-x  3 root     apache   16 Oct 17 05:00 bf
drwxr-sr-x  3 apache   apache   16 Oct 16 13:07 c6
drwxr-sr-x  3 root     apache   16 Oct 16 16:15 d3
drwxr-sr-x  3 apache   apache   16 Oct 17 12:32 dd
drwxr-sr-x  3 apache   apache   16 Oct 17 12:32 e2
drwxr-sr-x  3 root     apache   16 Oct 16 16:00 e9
drwxr-sr-x  3 apache   apache   16 Oct 16 21:25 f6
drwxr-sr-x  3 apache   apache   16 Oct 16 16:56 f8
drwxr-sr-x  4 apache   apache   26 Oct 17 06:00 fa

如您所见,某些目录归root所有,可以将此cd修复到storage目录中并运行:

(首先检查您需要哪个user:group,对于AWS可能是ec2-user:apache):

sudo chmod 2775 . && sudo chown -R apache:apache . && sudo chmod -R og-r . && sudo find . -type d -exec chmod g=rwxs "{}" \; && sudo find . -type f -exec chmod g=rw  "{}" \; && sudo setfacl -d -m g::rwx . && sudo setfacl -d -m o::rx .

每次您从存储库中推送更改时,您可能希望将此包含在部署脚本中。

答案 4 :(得分:0)

转到目录 laravel/bootstrap/cache 并删除 config.php 文件。

答案 5 :(得分:0)

你也可以试试这个,它对我有用php artisan optimize:clear

答案 6 :(得分:0)

我遇到了类似的问题,我的问题是文件名太长,您将文件命名为:C:\xampp\htdocs\laravelstart\storage\framework/sessions/sRPb1A6BKrshhH8HPAR2fXVEcCH4daYCLxgo4b8M

我建议: 尝试使用较短的名称。或者尝试将文件保存在没有路径的根目录中。或者检查您是否在路径中使用了正确的斜杠或使用了较短的路径,在我的情况下,我使用了这个:file_put_contents('./storage/pdfs/file.jpg');

相关问题