Install WordPress for Plugin Development
For plugin development we need a local installation of Wordpress. There are multiple ways to do this, however our preferred choice is to go with Docker; probably, the most elegant way to run Wordpress locally.
If you are new to Docker, then we suggest you to get familiarize with it as docker or similar technologies is the modern way of doing things in cloud platforms; it is not that difficult. Running Wordpress with Docker is breeze, just couple of commands and you get it up and running as everything is pre-configured.
Still, you like to do things in old fashion, then you may install Wordpress using XAMPP.
Install Docker Components
After installation, test it by running following commands,
docker run hello-world docker-compose -version
We are ready to run and install WordPress. First download docker-compose.yml file from our project page and copy it some work folder where you want to develop on your plugin; any location is fine. This folder will be used by Docker to place Wordpress and database data files. Run following command from the work folder,
Docker will download Wordpress and MySQL images from Docker Hub and create and run two containers. This process may take couple of minutes as the download size is about 600MB. Wait for image download to complete and then check status of containers with
$ docker ps CONTAINER ID IMAGE STATUS PORTS NAMES 5978b42efabc wordpress:latest Up 3 minutes 0.0.0.0:8000->80/tcp wp 08c08ebc263f mysql:5.7 Up 3 minutes 0.0.0.0:3306->3306/tcp, 33060/tcp wp-db
With containers up and running, open
http://localhost:8000 in the browser to get WordPress Installation screen. Complete the WordPress installation.
Once WP Installation is complete, you will have following folders in your work directory.
m@m:mywp$ ls -lrt total 12 -rwxrwxr-x 1 m m 693 Mar 9 16:56 docker-compose.yml drwxr-xr-x 7 systemd-coredump root 4096 Mar 14 17:10 db drwxr-xr-x 5 www-data www-data 4096 Mar 14 17:10 wp
Docker places wordpress files in
wp folder and database files in
db. Here onwards, we refer
wp as the wordpress directory. We are going to place the our plugin folder in
wp/wp-content/plugins dir in the next tutorial.
Volume Path in Windows
In the next tutorial, we start with WordPress plugin basics by start coding a simple plugin.