WP-Cli Tips and tricks
Install wp-cli⌗
-
curl -O https://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/wp-cli.phar
-
php wp-cli.phar --info
-
chmod +x wp-cli.phar
-
mv wp-cli.phar /usr/local/bin/wp
Install new wordpress domain using wp-cli⌗
-
Make sure directory has permisisons for web user
-
cd "WEB_DIRECTORY"
-
sudo -u www-data wp core download
-
sudo -u www-data wp config create --dbname=DATABASE_NAME --dbuser=DATABASE_USER --dbpass=DATABASE_PASSWORD --dbhost=DATABASE_HOST
-
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
-
sudo -u www-data wp plugin delete 'hello'
-
sudo -u www-data wp plugin delete 'akismet'
-
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