php - 在 Windows 上构建 Laravel 应用程序的 docker 镜像时未找到 000-default.conf

标签 php laravel docker apache

我正在尝试按照给定的教程使用 docker 镜像在 AWS 上部署我的 Laravel 应用程序:

https://medium.com/@okekedesmond/deploying-containerized-laravel-application-using-aws-ec2-instances-with-docker-and-rds-883e8f6d6245

在构建 docker 镜像时,我陷入了第一点。这是我的 Dockerfile:

#  Defining the base image for our project, if you understand how docker images and layers work, this should not be difficult to understand. 
FROM php:7.3-cli
# We need to update the  image and install some import packages
RUN apt-get update -y && apt-get install -y openssl zip unzip git curl libpng-dev libonig-dev libxml2-dev
# cleaning packages and install scripts
RUN apt-get clean && rm -rf /var/lib/apt/lists/*
# Installing composer which is used to install Laravel
RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin –filename=composer
#Creating a configuration file for apache and linking
ADD 000-default.conf /etc/apache2/sites-available/
RUN ln -sf /etc/apache2/sites-available/000-default.conf /etc/apache2/sites-enabled/000-default.conf 

#Restarting Apache
RUN a2enmod rewrite
RUN service apache2 restart
# Create a work directory and copy all project file into the 
WORKDIR /var/www/app/
COPY . /var/www/app
#Granting permissions to files and folders
RUN chmod -R o+w /var/www/app/storage
RUN chown -R www-data:www-data ./storage
RUN chgrp -R www-data storage bootstrap/cache
RUN chmod -R ug+rwx storage bootstrap/cache
RUN chmod -R 755 /var/www/app/
RUN find /var/www/app/ -type d -exec chmod 775 {} \;
RUN chown -R www-data:www-data /var/www
# Installing dependencies from laravel package 
RUN composer install --no-scripts --no-autoloader --no-ansi --no-interaction --working-dir=/var/www/app
#Running some packages 
RUN docker-php-ext-install mbstring pdo pdo_mysql mbstring exif pcntl bcmath gd opcache
#Running Laravel on docker, because we are using the php-7.3-cli so we have to use a php server in our docker image
CMD php artisan serve --host=0.0.0.0 --port=80
EXPOSE 80`

在第 1 步出现错误。 5:

Step 5/21 : ADD 000-default.conf /etc/apache2/sites-available/
ADD failed: file not found in build context or excluded by .dockerignore: stat 000-default.conf: file does not exist

如何在 Windows 上解决这个问题?任何帮助将不胜感激

最佳答案

我认为最好的解决方案是手动创建一个新的,这里是一个示例文件:

https://gist.github.com/tjtoml/942d696c868b22a25259

它应该位于:

/etc/apache2/sites-available/000-default.conf

您可能必须根据需要对其进行自定义

关于php - 在 Windows 上构建 Laravel 应用程序的 docker 镜像时未找到 000-default.conf,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/70668865/

相关文章:

php - 如何在 Laravel Eloquent 中确定结果的优先级

mysql - SQLSTATE[42S22] : Column not found: 1054 Unknown column 'id' in 'where clause' (SQL update. .) 其中 `id` 为空)

php - laravel 4 Eloquent 热切加载关系计数

mysql - Laravel - 如何使用查询生成器执行特定查询

php - HandlerSocket 给出错误 167 - 这是什么意思?

PHP/MySQL : Strange output issue when echoing variable from MySQL database

php - 在 php 字符串中存储 html 的替代方法

Spring Actuator - 来自 docker 容器的指标聚合

node.js - NPM 在 docker 容器中升级后中断

docker - Docker:加快SBT镜像的速度。 (正在获取org.scala-sbt sbt 1.2.6(这可能需要一些时间)…)