This repository contains shell scripts designed to automate the creation and removal of local WordPress sites running on Ubuntu.
Ubuntu (or Ubuntu running on WSL2) with:
- PHP 8.2+ with the curl, dom, gd, json, mbstring, mysqli, openssl, xml, zip modules enabled
- Apache with mod_rewrite enabled
- MariaDB 10.6+ with root access
- wp-cli (The
wp-create.sh
script will attempt to install it if it isn't installed)
This script uses set variables in an .env
file to automate the creation of local WordPress sites.
See the sample .env file
It prompts for a TITLE
and a SLUG
. If no TITLE
is provided, it defaults to 'WordPress'.
If no SLUG
is provided, it defaults to generating a SLUG
from the TITLE
truncated to a maximum of 15 characters.
It then performs the following functions:
- Creates the necessary directory structure at '
DEV_DIR
/SLUG
/wordpress' - Installs
wp-cli
if necessary - Downloads the latest version of WordPress
- Creates the wp-config.php file
- Creates the database user
DB_USER
if they do not already exist - Creates a new database with a name generated by replacing the dashes in the '
SLUG
' with underscores (DB_NAME
) - Grants all permissions for
DB_NAME
toDB_USER
- Installs WordPress with a database tables prefix of 'wp_
DB_NAME
_' - Checks
DB_DUMP_DIR
for an existing database dump file and imports it. In this order:SLUG
-dev.sqlSLUG
.sqlSLUG
-prod.sql
- If
SMTP_USER
andSMTP_PASS
are set, it installs and activates the Simple SMTP Mailer plugin.
This script removes everything and should be used with extreme caution.
Removes a WordPress site created by running the wp-create.sh
script:
- Prompts for the site's
SLUG
and then asks for confirmation of deletion - Asks if you want to delete the site's database
- Asks if you want to delete the Apache config file
- Create and/or navigate to the directory where you want to create WordPress sites (Should be the same as
DEV_DIR
)
mkdir -p /path/to/dev/directory && cd /path/to/dev/directory
- Clone (or download and extract) the repository into the directory
git clone [email protected]:joshmckibbin/wp-create.git .
- Make sure you have execute permissions for the scripts
chmod +x wp-create.sh wp-destroy.sh
- Copy the
.env-sample
file to.env
and replace the environment values with your own.
cp .env-sample .env
- Run one of the shell scripts
./wp-create.sh
- Profit?
This project is licensed under the MIT License. See the LICENSE file for details.