Git Product home page Git Product logo

wp-scratch's Introduction

WordPress Scratch

Build Status Latest Stable Version Latest Unstable Version License

A scalable WordPress project from scratch. Easy to deploy!

While working with WordPress, i feel unease to config virtual hosts, set up brand new WordPress installations, copy essential plugins... for each new project again and again.

With this, you can proxy static contents, databases, back-end and front-end into smaller servers. All of them use a same WordPress installation, it's really helpful in term of performance and maintainability. Moving your servers around or setting up load balancing becomes easier.

Requirements

Installation

  1. Prepare your server block for Nginx or virtual host for Apache. You do not need to create MySQL database, it will be created while installing WordPress.

  2. Run these two commands on your command line respectively:

$ composer create-project i30/wp-scratch /path/to/project/directory
$ cd /path/to/project/directory && ./install
  1. Follow instructions to finish the installation. It's easy!

From now on, to add a new WordPress site, you just need to fire the install script again.

Important Notes

  • Since $_SERVER['SERVER_NAME'] is used to determine which site will respond to requests, please make sure SERVER_NAME is configured properly. For Apache 2, remember to add UseCanonicalName = On in every virtual host.

  • While working with multiple sites (not WordPress multisite), you might need to separate UPLOADS directory. Use this script as a must-use plugin:

    /**
     * Plugin Name: Dynamic Uploads Directory
     * Version:     1.0.0
     * Description: Create custom uploads directory base on the DB_NAME constant.
     * Author:      sarahcoding
     * Author URI:  https://sarahcoding.com
     * License:     GPL v3+
     */
    add_filter('upload_dir', function($args)
    {
      $base_url = WP_HOME . '/uploads';
      $base_dir = APP_ROOT . 'app/uploads';
      $custom_url = WP_HOME . '/' . DB_NAME . '-uploads';
      $custom_dir = APP_ROOT . 'app/' . DB_NAME . '-uploads';
    
      $args['url'] = str_replace($base_url, $custom_url, $args['url']);
      $args['path'] = str_replace($base_dir, $custom_dir, $args['path']);
      $args['baseurl'] = str_replace($base_url, $custom_url, $args['baseurl']);
      $args['basedir'] = str_replace($base_dir, $custom_dir, $args['basedir']);
    
      return $args;
    }, PHP_INT_MAX);

Contributing

Contribution is always welcome!

wp-scratch's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

Forkers

wpsss

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.