dongyi1996 2019-06-10 15:05
浏览 646
已采纳

Laravel 5.7无法加载`storage / framework / cache / data`并写入`./ storage / logs / laravel-2019-06-11.log`

I have a project under laravel 5.7 installation and for some reason I get the following error:

file_put_contents(/home/vagrant/code/storage/framework/cache/data/1c/6e/1c6ea8378a1030f85a05f4cb2262de1e2164efa6): failed to open stream: No such file or directory

In order to mitigate the error I tried the following:

  • Permission Based tries:
 chmod 777 -R storage
 chmod 0777 -R storage
  • artistan based attempts:
 php artisan cache:clear
 php artisan config:clear
 php artisan config:cache
 php artisan view:clear
  • php-fpm default user settings:
sudo chown -R $USER:www-data storage
sudo chown -R $USER:www-data bootstrap/cache

Also for the development I use vagrant with the following Vagrantfile located at the root of my project:

Vagrant.configure("2") do |config|

    config.vm.box = "ubuntu/xenial64"
    config.vm.box_version = "20180917.0.0"     
    config.vm.box_download_insecure = true

    config.vm.provider "virtualbox" do |vb|
        vb.name = "myapp-api"

        vb.memory = 2024
        vb.cpus = 1

        vb.customize [ "modifyvm", :id, "--uartmode1", "disconnected" ]
    end

    config.vm.network "private_network", ip: "192.168.10.111"
    config.vm.network "forwarded_port", guest: 80, host: 8888
    config.vm.network "forwarded_port", guest: 22, host: 2223

    config.vm.synced_folder "./.", "/home/vagrant/code"

    # Provision Scripts
end

But any of these failed to resolve the solution.

Edit 1

The folder framework/cache/data already exists as ls -l shows:

$ ls -l /home/vagrant/code/storage/framework/cache/ | grep data
drwxrwxr-x 1 vagrant vagrant 4096 Jun 11 10:46 data

By doing:

rm -rf storage/framework/cache
mkdir -p storage/framework/cache

Resulted to the following NEW error:

The stream or file "/home/vagrant/code/storage/logs/laravel-2019-06-11.log" could not be opened: failed to open stream: Permission denied

So in my investigation shows:

$ ls -l /home/vagrant/code/storage/logs
total 112
drwxrw-rw- 1 vagrant vagrant  4096 Jun 10 17:31 .
drwxr-xr-x 1 vagrant vagrant  4096 Jun 10 15:47 ..
-rwxrwxrwx 1 vagrant vagrant    14 Jun 10 15:47 .gitignore
-rwxrwxrwx 1 vagrant vagrant 96507 Jun 10 18:09 laravel-2019-06-10.log

Meaning it has more than enouch permissions to get written. I also run the following command:

$ ls -l /home/vagrant/code/storage/ | grep logs
drwxrw-rw- 1 vagrant vagrant 4096 Jun 10 17:31 logs

Meaning that still there are good enouch permissions in order for the laravel to write into the file. Still the error shows the opposite.

Furthermore I tried this one:

mv bootstrap/cache/config.php ~/

I also tried the following:

rm -rf storage/logs/*
./artisan cache:clear

And the problem still remains.

  • 写回答

2条回答 默认 最新

  • duanemei2194 2019-06-11 08:59
    关注

    The problem is that the code is running as www-data user. To fix tat you should make a custom php-fpm resource using the user and group named vagrant.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥20 腾讯企业邮箱邮件可以恢复么
  • ¥15 有人知道怎么将自己的迁移策略布到edgecloudsim上使用吗?
  • ¥15 错误 LNK2001 无法解析的外部符号
  • ¥50 安装pyaudiokits失败
  • ¥15 计组这些题应该咋做呀
  • ¥60 更换迈创SOL6M4AE卡的时候,驱动要重新装才能使用,怎么解决?
  • ¥15 让node服务器有自动加载文件的功能
  • ¥15 jmeter脚本回放有的是对的有的是错的
  • ¥15 r语言蛋白组学相关问题
  • ¥15 Python时间序列如何拟合疏系数模型