Install wp-cli

  1. curl -O https://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/wp-cli.phar

  2. php wp-cli.phar --info

  3. chmod +x wp-cli.phar

  4. mv wp-cli.phar /usr/local/bin/wp


Install new wordpress domain using wp-cli

  1. Make sure directory has permisisons for web user

  2. cd "WEB_DIRECTORY"

  3. sudo -u www-data wp core download

  4. sudo -u www-data wp config create --dbname=DATABASE_NAME --dbuser=DATABASE_USER --dbpass=DATABASE_PASSWORD --dbhost=DATABASE_HOST

  5. sudo -u www-data wp core install --url=URL_INCLUDING_HTTPS --title=SITE_TITLE --admin_user=ADMIN_USERNAME --admin_password=ADMIN_PASSWORD --admin_email=ADMIN_EMAIL --skip-email

  6. sudo -u www-data wp plugin delete 'hello'

  7. sudo -u www-data wp plugin delete 'akismet'

  8. sudo -u www-data wp post delete 1


Search-replace WP-cli

This is how to use wp-cli to change the domain

If using CentOS

sudo -u nginx wp search-replace 'old.domain.com' 'newdomain.com'

If using Debian

sudo -u www-data wp search-replace 'old.domain.com' 'newdomain.com'

If using Plesk

sudo -u user /opt/plesk/php/7.1/bin/php /usr/local/bin/wp search-replace 'old.domain.com' 'newdomain.com'

Regenerate media thumbnails

sudo -u www-data wp media regenerate MEDIA_ID_NUMBER MEDIA_ID_NUMBER