Giter VIP home page Giter VIP logo

wordpress-ops's Introduction

Wordpress Ops

The right way to develop and do CI/CD for your Wordpress sites.

Wordpress :)

"Haizz... Again :(" - this is what I (or maybe you also) say when I have to setup a Wordpress site.

Maybe you don't like PHP and you don't want to upgrade tons of plugins and Wordpress version every month or week (or even day). Half of your working hours are on reading bugs, vulnerabilities of Wordpress eco-system? Sometimes, you dreamed about it?

Wordpress is boring and for noobs only? Everyone can publish something, check SEO, customize the images size and quality, get a nice dashboard report, etc. Yeah, these are the main reasons why you have to set it up.

Problems

Wordpress relies on MySQL to store data and configuration, so it is neat. Just download Wordpress release zip file, extract it somewhere and lets Apache or PHP-FPM/Nginx run that.

In general, your Wordpress development is for themes and plugins. Wordpress store all of these in wp-content/ folder. Usually, Wordpress admin can simply click and clicks to install a new theme or plugin inside Wordpress admin panel.

There are some issues.

  • Hard to replicate stuff from staging > pre-production > production. You can do the same "clicks" when you have to setup a new environment.
  • Wordpress offers some config files like wp-config.php where you can just add the MySQL login credential and keep the file on the server. This is not manual and not a good practice also.
  • You give PHP process more permission on the server which means higher risks e.g write permission to many folders like themes, plugins then you have a higher chance to get hacked because of the future bugs :)

Solutions

  • Let's use Git.

We only have to store plugins and themes since we only want to modify these files. Most of the time you only have to download the plugin code and add there without changing anything.

  • Only give enough permission to Wordpress/PHP process in servers.

You can keep track of all public plugins and your plugins. In the server Wordpress only need read permission to all of these which is great.

  • Use environment variables

Then you don't have to hardcode the MySQL password in wp-config.php. You can export necessary variables to ENV depends on your configuration management.

Note that ENV has its problem. It is not really fix the issue of plaintext password in wp-config.php. It is more about flexibility in term of configuration. E.g. you can easily swap from running Wordpress from EC2 to Docker without changing the config of where you put the secrets.

  • CI/CD to rescue

Depends on the complexity of your project then you can have a different Git flow. Base on that flow you can decide how to release to staging up to production.

Example

Imagine about a simple Wordpress site that editor publish content, upload images, etc. Readers will comment to the article using Disqus basically 99% of the traffic will be static.

We use AWS as the infrastructure provider here. We recommend to use Cloudflare as DNS manager and CDN. Cloudflare protects your site from many kinds of attacks, and it will save you a fortune when you have to serve millions of clients with TBs of bandwidth.

Wordpress-Sample-Site

Setup

I think most of the Wordpress sites are running on a single server on DigitalOcean, AWS, GCP, etc.

The problem comes when you have more than 1 instances of Wordpress e.g user sessions, uploaded data, etc. Most of these are easily handled by plugin. Here are some plugins that we recommend

For fun, we will run staging and production on EC2 Ubuntu 18.04 and in development we provide a docker config with similar config.

Development environment

Requirements

All what you need to launch this repo in your local

# Update ENV variables
cp .env.sample .env

# Start MySQL and Wordpress
# Then you can access Wordpress from your browser http://localhost:8000
docker-compose up

# Turn off the resources
docker-compose down

Other

TODO

  • CI config in CircleCI or Travis.
  • Ansible code to deploy on EC2.
  • Terraform code to launch the whole infras set.
  • Improve the Docker config and deploy to AWS ECS.

wordpress-ops's People

Contributors

ralavay avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.