This boilerplate is a ready-to-start customizable LAMP stack with Wordpress, WP-CLI and PHPMyAdmin integration. Warning : for Linux users only.
Use composer create-project
command :
composer create-project lch/docker-wordpress target-dir 1.1.6
This will clone the stack in your directory
First of all, specify parameters needed for the project
- WORDPRESS_HOST_RELATIVE_APP_PATH: This is the relative path from project initial path. Default to
./
. Note: a volume will be created on this path in order to persist Wordpress app files. - LOGS_DIR: The logs directory.
- HOST_USER: Your current username. Needed to ensure creation (directories...) with your current user to preserve mapping between container and host
- HOST_UID: Your current user host ID (uid). This is mandatory to map the UID between PHP container and host, in order to let you edit files both in container an through host volume access.
- HOST_GID: Your current main group host ID (gid). (Not used so far)
-
PROJECT_NAME: The project name : used as Wordpress site name. IMPORTANT : as this is used for setting the theme directory as well, keep this name with underscores (i.e : project_test)
-
ADMIN_USER: the first user to be created
-
ADMIN_PASSWORD: the first user password. IMPORTANT: Keep it enclosed with double quotes.
-
PROJECT_REPO: the git repo address
-
WP_CLI_CACHE_DIR: WP-CLI cache directory. Leave it this way.
- MYSQL_HOST: The database host. Has to be equal to database container name in
docker-compose.yml
file (defaultmysql
). - MYSQL_DATABASE: The database name you want
- MYSQL_DATABASE_PREFIX: THe database prefix you want for your Wordpress installation
- MYSQL_USER: THe database user you want to use (will be created on container creation)
- MYSQL_PASSWORD: the database password you want
- __MYSQL_HOST_PORT: the host port you want to bind Mysql Server in container to.
- MYSQL_PORT: the MySQL instance port. Careful, this is the MySQL port in container. Default to
3306
- MYSQL_HOST_VOLUME_PATH: default
./docker/data/mysql/5.7
. This is the volume which will store database.
You can have multiple projects using this boilerplate, but without changing ports, only one project can be up at a time, because port 80 is used to expose Apache.
- APPLICATION_WEB_PORT: default to
80
. - PHP_MY_ADMIN_PORT: default to
81
.
There are 2 ways to use this : initialisation and day-to-day usage. A Makefile
is created to help manipulate things
Just execute make install
to completly setup blank project. Please look to other entry points in Makefile
to see what you can do
Just execute make sage
to set a complete project with Sage 8.5.3. Sage 9 is coming...
- Execute
make up
for bringing project live - Execute
make down
for stopping and removing container instances. - Execute
make bash-php
for a shell in PHP container withwww-data
user.
Note : All volumes set will ensure to persist both app files and database.
If you want to reset everything, just
- Run
docker-compose down
. - Remove the WORDPRESS_HOST_RELATIVE_APP_PATH and the MYSQL_HOST_VOLUME_PATH.
- Then goes back on
make install
.
Accessible on localhost
by default.
Important note : to execute wp-cli, be sure to connect to php container with www-data user. The mapping described above targets www-data on container.
Command to use : make bash-php
Accessible on localhost:81
by default. Use MYSQL_USER
and MYSQL_PASSWORD
to connect.