Simple and fast Wordpress Bedrock setup on docker. This setup has the advantage of using separate container for each service which is little bit slower on Windows devices. Faster version of this setup using official WordPress image is here.
- Apache
- PHP 7.3
- MySQL 8
- PhpMyAdmin
- Composer
- WP-CLI - command line interface for WordPress
- Clone this repository to your PC
cd
into the folder and edit.env
cd
intosrc
folder and edit.env
- Download bedrock with composer:
docker-compose run composer create-project roots/bedrock
or if you have composer installed globally:
composer create-project roots/bedrock
-
copy
env
file fromsrc
folder tobedrock
and rewrite. -
From the root run:
docker-compose up -d
- Wordpress is ready for installation on the localholst IP you have inserted in
.env
file.
To use wp-cli, you can easily set alias in .bashrc
file in your user folder.
alias wp="docker-compose run --rm wpcli"
Then you can run standard commands. For instance for database manipulation you can run:
Import database:
wp db import databasename.sql
Database dump:
wp db export
Database drop:
wp db drop
Search and replace:
wp search-replace 'old-url' 'new-url'
If you want, you can use standard MySQL commands.
Database dump:
docker exec CONTAINER-NAME sh -c 'exec mysqldump DBNAME -uroot -p"$MYSQL_ROOT_PASSWORD"' > backup.sql
Database import:
docker exec -i CONTAINER-NAME sh -c 'exec mysql -uroot DBNAME -p"$MYSQL_ROOT_PASSWORD"' < backup.sql
If you want to change the default web folder, just rewrite these 3 files:
- In
bedrock
folder renameweb
folder tohtml
for instance - In
config
folder inapplication.php
change$webroot_dir
variable fromweb
tohtml
- In
Dockerfile
changeAPACHE_DOCUMENT_ROOT