Laravel 在“存储/日志”中没有现有目录

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/52958681/
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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-14 18:08:01  来源:igfitidea点击:

Laravel No Existing Directory at "storage/logs"

phplaraveldockerlaravel-5.7

提问by Anastasia

I want to run a Laravel 5.7 application with Docker. My containers start OK but when I try to run the app in the browser I get an error.

我想用 Docker 运行 Laravel 5.7 应用程序。我的容器启动正常,但是当我尝试在浏览器中运行该应用程序时出现错误。

There is no existing directory at "/Users/user/projects/laravel/application/storage/logs" and its not buildable: Permission denied

“/Users/user/projects/laravel/application/storage/logs”中没有现有目录,并且无法构建:权限被拒绝

I changed permissions for the whole project with...

我更改了整个项目的权限...

sudo chmod -R 777 /Users/user/projects/laravel/application

However, nothing changed. How else can this issue be solved?

然而,一切都没有改变。这个问题还能怎么解决?

Here is docker-compose.xml file

这是 docker-compose.xml 文件

version: '3'
services:
  web:
    image: nginx
    volumes:
    - "./vhosts.conf:/etc/nginx/conf.d/vhosts.conf"
    - "./application/public:/var/www/html/application/public"
    - "./:/var/www/html"
    - "./logs/nginx/error.log:/var/log/nginx/error.log"
    - "./logs/nginx/access.log:/var/log/nginx/access.log"
    ports:
    - "8000:80"
    environment:
    - NGINX_HOST=ld2.web
    restart: always
    depends_on:
    - php
  php:
    image: php:7.2-fpm
    restart: always
    volumes:
    - "./application/storage/php/php.ini:/usr/local/etc/php/conf.d/php.ini"
    - "./application/public:/var/www/html/application/public"
    - "./:/var/www/html"

Here is an output of ls -ls application

这是ls -ls 应用程序的输出

drwxrwxrwx  26 user  staff     832 Oct 24 14:50 .
drwxrwxrwx   8 user  staff     256 Oct 24 01:06 ..
-rwxrwxrwx   1 user  staff     213 Sep  4 16:12 .editorconfig
-rwxrwxrwx   1 user  staff     704 Oct 24 00:38 .env
-rwxrwxrwx   1 user  staff     655 Sep  4 16:12 .env.example
-rwxrwxrwx   1 user  staff     111 Sep  4 16:12 .gitattributes
-rwxrwxrwx   1 user  staff     177 Sep  4 16:12 .gitignore
drwxrwxrwx   7 user  staff     224 Sep  4 16:12 app
-rw-r--r--   1 user  staff       0 Oct 24 14:56 application.txt
-rwxrwxrwx   1 user  staff    1686 Sep  4 16:12 artisan
drwxrwxrwx   4 user  staff     128 Sep  4 16:12 bootstrap
-rwxrwxrwx   1 user  staff    1527 Sep  4 16:12 composer.json
-rwxrwxrwx   1 user  staff  148959 Oct 24 00:35 composer.lock
drwxrwxrwx  15 user  staff     480 Sep  4 16:12 config
drwxrwxrwx   6 user  staff     192 Sep  4 16:12 database
-rwxrwxrwx   1 user  staff    1022 Sep  4 16:12 package.json
-rwxrwxrwx   1 user  staff    1134 Sep  4 16:12 phpunit.xml
drwxrwxrwx  10 user  staff     320 Sep  4 16:12 public
-rwxrwxrwx   1 user  staff    3924 Sep  4 16:12 readme.md
drwxrwxrwx   6 user  staff     192 Sep  4 16:12 resources
drwxrwxrwx   6 user  staff     192 Sep  4 16:12 routes
-rwxrwxrwx   1 user  staff     563 Sep  4 16:12 server.php
drwxrwxrwx   6 user  staff     192 Oct 24 01:20 storage
drwxrwxrwx   6 user  staff     192 Sep  4 16:12 tests
drwxrwxrwx  40 user  staff    1280 Oct 24 00:41 vendor
-rwxrwxrwx   1 user  staff     537 Sep  4 16:12 webpack.mix.js

ls -la application/storage

ls -la 应用程序/存储

drwxrwxrwx   6 user  staff  192 Oct 24 01:20 .
drwxrwxrwx  27 user  staff  864 Oct 24 15:44 ..
drwxrwxrwx   4 user  staff  128 Sep  4 16:12 app
drwxrwxrwx   7 user  staff  224 Sep  4 16:12 framework
drwxrwxrwx   2 user  staff   64 Oct 24 01:20 logs
drwxrwxrwx   3 user  staff   96 Oct 24 00:43 php

回答by Alexey

Seems that your APP_LOG_FILE in the config references the logfile path for your host machine (i.e. /Users/user/projects/laravel/application/storage/logs) and set as absolute path, but inside your containter the path is different and in fact is /var/www/html/application/storage/logs. Can you change it in the .env and try again?

似乎您在配置中的 APP_LOG_FILE 引用了主机的日志文件路径(即/Users/user/projects/laravel/application/storage/logs)并设置为绝对路径,但在您的容器中,路径是不同的,实际上是/var/www/html/application/storage/logs. 您可以在 .env 中更改它并重试吗?

回答by Satendra Rawat

Try this command,

试试这个命令,

php artisan optimize:clear

If php artisan gives error then execute,

如果 php artisan 报错,则执行,

composer update

回答by user2991379

You need execute php artisan config:cachecommand in container folder instead of your OS folder.
Enter in your php container:
docker exec -it your-php-container /bin/bash
go to laravel project folder and configure cache:
php artisan config:cache

您需要php artisan config:cache在容器文件夹而不是操作系统文件夹中执行命令。
进入你的 php 容器:
docker exec -it your-php-container /bin/bash
转到 laravel 项目文件夹并配置缓存:
php artisan config:cache