Skip to content

Instantly share code, notes, and snippets.

@marceltannich
Last active June 5, 2025 12:43
Show Gist options
  • Save marceltannich/de2df70d09d33c56c423aaefd06bb599 to your computer and use it in GitHub Desktop.
Save marceltannich/de2df70d09d33c56c423aaefd06bb599 to your computer and use it in GitHub Desktop.
Example script to automate WordPress setups
#!/bin/bash
# 1) Adjust the script to your needs
# 2) Set the permission to run it with chmod +x wp-setup.sh
# 3) Call the script via ./wp-setup.sh
echo "πŸš€ WordPress Automated Setup"
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
# User prompts
read -p "Install WordPress core? (Y/n): " INSTALL_CORE
INSTALL_CORE=${INSTALL_CORE:-Y}
if [[ ! "$INSTALL_CORE" =~ ^[Yy]$ ]]; then
echo "❌ Installation skipped."
exit 0
fi
read -p "Site title: " SITE_TITLE
SITE_TITLE=${SITE_TITLE:-"My Demo Site"}
# Install WordPress
echo "πŸ“¦ Installing WordPress..."
wp core download
# Configure WordPress
echo "βš™οΈ Configuring..."
wp config create --dbname=demo_db --dbuser=root --dbpass=password \
--extra-php <<< "define('WP_DEBUG', true);"
wp core install --url=http://demo.local --title="$SITE_TITLE" \
--admin_user=marcel --admin_password=mysecretpw123 --admin_email=demo@test.com
# Set permalinks
wp rewrite structure '/%postname%/'
# Install plugins
echo "πŸ”Œ Installing plugins..."
wp plugin install woocommerce --activate
wp plugin install wordpress-seo --activate
# Install Storefront theme
echo "🎨 Installing theme..."
wp theme install storefront --activate
echo ""
echo "βœ… Done! Site: $SITE_TITLE"
echo "πŸ”— URL: http://demo.local"
echo "πŸ‘€ Admin: marcel / mysecretpw123"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment