【发布时间】:2019-10-08 09:04:04
【问题描述】:
我正在尝试为 PHP 服务设置 Dockerfile。 PHP 脚本是在 docker 容器中使用 Nginx 服务器提供的,但它给了我 vendor/autoload.php not found 错误。
我已尝试多次更改 Dockerfile,但 vendor/autoload.php 错误仍然存在。
这是 Dockerfile
FROM composer as builder
RUN mkdir -p /usr/app/php-services
WORKDIR /usr/app/php-services
#copy composer file
COPY composer.json .
RUN composer install
#copy php-scripts to /usr/app/php-services
COPY . .
FROM nginx:alpine
COPY --from=builder /usr/app/php-services /usr/app/php-services
COPY ./phpdocker/nginx/nginx.conf /etc/nginx/conf.d/default.conf
#check if vendor has autoload file and it exists!!!
RUN ls /usr/app/php-services/vendor
EXPOSE 8000
脚本应该可以正常运行,但每当我运行 docker logs 时,它都会显示。
这是 nginx.conf 文件
server {
listen 8000;
access_log /var/log/nginx/application.access.log;
root /usr/app/php-services;
location / {
try_files $uri /index.php$is_args$args;
}
location ~ \.php$ {
fastcgi_pass php-fpm:9000;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param PHP_VALUE "error_log=/var/log/nginx/application_php_errors.log";
fastcgi_buffers 16 16k;
fastcgi_buffer_size 32k;
include fastcgi_params;
}
}
我几乎尝试了所有方法,但实际上不知道为什么会发生这种情况。我在这里做错了什么?我的 nginx.conf 文件有问题吗?
【问题讨论】:
标签: php docker nginx composer-php dockerfile