Skip to main content
  1. All Posts/


Tools Open Source PHP WordPress

WordPress Boilerplate

The WordPress Boilerplate is a starting base for development of any WordPress based web project. It provides all the files and most common code patterns — the bare essentials needed to get started quickly without wasting time setting up directory and file structure, importing CSS resets, setting up the functions.php file etc.
WordPressBP is meant for developers developing a WordPress site from scratch using a scalable and modern approach.
It is not:

  1. an end-user template
  2. a WordPress Plugin Boilerplate
  3. a WordPress Widget Boilerplate

If you need a stripped down version to manage WordPress installations with 3rd-party themes and plugins and an automated deployment process, check out my other project ManagedWP.

  • System requirements
  • Installation

  • Development

    System requirements

    WordPressBP has been extensively tested on Linux but will probably work with any Unix environment (macOS, BSD,…). It does not work on Windows in which case you should use a Linux VM for development.

    • LEMP stack (Linux, Nginx, MySQL, PHP 7+)
    • Git
    • NodeJS (node) and NPM (npm)
    • Composer
    • WP-CLI
    • gettext utilities (msgfmt) for i18n

    Read this Gist on how to correctly set these tools up on your development environment.


    Quick-start guide:

    1. Clone this repository and move into it
    2. Run the setup script ./ mywebsite /srv/http/
    3. Set up the web server to serve from /srv/http/
    4. Map the server IP to in your local hosts file (/etc/hosts)
    5. Login at (login: dev / dev)
    6. Initialize Git in /srv/http/ and start developing

    Continue reading for details.

    Setup script

    $ ./
      ./ <namespace> <project_path> [<branch>]
      <namespace>:    Lowercase alphanumeric name for your project. Must not start with a number. Must be file system and URL friendly.
      <project_path>: Path to directory where the project structure will be set up.
      <branch>:       Branch from which to create the project structure. Defaults to 'master'.
      ./ mything /srv/http/

    The script will create the directory at project_path if it doesn’t exist. Make sure the parent directory (or project_path if exists) is writable by the user running this script. Do not run the setup script as root unless you’re doing everything as root on your dev environment.
    The script will use composer, npm and wp (WP-CLI) to install dependencies and setup WordPress. Make sure these tools are installed as explained here.
    If you don’t have or don’t want to use a root MySQL account, you’ll be asked to manually create a database and user for it.

    Nginx web server

    Lets assume your project_path is /srv/http/ and namespace is mywebsite.
    Create /etc/nginx/sites-enabled/ with the following content and restart Nginx:

    # If you have SSL enable this redirect
    #server {
    #  listen [::]:80;
    #  listen 80;
    #  server_name;
    #  return 301$request_uri;
    server {
      # If no SSL:
      listen [::]:80;
      listen 80;
      # Else if SSL:
      #listen [::]:443 ssl http2;
      #listen 443 ssl http2;
      #include /etc/nginx/conf.d/ssl.conf; #
      #ssl_certificate /srv/http/;
      #ssl_certificate_key /srv/http/;
      root /srv/http/;
      index index.html index.php;
      access_log off;
      client_max_body_size 20m;
      # Rewrite URLs for uploaded files to production - no need to sync uploads from production
      #location /app/uploads/ { try_files $uri @production; }
      #location @production { rewrite ^$request_uri permanent; }
      location ~ .php$ {
        try_files $uri =404;
        fastcgi_index index.php;
        include fastcgi_params;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        fastcgi_pass unix:/run/php-fpm/php-fpm.sock; # Arch
        #fastcgi_pass unix:/var/run/php/php7.2-fpm.sock; # Ubuntu
      location / { try_files $uri $uri/ /index.php$is_args$args; }

    Read up on how to create self signed certificates for development. If you do create SSL certs, enable them in the Nginx config (above) and change the URLs in .env.
    To be able to access you need to map the server IP to domain in /etc/hosts. If you’re running the server on your local machine, the IP is, if you are using a virtual environment, then use the IP of…