Docker running Apache, PHP-Apache, MySQL and PHPMyAdmin.
THIS ENVIRONMENT SHOULD ONLY BE USED FOR DEVELOPMENT!
DO NOT USE IT IN PRODUCTION!
-
Download it :
$ git clone https://github.com/aleix20bcn/docker-apache2-php-mysql-wordpress.git
-
Configure Apache :
Create apache file etc/apache/mydomain.com.conf and configure the server section.
<VirtualHost *:80>
ServerAdmin web@localhost
ServerName mydomain.com
ServerAlias www.mydomain.com
DocumentRoot /CODE/mydomain.com/live/current
ErrorLog ${APACHE_LOG_DIR}/mydomain.com_error.log
LogLevel warn
CustomLog ${APACHE_LOG_DIR}/mydomain.com_access.log combined
<Directory />
Options FollowSymLinks
</Directory>
<Directory /CODE/mydomain.com/live/current/>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all
# New directive needed in Apache 2.4.3:
Require all granted
</Directory>
RewriteEngine On
</VirtualHost>
- Configure .env file :
#Domain variables
DOMAIN_NAME=<domain_name>
#Database variables
DATABASE=<database>
DATABASE_USER=<user_database>
DATABASE_PASS=<supersecretpassword_database>
-
Copy wordpres project to /web
-
Run :
$ docker-compose up -d
-
Add dump database in container :
$ cat backup.sql | docker exec -i mysql /usr/bin/mysql -u root --password=root MYDATABASE
-
Configure your "/etc/hosts" file in your computer :
$ 127.0.0.1 mydomain.com
-
Open your favorite browser :
- http://mydomain.com
- https://mydomain.com (HTTPS not configured by default)
- phpMyAdmin (user: root, pass: root)
├── README.md
├── bin
│ └── linux
│ └── clean.sh
├── data
│ └── db
│ └── mysql
├── docker-compose.yml
├── etc
│ ├── apache
│ │ ├── mydomain.conf
│ ├── php
│ │ └── php.ini
│ └── ssl
│ ├── cacert.pem
│ ├── server.key
│ └── server.pem
└── web
<?php
return array (
...
define('DB_NAME', '<database>');
/** Tu nombre de usuario de MySQL */
define('DB_USER', '<user_database>');
/** Tu contraseña de MySQL */
define('DB_PASSWORD', '<supersecretpassword_database>');
/** Host de MySQL (es muy probable que no necesites cambiarlo) */
define('DB_HOST', 'mysql');
...
);
?>
$ docker exec -i -t CONTAINER_NAME /bin/bash
$ docker exec CONTAINER /usr/bin/mysqldump -u root --password=root DATABASE > backup.sql
$ cat backup.sql | docker exec -i CONTAINER /usr/bin/mysql -u root --password=root DATABASE
$ docker rm -f $(docker ps -aq)
$ docker rmi $(docker images -q)
$ ./bin/linux/clean.sh $(pwd)