Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save mackankowski/0ba28fca82973aa649170b2cc6520a04 to your computer and use it in GitHub Desktop.
Save mackankowski/0ba28fca82973aa649170b2cc6520a04 to your computer and use it in GitHub Desktop.
Wordpress - local set up and migration

Wordpress - local set up and migration

Prerequisites

Required software:

Set up

Setup GIT repository for changes revision

  1. For fresh new website, create a new folder and copy docker-compose.yml file there

  2. In the root directory, run: docker compose up (or docker-compose up)

The website will available at http://localhost (:80)

(Also, there is phpadmin available at http://localhost:8081)

  1. To stop application container, run: docker compose down

For more commands, go to: https://docs.docker.com/engine/reference/commandline/docker/

Migration

  1. For both, local and remote instance of Wordpress, install the plugin: https://wordpress.org/plugins/all-in-one-wp-migration/

  2. For the local instance, open Wordpress admin dashboard and find All-In-One-WP-Migration/Export tab

  3. Fill the field: "Find text Replace with another-text in the database, e.g. "Find localhost Replace with yoursite.com in the database or http:// to https://" (replacing http://localhost to https://yoursite.com should be enough)

  4. Choose "Export to file" and wait for finishing - the backup file will be saved on your local machine

  5. For the remote website instance, open Wordpress admin dashboard and find All-In-One-WP-Migration/Import tab

  6. Click "Import from file", find save backup file, confirm and wait for completion

version: '3.1'
services:
wordpress:
image: wordpress:latest
restart: always
ports:
- 80:80
environment:
WORDPRESS_DB_HOST: db
WORDPRESS_DB_USER: xyz
WORDPRESS_DB_PASSWORD: xyz
WORDPRESS_DB_NAME: xyz
volumes:
- ./wordpress:/var/www/html
db:
image: mariadb:10.5.8
restart: always
user: mysql
environment:
MYSQL_DATABASE: xyz
MYSQL_USER: xyz
MYSQL_PASSWORD: xyz
MYSQL_RANDOM_ROOT_PASSWORD: '1'
volumes:
- ./db:/var/lib/mysql
phpmyadmin:
image: phpmyadmin
restart: always
ports:
- 8081:80
environment:
- PMA_ARBITRARY=1
volumes:
wordpress:
db:
phpmyadmin:
@mackankowski
Copy link
Author

Troubleshooting for Bind for 0.0.0.0:8081 failed: port is already allocated

Run the following command to identify the container which uses the port and remove it:

docker container ls
docker rm -f <container-name>

@mackankowski
Copy link
Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment