Ready-To-Start LAMP stack with Wordpress, WP-CLI and PHPMyAdmin
This boilerplate is a ready-to-start customizable LAMP stack with Wordpress, WP-CLI and PHPMyAdmin integration.
Warning : for Linux users only., (*1)
Installation
Use composer create-project
command :, (*2)
composer create-project devgiants/docker-wordpress target-dir 1.7.1
This will clone the stack in your directory, (*3)
Requirements
Mac users : During installation, the script requires the use of envsubst which is not installed by default on MacOS. You can install it directly with Homebrew:, (*4)
brew install gettext
brew link --force gettext
Configuration
Custom parameters
.env file
First of all, specify parameters needed for the project, (*5)
Directories
-
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.
PHP
-
PHP_VERSION: the PHP version to use for stack
Host
-
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)
Wordpress
-
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, (*6)
-
WP_CLI_CACHE_DIR: WP-CLI cache directory. Leave it this way., (*7)
Database
-
MYSQL_HOST: The database host. Has to be equal to database container name in
docker-compose.yml
file (default mysql
).
-
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.
Ports
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., (*8)
-
APPLICATION_WEB_PORT: default to
80
.
-
PHP_MY_ADMIN_PORT: default to
81
.
Usage
There are 2 ways to use this : initialisation and day-to-day usage. A Makefile
is created to help manipulate things, (*9)
Initialisation
Blank project
Just execute make install
to completly setup blank project. Please look to other entry points in Makefile
to see what you can do, (*10)
Project with Sage 9 theme
Just execute make sage
to set a complete project with Sage 9., (*11)
Day-to-day usage
- 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 with www-data
user.
Note : All volumes set will ensure to persist both app files and database., (*12)
Reset from scratch
If you want to reset everything, just
1. Run docker-compose down
.
2. Remove the WORDPRESS_HOST_RELATIVE_APP_PATH and the MYSQL_HOST_VOLUME_PATH.
3. Then goes back on make install
., (*13)
Wordpress
Accessible on localhost
by default., (*14)
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
, (*15)
PhpMyAdmin
Accessible on localhost:81
by default. Use MYSQL_USER
and MYSQL_PASSWORD
to connect., (*16)