Setup Docker for LAMP!
Author: Doe Hoon LEE
This shows the steps to setup LAMP environment with Docker
What is LAMP?
LAMP stands for Linux Apache MySQL PHP
You can simply git clone https://github.com/DOEHOONLEE/dockerLAMP.git or try typing in the following steps!
1. Project Structure
-
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 write
3. index.php
within the www
directory looks like this
4. Now, the most interesting one: docker-compose.yml
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!
type in docker-compose up --build
and test if it works!
6. Check if all containers are running smoothly!
type in docker ps
7. Go to localhost
You should see Connected to MySQL successfully!
8. Test if phpmyadmin
is working
Go to localhost:8080
9. In case you want to use environment variables
10. To stop the service,
type in docker-compose stop
Leave a comment