简体   繁体   English

运行 Artisan 命令时记录目录权限被拒绝错误

[英]Logs directory permission denied error when running Artisan commands

I have a setup of docker with laravel and apache alongside mysql, when trying to run artisan command in the terminal of vscode i get :我在 mysql 旁边设置了带有 laravel 和 apache 的 docker,当我尝试在 vscode 的终端中运行 artisan 命令时,我得到:

There is no existing directory at "/var/www/html/storage/logs" and its not buildable: Permission denied “/var/www/html/storage/logs”中没有现有目录,并且无法构建:权限被拒绝

Apache setup in docker compose: docker compose 中的 Apache 设置:
 laravel-app: build: context: ./docker/app args: uid: ${UID} container_name: laravel-app environment: - APACHE_RUN_USER=#${UID} - APACHE_RUN_GROUP=#${UID} volumes: - .:/var/www/html ports: - ${HOST_PORT}:80 networks: backend: aliases: - laravel-app
Dockerfile of apache Apache 的 Dockerfile
 FROM php:7.2-apache RUN apt-get update # 1. development packages RUN apt-get install -y \\ git \\ zip \\ curl \\ sudo \\ unzip \\ libicu-dev \\ libbz2-dev \\ libpng-dev \\ libjpeg-dev \\ libmcrypt-dev \\ libreadline-dev \\ libfreetype6-dev \\ g++ # 2. apache configs + document root ENV APACHE_DOCUMENT_ROOT=/var/www/html/public RUN sed -ri -e 's!/var/www/html!${APACHE_DOCUMENT_ROOT}!g' /etc/apache2/sites-available/*.conf RUN sed -ri -e 's!/var/www/!${APACHE_DOCUMENT_ROOT}!g' /etc/apache2/apache2.conf /etc/apache2/conf-available/*.conf # 3. mod_rewrite for URL rewrite and mod_headers for .htaccess extra headers like Access-Control-Allow-Origin- RUN a2enmod rewrite headers # 4. start with base php config, then add extensions RUN mv "$PHP_INI_DIR/php.ini-development" "$PHP_INI_DIR/php.ini" RUN docker-php-ext-install \\ bz2 \\ intl \\ iconv \\ bcmath \\ opcache \\ calendar \\ mbstring \\ pdo_mysql \\ zip # 5. composer COPY --from=composer:latest /usr/bin/composer /usr/bin/composer # 6. we need a user with the same UID/GID with host user # so when we execute CLI commands, all the host file's ownership remains intact # otherwise command from inside container will create root-owned files and directories ARG uid RUN useradd -G www-data,root -u $uid -d /home/devuser devuser RUN mkdir -p /home/devuser/.composer && \\ chown -R devuser:devuser /home/devuser

even though the directory exists, also the commands run successfully from within the container.即使目录存在,命令也会从容器内成功运行。 Should i always run the commands related to laravel artisan from the container, or there is something wrong?我应该总是从容器运行与 laravel artisan 相关的命令,还是有什么问题?

转到您的项目文件夹并打开终端,然后运行此命令

sudo chmod -R 775 storage

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM