Skip to content

Instantly share code, notes, and snippets.

@vladutilie
Last active February 9, 2023 10:43
Show Gist options
  • Save vladutilie/888c4b9df857e82ce64411eb1f6d59e8 to your computer and use it in GitHub Desktop.
Save vladutilie/888c4b9df857e82ce64411eb1f6d59e8 to your computer and use it in GitHub Desktop.
Localhost WordPress installation bash script
#!/bin/bash
read -p 'WWW directory path [/Users/vlad/www/]: ' READ_WWW_PATH
read -p 'Sitename (without no extension): ' SITENAME
read -p 'Site locale [ro_RO]: ' READ_SITE_LOCALE
WWW_PATH=${READ_WWW_PATH:='/Users/vlad/www'}
SITE_LOCALE=${READ_SITE_LOCALE:=ro_RO}
cd $WWW_PATH
cd $SITENAME
if [ $? -eq 0 ]; then
wp core download --locale=$SITE_LOCALE
wp config create --dbname=$SITENAME --dbuser=root --dbpass=root --dbhost=127.0.0.1
wp config set WP_DEBUG true --raw
wp config set SCRIPT_DEBUG true --raw
wp config set WP_POST_REVISIONS true --raw
mysql -uroot -p -e "CREATE DATABASE $SITENAME"
if [ $? -eq 0 ]; then
wp core install --url=$SITENAME'.test' --title=$SITENAME --admin_user=admin --admin_password=$SITENAME --admin_email=hello@vladilie.ro
# Author Mike https://guides.wp-bullet.com
# Purpose - Convert MyISAM tables to InnoDB with WP-CLI
# create array of MyISAM tables
WPTABLES=($(wp db query "SHOW TABLE STATUS WHERE Engine='MyISAM'" --allow-root --silent --skip-column-names | awk '{ print $1}'))
# loop through array and alter tables
for WPTABLE in ${WPTABLES[@]}
do
echo "Convertire motor tabel ${WPTABLE} la InnoDB..."
wp db query "ALTER TABLE ${WPTABLE} ENGINE=InnoDB" --allow-root
echo "Motorul tabelului ${WPTABLE} a fost convertit la InnoDB."
done
fi
else
echo "$WWW_PATH/$SITENAME does not exist"
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment