Laravel 5.0 file_put_contents 错误
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/34725266/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Laravel 5.0 file_put_contents error
提问by Max
Just moved laravel project on hosting and it says:
刚刚在托管上移动了 laravel 项目,它说:
production.ERROR: exception 'ErrorException' with message 'file_put_contents(/Users/max/sites/evocate.dev/storage/framework/sessions/7f7df88c52734c34a3f89286dc74d517d446c4fd): failed to open stream: No such file or directory' in /home/f/fb7929gh/evocate2/vendor/compiled.php:6440
production.ERROR: 异常 'ErrorException' 带有消息 'file_put_contents(/Users/max/sites/evocate.dev/storage/framework/sessions/7f7df88c52734c34a3f89286dc74d517d446c4fd): 无法打开流: 没有这样的文件或目录/' fb7929gh/evocate2/vendor/compiled.php:6440
Why it takes my local host path and where can I fix this?
为什么它需要我的本地主机路径,我可以在哪里解决这个问题?
回答by Marcin Nabia?ek
You should make sure this directory exists and you have valid file permissions to this directory
您应该确保此目录存在并且您对该目录具有有效的文件权限
回答by Jijesh Cherrai
Make a directory sessions
with proper permission inside storage/framework
You can make directory using terminal command in Ubuntu:
在sessions
内部storage/framework
创建一个具有适当权限的目录您可以在 Ubuntu 中使用终端命令创建目录:
sudo mkdir storage/framework/sessions
Or you can create a directory directly inside project-root-folder/storage/framework/sessions
或者你可以直接在里面创建一个目录 project-root-folder/storage/framework/sessions
And also check **storage**
and **bootstrap**
have the full permission to write. 777
or 775
并且还检查**storage**
并**bootstrap**
拥有完全的写入权限。777
或者775
回答by Elisha Senoo
This issue is due to the Laravel Configuration Caching. You should typically run the
这个问题是由于Laravel 配置缓存。您通常应该运行
php artisan config:cache
php工匠配置:缓存
command as part of your production deployment routine. I suggest you
命令作为生产部署例程的一部分。我建议你
- Remove the configuration cache file
- Flush the application cache
- Create a cache file for faster configuration loading
- 删除配置缓存文件
- 刷新应用程序缓存
- 创建缓存文件以加快配置加载
To do this, run the following Artisan commands on your command line
为此,请在命令行上运行以下 Artisan 命令
- php artisan config:clear
- php artisan cache:clear
- php artisan config:cache
- php工匠配置:清除
- php artisan 缓存:清除
- php工匠配置:缓存
Where you don't have access to the command line on your server, you can programmatically execute commandslike this:
如果您无权访问服务器上的命令行,则可以通过编程方式执行如下命令:
Route::get('/clear-cache', function() {
$exitCode = Artisan::call('config:clear');
$exitCode = Artisan::call('cache:clear');
$exitCode = Artisan::call('config:cache');
return 'DONE'; //Return anything
});
I hope this is helpful.
我希望这是有帮助的。