How to Setup WordPress the Easy Way

How to setup Wordpress the easy way and in a secure matter.

Setup and Start Docker

  • Install Docker Engine for your operating system.
  • Click here for instructions on how to install docker-compose for any Linux distribution. On Windows and Mac the docker-compose is bundled with the Docker Engine install.

Writing some markup

  1. Open a editor of your choice.
  2. Create a new file.
  3. Copy the yaml below to your new file.
version: '3.3'

services:
    database:
        image: mysql:5.7
        volumes:
            - database_data:/var/lib/mysql
        restart: always
        environment:
            MYSQL_ROOT_PASSWORD: ${DATABASE_ROOT_PASSWORD}
            MYSQL_DATABASE: ${APPLICATION_DATABASE}
            MYSQL_USER: ${APPLICATION_USER}
            MYSQL_PASSWORD: ${APPLICATION_PASSWORD}
        networks:
            - internal

    webserver:
        depends_on:
            - database
        image: wordpress:latest
        ports:
            - "${WEBSERVER_PORT}:80"
        restart: always
        environment:
            WORDPRESS_DB_HOST: database:3306
            WORDPRESS_DB_USER: ${APPLICATION_USER}
            WORDPRESS_DB_PASSWORD: ${APPLICATION_PASSWORD}
            WORDPRESS_DB_NAME: ${APPLICATION_DATABASE}
        networks:
            - internal
            - external

volumes:
    database_data: {}

networks:
    external:
        driver: bridge
    internal:
        driver: bridge
  1. Save your project as a sub-directory in the Documents folder. I decided to call my project wordpress.
  2. The name of your file should be docker-compose and make sure the file format is yaml.
  3. Click the save button when done.
  4. Create a new file.
  5. Copy the file below to your new file.
  6. Replace CHANGE THIS with a stronger password from https://passwordsgenerator.net.
# Global environment variables.
APPLICATION_DATABASE=developer_blog
APPLICATION_USER=developer_user
APPLICATION_PASSWORDD='CHANGE THIS'

# Database environment container.
DATABASE_ROOT_PASSWORD='CHANGE THIS'

# Webserver environment container.
WEBSERVER_PORT=8000
  1. Save this file in the same folder as your docker-compose file. The name of this file will be dev.env.

Run Docker Commands

  1. Open a Terminal/Command/Powershell window.
  2. Navigate to your project directory.
  3. Run docker-compose ps to make sure there are no projects running and should look like the below image.
  1. Run docker-compose --env-file=dev.env up --build -d to start the server. This will take around 5-10 minutes depending on the speed of your internet. This video has been sped up so you don’t have to wait.
  2. When done you should see a similar response that says done for both database_1 and webserver_1.

Test Webpage

  • Run docker-compose ps to check the status of the last command. The status of both lines should be positive.
  • The line wordpress-lamp_wordpress_1 should have a port that looks similar to 0.0.0.0:8000->80/tcp. The 8000 is very important in the next step.
  • In your browser url bar type localhost:8000 and press enter. You will get the fist page of the WordPress install.
  • Select your language and fill out the initial setup form. Make sure you copy the password because it will be used in a moment.
  • When the setup is complete you will get a login page. Use the email and password from the previous login page.
  • Congratulations you now have WordPress running on your home computer.

Josh Martin
Josh Martin
Articles: 2

10 Comments

  1. Hello There. I found your blog using msn. This is
    an extremely well written article. I’ll make sure to bookmark
    it and return to read more of your useful information. Thanks for
    the post. I’ll definitely return.

  2. Next time I read a blog, Hopefully it wont fail me as much as this particular one. I mean, Yes, it was my choice to read, however I really believed you would have something helpful to talk about. All I hear is a bunch of whining about something you could fix if you werent too busy searching for attention.

  3. When some one searches for his necessary thing, so he/she desires
    to be available that in detail, therefore that thing is maintained over here.

  4. Thank you, I have just been looking for info approximately this subject for a long time and yours is the best
    I’ve discovered so far. But, what concerning the bottom line?

    Are you certain concerning the source?

Leave a Reply to Josh MartinCancel Reply

Your email address will not be published. Required fields are marked *