https://github.com/i30/wp-scratch
A scalable WordPress project from scratch. Easy to deploy!
https://github.com/i30/wp-scratch
wordpress-deployment wordpress-installation
Last synced: 4 months ago
JSON representation
A scalable WordPress project from scratch. Easy to deploy!
- Host: GitHub
- URL: https://github.com/i30/wp-scratch
- Owner: i30
- License: gpl-3.0
- Created: 2016-10-20T14:24:34.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2020-12-21T01:42:14.000Z (over 5 years ago)
- Last Synced: 2025-03-19T10:41:54.771Z (about 1 year ago)
- Topics: wordpress-deployment, wordpress-installation
- Language: Shell
- Homepage:
- Size: 29.3 KB
- Stars: 8
- Watchers: 4
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# WordPress Scratch
[](https://travis-ci.org/i30/wp-scratch)
[](https://packagist.org/packages/i30/wp-scratch)
[](https://packagist.org/packages/i30/wp-scratch)
[](https://packagist.org/packages/i30/wp-scratch)
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
- [PHP][1] >= 5.6
- [MySQL][2] >= 5.6
- [WP-CLI][3] >= 0.24
- [Composer][4] >= 1.0
## Installation
1. Prepare your server block for [Nginx][5] or virtual host for [Apache][6]. 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:
```bash
$ composer create-project i30/wp-scratch /path/to/project/directory
$ cd /path/to/project/directory && ./install
```
3. 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:
```php
/**
* 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!
[1]: http://php.net
[2]: http://dev.mysql.com/downloads/mysql/
[3]: http://wp-cli.org
[4]: https://getcomposer.org
[5]: https://www.nginx.com
[6]: https://www.apache.org