【发布时间】:2021-07-18 23:28:33
【问题描述】:
几乎一整天都在尝试修复此错误,但不知道可能导致此问题的原因。
我得到的错误是:UnexpectedValueException 无法以附加模式打开流或文件“/var/www/storage/logs/laravel.log”:无法打开流:权限被拒绝
以下是我的 docker-compose.yml、Dockerfile 和 conf.d 文件。
docker-compose.yml:
version: "3"
services:
app:
build:
context: .
dockerfile: Dockerfile
image: /laravelproject
container_name: app
restart: unless-stopped
volumes:
- ./:/var/www
- ./config/php/local.ini:/usr/local/etc/php/conf.d/local.ini
webserver:
build:
context: .
dockerfile: Dockerfile_Nginx
image: /nginx
container_name: webserver
restart: unless-stopped
ports:
- "8080:80"
volumes:
- ./:/var/www
- ./config/nginx/conf.d/:/etc/nginx/conf.d/
depends_on:
- app
Dockerfile:
FROM php:7.3-fpm-alpine
WORKDIR /var/www
RUN apk update && apk add \
build-base \
freetype-dev \
libjpeg-turbo-dev \
libpng-dev \
libzip-dev \
zip \
jpegoptim optipng pngquant gifsicle \
vim \
unzip \
git \
curl
RUN docker-php-ext-install pdo_mysql mbstring zip exif pcntl
RUN docker-php-ext-configure gd --with-gd --with-freetype-dir=/usr/include/ --with-jpeg-dir=/usr/include/ --with-png-dir=/usr/include/
RUN docker-php-ext-install gd
# copy config
COPY ./config/php/local.ini /usr/local/etc/php/conf.d/local.ini
RUN addgroup -g 1000 -S www && \
adduser -u 1000 -S www -G www
USER www
COPY --chown=www-data:www-data . /var/www
EXPOSE 9000
app.conf:
server{
listen 80;
index index.php index.html;
error_log /var/log/nginx/error.log;
access_log /var/log/nginx/access.log;
root /var/www/public;
location ~ \.php$ {
try_files $uri =404;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass app:9000;
fastcgi_index index.php;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param PATH_INFO $fastcgi_path_info;
}
location / {
try_files $uri $uri/ /index.php?$query_string;
gzip_static on;
}
}
我尝试了很多解决方案,但都没有奏效。
谢谢。
【问题讨论】:
-
安装 Laravel Sail