Code Monkey home page Code Monkey logo

docker-lemp's Introduction

LEMP ((Linux) + (E)nginx + MariaDB + PHP) Docker stack for local web development

A docker-compose stack for local web development, which includes:

  • Nginx 1.20
  • MariaDB 10.5
  • PHP 7.4

There is also a LEPP (Nginx + PostgreSQL + PHP) Docker stack available on this repo

...and a LAMP (Apache + MariaDB + PHP) Docker stack available on this repo

How to run

  • Install Docker

  • Export env variable WWW_DOCUMENT_ROOT to point to your project root directory:

export WWW_DOCUMENT_ROOT="/var/www/html"
  • Export env variable MYSQL_ROOT_PASSWORD for defining your MySQL root password:
export MYSQL_ROOT_PASSWORD="root"

WARNING! The root password variable will only be used when creating a database, it won't change the root password of an existing database. And databases are persistent in a volume, even if the image is destroyed and recreated.

  • Start Docker compose:
docker-compose up -d
  • Access the website at document root on the URL http://localhost:8080/ or http://127.0.0.1:8080/ (both work).

Note on how to connect to MariaDB database from PHP container

Ports are ignored for connections between containers, so use 3306 (default), and the host name is the mariadb container name. So, i.e.:

try {
    $db = new PDO('mysql:host=mariadb;dbname=my_db_name', 'root', 'root');
}
catch(Exception $e) {
    die('Error: '.$e->getMessage());
}

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.