linux programming web server

Simple Laravel Docker setup

composer create-project laravel/laravel laravel-app
cd laravel-app
touch .docker/Dockerfile
touch .docker/vhost.conf

Content of Dockerfile:

FROM php:7.3-apache
COPY . /srv/app
COPY .docker/vhost.conf /etc/apache2/sites-available/000-default.conf
RUN chown -R www-data:www-data /srv/app && a2enmod rewrite

Content of vhost.conf:

<VirtualHost *:80>
    DocumentRoot /srv/app/public
    <Directory "/srv/app/public">
        AllowOverride all
        Require all granted
    ErrorLog ${APACHE_LOG_DIR}/error.log
    CustomLog ${APACHE_LOG_DIR}/access.log combined

Building image:

docker build --file .docker/Dockerfile -t laravel-app .

Running container:

docker run --rm -p 8080:80 laravel-app

Source: BitPress

Leave a Reply

Your email address will not be published. Required fields are marked *

This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.