This repository contains a Docker setup for running a Laravel application locally using the LEMP stack (Linux, Nginx, MySQL, PHP), along with phpMyAdmin for database management.
Before getting started, ensure that you have Docker and Docker Compose installed on your machine.
-
Clone this repository to your local machine:
git clone https://github.com/davseve/laravel-docker-lemp.git
-
Navigate to the project directory:
cd laravel-docker-lemp
-
Copy the
.env.example
file to.env
:cp .env.example .env
-
Update the
.env
file with your Laravel application configurations, including database credentials:DB_CONNECTION=mysql DB_HOST=db DB_PORT=3306 DB_DATABASE=laravel DB_USERNAME=root DB_PASSWORD=password
To set up the Docker image, execute the following command:
docker-compose build
To start the Docker containers in detached mode (background):
docker-compose up -d
To stop the Docker containers, execute:
docker-compose stop
- Access your Laravel application in a web browser at
http://localhost
. - Access phpMyAdmin at
http://localhost:8080
in your web browser. Use the MySQL database credentials specified in your.env
file to log in.
- Start containers:
docker-compose up -d
- Stop containers:
docker-compose stop
- View container logs:
docker-compose logs
app/
: Laravel application filesnginx/
: Nginx server configurationmysql/
: MySQL database storagephpmyadmin/
: phpMyAdmin configuration files
- Adjust Nginx configuration in
nginx/default.conf
if needed. - Customize Docker container names, ports, and volumes in
docker-compose.yml
.
- Make sure ports
80
and8080
are not in use by other services on your machine before running Docker. - This setup is intended for local development purposes. Ensure proper security measures in production environments.
This project is licensed under the MIT License.