Docker running PHP, Apache, MySQL, and PHPMyAdmin
157
Docker running Apache, MySQL and PHPMyAdmin.
Before installing project make sure the following prerequisites have been met.
We’ll download the code from its repository on GitHub.
By this point we’ll have all the project pieces in place.
When running, you can use docker commands for doing recurrent operations.
To run the docker commands without using sudo you must add the docker group to your-user:
sudo usermod -aG docker your-user
All requisites should be available for your distribution. The most important are :
Check if docker-compose is already installed by entering the following command :
which docker-compose
Check Docker Compose compatibility :
The following is optional but makes life more enjoyable :
which make
On Ubuntu and Debian these are available in the meta-package build-essential. On other distributions, you may need to install the GNU C++ compiler separately.
sudo apt install build-essential
You should be careful when installing third party web servers such as MySQL or Nginx.
This project use the following ports :
| Server | Port |
|---|---|
| MySQL | 3306 |
| PHPMyAdmin | 8080 |
| Apache | 80 |
To install Git, download it and install following the instructions :
git clone https://github.com/DamoFD/docker-php-apache-mysql.git
Go to the project directory :
cd docker-php-apache-mysql
.
├── README.md
├── docker-compose.yml
├── www
│ ├── index.php
│ ├── database.php
└── Dockerfile
Start the application :
docker-compose up -d
Please wait this might take a several minutes...
docker-compose logs -f # Follow log output
Open your favorite browser :
docker-compose exec php php -m
docker exec -it mysql bash
and
mysql -u"$MYSQL_ROOT_USER" -p"$MYSQL_ROOT_PASSWORD"
mkdir -p data/db/dumps
source .env && docker exec $(docker-compose ps -q mysqldb) mysqldump --all-databases -u"$MYSQL_ROOT_USER" -p"$MYSQL_ROOT_PASSWORD" > "data/db/dumps/db.sql"
source .env && docker exec -i $(docker-compose ps -q mysqldb) mysql -u"$MYSQL_ROOT_USER" -p"$MYSQL_ROOT_PASSWORD" < "data/db/dumps/db.sql"
Notice: Replace "YOUR_DB_NAME" by your custom name.
source .env && docker exec $(docker-compose ps -q mysqldb) mysqldump -u"$MYSQL_ROOT_USER" -p"$MYSQL_ROOT_PASSWORD" --databases YOUR_DB_NAME > "data/db/dumps/YOUR_DB_NAME_dump.sql"
source .env && docker exec -i $(docker-compose ps -q mysqldb) mysql -u"$MYSQL_ROOT_USER" -p"$MYSQL_ROOT_PASSWORD" < "data/db/dumps/YOUR_DB_NAME_dump.sql"
Any thought, feedback or (hopefully not!)
Content type
Image
Digest
sha256:695ef6d34…
Size
155.7 MB
Last updated
about 3 years ago
docker pull damofd/php-apache-phpmyadmin