Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@chancesmith
Last active November 24, 2021 11:47
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save chancesmith/57bca25c2aac49cd30995142b1abdcc8 to your computer and use it in GitHub Desktop.
Save chancesmith/57bca25c2aac49cd30995142b1abdcc8 to your computer and use it in GitHub Desktop.
Wordpress Setup shell script

Setup Instructions

  • add wp-setup.sh to your home directory
  • in terminal $ chmod +x wp-setup.sh so we can execute this without admin permissions needed
  • add an alias in your terminal profile and source the profile...(see command in next step)
  • $ echo '\n\n alias wpsetup="~/wp-setup.sh"' >> ~/.zshrc && . ~/.zshrc

Usage

Now, when you are ready run $ wpsetup in the folder you want to setup Wordpress locally in.

I use ~/wip/ folder for all code projects. I would then $ cd ~/wip/ && mkdir wordpress-project/. Then... $ cd ~/wip/wordpress-project && wpsetup. The wpsetup is the new alias we created above in Setup Instructions.

#!/bin/bash
emailAddress="YOUREMAIL@DOMAIN.com"
echo "WP Setup: creating database and config file..."
read -p "Enter Database name : " databaseName
read -p "Enter Site Name name : " siteName
read -p "Enter SiteUrl name (DOMAIN.sh) : " siteUrl
echo "Your user/pass : sh/sh"
echo "Email: $emailAddress"
wp core download && wp core config --dbname=$databaseName --dbuser=root --dbpass= && wp db create && wp core install --title=$sitename --url=$siteUrl --admin_user=sh --admin_password=sh --admin_email=$emailAddress
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment