Giter Club home page Giter Club logo

docker-lamp-dev's Introduction

Docker LAMP

Installs Lamp project for local development

  • Handles multiple domains (localhost, yoursite)
  • Handles http and https
  • phpmyadmin is accessible via /phpmyadmin/ (with a trailing /)

Install

Create a local SSL certificate

  • Download mkcert

  • Run mkcert -install so that your browser accepts mkcert certificates

  • Create a certificate and private key for your website:

      mkcert yoursite
      mv yoursite.pem ./www/yoursite/site.crt
      mv yoursite-key.pem ./www/yoursite/site.key
    

Set your the database password

Change the name of the database and user to be created in docker-compose.yml

  - MYSQL_ROOT_PASSWORD=rootpassword
  - MYSQL_DATABASE=mydatabase
  - MYSQL_USER=myuser
  - MYSQL_PASSWORD=userpassword

Set the app environment variables

In the www/yoursite/.env.ini file (loaded in inc.config.php)

; Fichier de configuration chargé dans inc.config.php

DEBUG=true
DOMAIN='yoursite'

[database]
DB_DSN='mysql:dbname=mydatabase;host=db'
DB_USER='myuser'
DB_PASSWORD='userpassword'

Or in the docker-compose.yml file

services:
  webserver:
    ...
    environment:
      - DEBUG=0
      - DOMAIN=yoursite

Run

Give ownership to www-data (we set the UID of www-data to 1000 in the Dockerfile):

sudo chown -R $(whoami):1000 ./www

Make sure Docker is running

sudo docker ps

Run the container

sudo docker-compose up -d

If you change the Dockerfile and you need to rebuild the image, use sudo docker-compose build instead

Access the site

  • Edit /etc/hosts with admin privileges and add 127.0.0.1 yoursite
  • Check accessing the websites works: http://localhost, http://yoursite
  • Check your SSL certificate is correctly configured: https://yoursite
  • Check you can access the database: https://yoursite/test
  • Access phpmyadmin: https://yoursite/phpmyadmin/

Others

Stop the containers

sudo docker stop $(sudo docker ps -a -q)
sudo docker rm $(sudo docker ps -a -q)

Execute a command on a running container

sudo docker ps
sudo docker exec -it CONTAINER_ID ls /

Ressources that have been useful:
@PerchCMS/simple-docker
@sprintcube/docker-compose-lamp
@mattrayner/docker-lamp
@phpmyadmin/docker

docker-lamp-dev's People

Contributors

a-mt avatar

Watchers

 avatar  avatar

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.