davseve / laravel-docker-lemp

Docker file to run laravel

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

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.

Prerequisites

Before getting started, ensure that you have Docker and Docker Compose installed on your machine.

Getting Started

  1. Clone this repository to your local machine:

    git clone https://github.com/davseve/laravel-docker-lemp.git
  2. Navigate to the project directory:

    cd laravel-docker-lemp
  3. Copy the .env.example file to .env:

    cp .env.example .env
  4. 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

Building and Starting Docker Containers

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

Stopping Docker Containers

To stop the Docker containers, execute:

docker-compose stop

Accessing Laravel Application and phpMyAdmin

  • 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.

Docker Commands

  • Start containers: docker-compose up -d
  • Stop containers: docker-compose stop
  • View container logs: docker-compose logs

Directory Structure

  • app/: Laravel application files
  • nginx/: Nginx server configuration
  • mysql/: MySQL database storage
  • phpmyadmin/: phpMyAdmin configuration files

Customizations

  • Adjust Nginx configuration in nginx/default.conf if needed.
  • Customize Docker container names, ports, and volumes in docker-compose.yml.

Notes

  • Make sure ports 80 and 8080 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.

License

This project is licensed under the MIT License.

About

Docker file to run laravel


Languages

Language:PHP 57.1%Language:Blade 41.2%Language:Dockerfile 1.3%Language:JavaScript 0.3%