A bare-bones starter WordPress environment using Docker. Right now, this just quickly sets up a functional local PHP environment and WordPress installation. Out of the box, the container comes installed with tools like Composer and the WP CLI.
Make sure Docker and Docker Compose are installed on your machine.
- Clone this repository into a directory.
- Navigate into that directory.
- Run
docker-compose up
to turn on the container. - If this is your first time using this environment, run
sh setup.sh
(outside the running container -- no need to enter it). This will do the following things to get set up:
- Download & install WordPress.
- Enable WP debugging.
- Remove default posts, comments, and terms.
- Remove default plugins, themes, widgets.
- Install any dependencies you have noted in your
content/composer.json
file.
- After setup, navigate to http://localhost/wp-admin, where you'll be able to login with
admin
andpassword
as the username & password. - In the future, just turn on the container by running
docker-compose up
. This will turn on the container and make the/wordpress
directory the web root, with thecontent
directory being mounted inside of that. You should do all of your local development (themes, plugins, etc.) inside thecontent
directory at the root of this project. - When you're done, run
docker-compose down
to turn off the container.
There are some other commands in the Makefile
too, so feel free to check those out or add your own.
Composer is installed inside the container for easier dependency management, and a composer.json
file is included in the wp-content
. These are automatically installed on setup, but you can also install/update them manually using the following command:
docker-compose exec --user root php-fpm /bin/bash -c "cd wp-content && composer install"
Or, to update packages, use:
docker-compose exec --user root php-fpm /bin/bash -c "cd wp-content && composer update"
Mailcatcher is setup to trap emails sent from your application. View these emails by going to http://localhost:1080/.
You can use a tool like Sequel Pro to more easily see what's happening inside your database. To connect, use the following configuration:
Host: 127.0.0.1
Username: root
Password: root
Port: 3306
Everything should go in the content
directory, which will be mounted to the container when it's turned on.
Right now, directory modify the wp-config.php
file in the wordpress
directory.
Run docker-compose exec --user root php-fpm /bin/bash
, or use the make bash
shortcut (assuming make
is installed).
Yes. In the config
directory, a default.conf
and php.ini
file exist for you to customize nginx & PHP as needed. These are mounted to the container when you turn it on.
In the docker-compose.yml
file, change the tag in this line: image: 10up/phpfpm:7.2
. You can see a list of available tags here.
This environment was heavily inspired by 10up and their wp-local-docker project. So, thanks to them.
MIT © Alex MacArthur