Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save tarunsinghaldotme/8c89acdf021e6762f99044d33cf1b4d8 to your computer and use it in GitHub Desktop.
Save tarunsinghaldotme/8c89acdf021e6762f99044d33cf1b4d8 to your computer and use it in GitHub Desktop.
Wordpress Installation, Configuration and Management using Command line

Wordpress Installation, Configuration and Management using Command line


There is a command line utility called wp-cli

  • To Install wordpress please follow following commands

  • Download wp-cli via curl

curl -O https://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/wp-cli.phar
  • To use wp-cli make this script executable.
chmod +x wp-cli.phar
  • If you have sudo permission or root access then move this file into user local directory so that you can access this globally
sudo mv wp-cli.phar /usr/local/bin/wp
  • Now check if everything is working fine !! by executing below command.
wp --info
  • Download the latest WordPress into the root directory of your server.
wp core download --path=/path/to/root/dir
  • Configure the wp-config file.
wp core config --dbname="<database_name>" --dbuser="<database_user>" --dbpass="<database_password>" --dbprefix=wp_ --path=/path/to/root/dir
  • Now it’s time to install WordPress.
wp core install --url="<site_name>" --title="<Site_titile>" --admin_user="<admin_username>" --admin_password="admin_password"  --admin_email="<email_address>" --path=/path/to/root/dir

Basic WordPress installation has been done. but we didn’t end up here, now we will see how to install themes and plugins to our installed WordPress. But before that we should get familiar with the term SLUG. I hope you may know this but still for the one who may or may not know Slug is the user-friendly and URL valid name of a post. Most common usage of this feature is to create a permalink for each post.

I will take an example so that, you can understand it more easily.

there is a plugin Contact form 7 for WordPress whose URL is https://wordpress.org/plugins/contact-form-7/

slug for this plugin is contact-form-7 which we use to install via command line.

Likewise we can also get slug for WordPress themes

but what if you have zip file for the plugin or theme to be install. We will also discuss this.

so lets’s see how to install plugin and theme with the help of slugs and also with zip file.

  • Install Plugin through wp-cli
# via Slug
wp plugin install <Plugin Slug> --path=/path/to/root/dir
# via zip
wp plugin install /path/to/zip --path=/path/to/root/dir
  • ** Activate/Deactivate the Plugin**
# to activate
wp plugin activate <plugin_name> --path=/path/to/root/dir
# to deactivate
wp plugin deactivate <plugin_name> --path=/path/to/root/dir
  • Install Theme through wp-cli.
# via Slug
wp theme install <theme Slug> --path=/path/to/root/dir
# via zip
wp theme install /path/to/zip --path=/path/to/root/dir
  • Activate/Deactivate the Theme.
# to activate
wp theme activate <theme_name> --path=/path/to/root/dir
# to deactivate
wp theme deactivate <theme_name> --path=/path/to/root/dir
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment