Setup Docker for LAMP!
Author: Doe Hoon LEE
This shows the steps to setup LAMP environment with DockerPermalink
What is LAMP?Permalink
LAMP stands for Linux Apache MySQL PHPPermalink
You can simply git clone https://github.com/DOEHOONLEE/dockerLAMP.git or try typing in the following steps!Permalink
1. Project StructurePermalink
-
Create directories
php
andwww
-
Create a Docker file
Dockerfile
inphp
directory -
Create a file
docker-compose.yml
in the root directory -
Create
index.php
inwww
directory -
Create
.env
in root directory [this can be skipped if you do not want to use environment variables]
2. In Dockerfile
inside php
directory, we will writePermalink
3. index.php
within the www
directory looks like thisPermalink
4. Now, the most interesting one: docker-compose.yml
Permalink
You can use different names for DATABASE, user, password, or even ports if you want to. Also, again, you do not have to use environment variables like in the picture.
(See step 9 for environment variables)
5. We are now all set! Let’s test it out!Permalink
type in docker-compose up --build
and test if it works!
6. Check if all containers are running smoothly!Permalink
type in docker ps
7. Go to localhost
Permalink
You should see Connected to MySQL successfully!
8. Test if phpmyadmin
is workingPermalink
Go to localhost:8080
9. In case you want to use environment variablesPermalink
10. To stop the service,Permalink
type in docker-compose stop
Leave a comment