gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-12-02 19:24:17 25 4
gpt4 key购买 nike

当尝试在vscode的终端中运行artisan命令时,我在mysql旁边安装了带有laravel和apache的docker,我得到了:

There is no existing directory at "/var/www/html/storage/logs" and its not buildable: Permission denied



Docker中的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

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

即使目录存在,命令也可以从容器内成功运行。我应该始终从容器中运行与laravel artisan相关的命令,还是出现问题?

最佳答案

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

sudo chmod -R 775 storage

关于laravel - 运行Artisan命令时记录目录权限被拒绝的错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57533540/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com