Skip to content

Instantly share code, notes, and snippets.

@pavr0m
Created March 7, 2023 15:44
Show Gist options
  • Save pavr0m/a4ca70824328eeb225c1e156711b521e to your computer and use it in GitHub Desktop.
Save pavr0m/a4ca70824328eeb225c1e156711b521e to your computer and use it in GitHub Desktop.
Bash script for WP-CLI to download and install WordPress
#!/bin/bash
read -p "Enter the WordPress version you want to install (e.g., 5.9.1): " wp_version
wp core download --version="$wp_version"
read -p "Enter the name of the database for WordPress: " db_name
read -p "Enter the database username: " db_user
read -s -p "Enter the database password: " db_password
mysql -u root -p -e "CREATE DATABASE $db_name;"
mysql -u root -p -e "CREATE USER '$db_user'@'localhost' IDENTIFIED BY '$db_password';"
mysql -u root -p -e "GRANT ALL PRIVILEGES ON $db_name.* TO '$db_user'@'localhost';"
wp config create --dbname="$db_name" --dbuser="$db_user" --dbpass="$db_password"
read -p "Enter the URL for your site (e.g., http://your-site-url.com): " site_url
read -p "Enter the title for your site: " site_title
read -p "Enter the admin username for your site: " admin_user
read -s -p "Enter the admin password for your site: " admin_password
read -p "Enter the admin email for your site: " admin_email
wp core install --url="$site_url" --title="$site_title" --admin_user="$admin_user" --admin_password="$admin_password" --admin_email="$admin_email"
echo "WordPress Core $wp_version has been successfully downloaded and installed!"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment