Use Docker Compose to run WordPress on your local machine. This will start four containers: WordPress, MySQL, PHPMyAdmin and Mailhog (catch all emails - nothing sent from your localhost will reach the real users).
- Install Docker: https://docs.docker.com/get-docker/
- Update your
hosts
file - add127.0.0.1 localhost.develop
entry (see: https://www.howtogeek.com/howto/27350/beginner-geek-how-to-edit-your-hosts-file/)
- Make sure that Docker daemon is running on your local machine.
- Clone this repository (
git clone https://github.com/bartoszgadomski/wordpress-localhost.git
) and runcd wordpress-localhost
to enter its directory in your terminal. - Run
npm run setup
- this will createwp-content
directory for your project files. - Run
cd wp-content
and clone your project files/repositories here. - Go back (
cd ../
) and start the Docker Compose:docker-compose up
. This will build and start all the containers. If you don't want to see the containers logs, usedocker-compose up -d
instead. - Once you've finished your work, but you want to keep your data, stop the containers with Ctrl+C or
docker-compose kill
. - If you want to remove this project data, run
docker-compose down
.
- If you want to run shell inside the WordPress container, run
docker-compose exec wordpress sh