I am trying to connect a Laravel 5.2 application. For this, I use the following images,
php:apache mysql:5.7
Below is my docker-compose.yml
web: build: . volumes: - ./:/var/www/html ports: - "9899:80" links: - db command : [/usr/sbin/apache2ctl, -D, FOREGROUND] db: image: mysql:5.7 volumes: - /home/data:/var/lib/mysql environment: MYSQL_DATABASE: custom MYSQL_ROOT_PASSWORD: custom
And my Dockerfile
FROM php:apache RUN apt-get update && docker-php-ext-install pdo pdo_mysql RUN rm -f /etc/apache2/sites-available/000-default.conf ADD ./settings/000-default.conf /etc/apache2/sites-available
Both Dockerfile and docker-compose.yml are in the laravel root directory. To run a laravel-based application, the server must point to the public folder. So you can see that I am replacing the apache2 default configuration file below 000-default.conf file,
<VirtualHost *:80> ServerAdmin webmaster@localhost DocumentRoot /var/www/html/public ErrorLog ${APACHE_LOG_DIR}/error.log CustomLog ${APACHE_LOG_DIR}/access.log combined </VirtualHost>
Everything works fine in the docker-compose up , but when I look at localhost:9899 , I get a Forbidden error, but localhost:9899/public starts the laravel application correctly. This means that my shipped 000-default.conf has no effect, and the server still points to /var/www/html/ instead of /var/www/html/public .
So, I tried exec to enter the running container to check 000-default.conf . And I could see my file, not the default. I do not understand this problem. I want apache to review my 000-default.conf . Hope you guys can see what I'm doing wrong.
source share